klibc.git
3 years agoManual merge of version 2.0.8-6.1+rpi1 and 2.0.10-4 to produce 2.0.10-4+rpi1 archive/raspbian/2.0.10-4+rpi1 raspbian/2.0.10-4+rpi1
Peter Michael Green [Thu, 3 Feb 2022 19:26:05 +0000 (19:26 +0000)]
Manual merge of version 2.0.8-6.1+rpi1 and 2.0.10-4 to produce 2.0.10-4+rpi1

3 years agoMerge klibc (2.0.10-4) import into refs/heads/workingbranch
Ben Hutchings [Sun, 30 Jan 2022 23:28:16 +0000 (23:28 +0000)]
Merge klibc (2.0.10-4) import into refs/heads/workingbranch

3 years ago[klibc] Fix header installation from out-of-tree build
Ben Hutchings [Sun, 30 Jan 2022 22:59:18 +0000 (23:59 +0100)]
[klibc] Fix header installation from out-of-tree build

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit?id=8d6ee65cc8bd75bba8f51589c667ff7c5fd9b3b5
Bug-Debian: https://bugs.debian.org/1004465

In an out-of-tree build we currently only install the kernel UAPI
headers and the generated <klibc/havesyscall.h>.  Add an extra
command to copy headers from the source tree in an out-of-tree
build.

References: https://bugs.debian.org/1004465
Reported-by: Thorsten Glaser <tg@mirbsd.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0001-klibc-Fix-header-installation-from-out-of-tree-build.patch

3 years ago[klibc] ia64: Fix out-of-tree build
Ben Hutchings [Sat, 1 Jan 2022 13:59:07 +0000 (14:59 +0100)]
[klibc] ia64: Fix out-of-tree build

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=2114e20cf16bbfb45a94aaf978d62d08d8968414

The linker script is currently not found in an out-of-tree build.
The filename needs to start with $(srctree) to make this work.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0001-klibc-ia64-Fix-out-of-tree-build.patch

3 years ago[klibc] Kbuild: Include provided KCFLAGS in KLIBCCFLAGS
Ben Hutchings [Fri, 31 Dec 2021 13:59:23 +0000 (14:59 +0100)]
[klibc] Kbuild: Include provided KCFLAGS in KLIBCCFLAGS

If KCFLAGS is provided through the environment or make variables, use
it in addition to all the options we need.

Gbp-Pq: Name klibc-kbuild-include-provided-kcflags-in-klibccflags.patch

3 years agoklibc (2.0.10-4) unstable; urgency=medium
Ben Hutchings [Sun, 30 Jan 2022 23:28:16 +0000 (23:28 +0000)]
klibc (2.0.10-4) unstable; urgency=medium

  * d/control, d/rules: Remove ccache from $PATH instead of Build-Conflicting
  * d/salsa-ci.yml: Add CI configuration for salsa.debian.org
  * d/tests: Add klcc smoke test
  * Fix header installation from out-of-tree build (Closes: #1004465)

[dgit import unpatched klibc 2.0.10-4]

3 years agoImport klibc_2.0.10-4.debian.tar.xz
Ben Hutchings [Sun, 30 Jan 2022 23:28:16 +0000 (23:28 +0000)]
Import klibc_2.0.10-4.debian.tar.xz

[dgit import tarball klibc 2.0.10-4 klibc_2.0.10-4.debian.tar.xz]

3 years agoMerge klibc (2.0.10-3) import into refs/heads/workingbranch
Ben Hutchings [Sat, 1 Jan 2022 15:55:44 +0000 (15:55 +0000)]
Merge klibc (2.0.10-3) import into refs/heads/workingbranch

3 years ago[klibc] ia64: Fix out-of-tree build
Ben Hutchings [Sat, 1 Jan 2022 13:59:07 +0000 (14:59 +0100)]
[klibc] ia64: Fix out-of-tree build

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=2114e20cf16bbfb45a94aaf978d62d08d8968414

The linker script is currently not found in an out-of-tree build.
The filename needs to start with $(srctree) to make this work.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0001-klibc-ia64-Fix-out-of-tree-build.patch

3 years ago[klibc] Kbuild: Include provided KCFLAGS in KLIBCCFLAGS
Ben Hutchings [Fri, 31 Dec 2021 13:59:23 +0000 (14:59 +0100)]
[klibc] Kbuild: Include provided KCFLAGS in KLIBCCFLAGS

If KCFLAGS is provided through the environment or make variables, use
it in addition to all the options we need.

Gbp-Pq: Name klibc-kbuild-include-provided-kcflags-in-klibccflags.patch

3 years agoklibc (2.0.10-3) unstable; urgency=medium
Ben Hutchings [Sat, 1 Jan 2022 15:55:44 +0000 (15:55 +0000)]
klibc (2.0.10-3) unstable; urgency=medium

  * ia64: Fix out-of-tree build

[dgit import unpatched klibc 2.0.10-3]

3 years agoImport klibc_2.0.10-3.debian.tar.xz
Ben Hutchings [Sat, 1 Jan 2022 15:55:44 +0000 (15:55 +0000)]
Import klibc_2.0.10-3.debian.tar.xz

[dgit import tarball klibc 2.0.10-3 klibc_2.0.10-3.debian.tar.xz]

3 years agoImport klibc_2.0.10.orig.tar.xz
Ben Hutchings [Thu, 30 Dec 2021 20:54:47 +0000 (20:54 +0000)]
Import klibc_2.0.10.orig.tar.xz

[dgit import orig klibc_2.0.10.orig.tar.xz]

3 years agoMerge klibc (2.0.9-1) import into refs/heads/workingbranch
Ben Hutchings [Sun, 26 Dec 2021 23:17:05 +0000 (23:17 +0000)]
Merge klibc (2.0.9-1) import into refs/heads/workingbranch

3 years ago[klibc] Fix implementation of utimes
Benjamin Gwin [Fri, 10 Dec 2021 00:42:36 +0000 (16:42 -0800)]
[klibc] Fix implementation of utimes

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=a13b588a915d3a4498bf342d85524eb7dde71594

This was not correctly initializing the timespec array before passing it
on to utimensat.

Tested: Built cpio and extracted an image with `cpio -im` to preserve
mtime. The calls to utime now pass through the correct timestamps.

Signed-off-by: Benjamin Gwin <bgwin@google.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name klibc-fix-implementation-of-utimes.patch

3 years ago{set,long}jmp [s390x]: save/restore the correct registers
mirabilos [Sun, 26 Dec 2021 23:17:05 +0000 (23:17 +0000)]
{set,long}jmp [s390x]: save/restore the correct registers

Forwarded: https://lists.zytor.com/archives/klibc/2021-May/004620.html

The s390x ABI actually has FPU registers f8‥f15, not f1/f3/f5/f7,
to be saved. (Closes: Debian #943425)

Gbp-Pq: Name 0041-klibc-set-long-jmp-s390x-save-restore-the-correct-re.patch

3 years agosig{set,long}jmp: do not ignore sigsetjmp's second argument
mirabilos [Wed, 5 May 2021 19:02:37 +0000 (21:02 +0200)]
sig{set,long}jmp: do not ignore sigsetjmp's second argument

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=eb10cf8c3128612a089ace8489a81bc4ffd5d07a
Bug-Debian: https://bugs.debian.org/988027

Save and restore the signal mask only if that argument is nonzero,
as required by the standards.  (Closes: Debian #988027)

Signed-off-by: mirabilos <tg@debian.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name sig-set-long-jmp-do-not-ignore-sigsetjmp-s-second-ar.patch

3 years agoklibc (2.0.9-1) unstable; urgency=medium
Ben Hutchings [Sun, 26 Dec 2021 23:17:05 +0000 (23:17 +0000)]
klibc (2.0.9-1) unstable; urgency=medium

  * New upstream version
  * armhf: Update compiler options for gcc 11 (Closes: #996906)
  * sig{set,long}jmp: do not ignore sigsetjmp's second argument
    (Closes: #988027)
  * Fix implementation of utimes

[dgit import unpatched klibc 2.0.9-1]

3 years agoImport klibc_2.0.9.orig.tar.xz
Ben Hutchings [Sun, 26 Dec 2021 23:17:05 +0000 (23:17 +0000)]
Import klibc_2.0.9.orig.tar.xz

[dgit import orig klibc_2.0.9.orig.tar.xz]

3 years agoImport klibc_2.0.9-1.debian.tar.xz
Ben Hutchings [Sun, 26 Dec 2021 23:17:05 +0000 (23:17 +0000)]
Import klibc_2.0.9-1.debian.tar.xz

[dgit import tarball klibc 2.0.9-1 klibc_2.0.9-1.debian.tar.xz]

4 years agoMerge version 2.0.8-6+rpi1 and 2.0.8-6.1 to produce 2.0.8-6.1+rpi1 bullseye-staging archive/raspbian/2.0.8-6.1+rpi1 raspbian/2.0.8-6.1+rpi1
Raspbian automatic forward porter [Thu, 10 Jun 2021 20:07:05 +0000 (21:07 +0100)]
Merge version 2.0.8-6+rpi1 and 2.0.8-6.1 to produce 2.0.8-6.1+rpi1

4 years agoMerge klibc (2.0.8-6.1) import into refs/heads/workingbranch
Thorsten Glaser [Wed, 26 May 2021 22:12:10 +0000 (23:12 +0100)]
Merge klibc (2.0.8-6.1) import into refs/heads/workingbranch

4 years ago{set,long}jmp [s390x]: save/restore the correct registers
mirabilos [Wed, 26 May 2021 22:12:10 +0000 (23:12 +0100)]
{set,long}jmp [s390x]: save/restore the correct registers

Forwarded: https://lists.zytor.com/archives/klibc/2021-May/004620.html

The s390x ABI actually has FPU registers f8‥f15, not f1/f3/f5/f7,
to be saved. (Closes: Debian #943425)

Gbp-Pq: Name 0041-klibc-set-long-jmp-s390x-save-restore-the-correct-re.patch

4 years ago[klibc] cpio: Fix possible crash on 64-bit systems
Ben Hutchings [Wed, 28 Apr 2021 17:46:47 +0000 (19:46 +0200)]
[klibc] cpio: Fix possible crash on 64-bit systems

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=2e48a12ab1e30d43498c2d53e878a11a1b5102d5
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2021-31871

copyin_link() tries to allocate (unsigned int)c_filesize + 1 bytes.
If c_filesize == UINT_MAX, this works out as 0 bytes, resulting in a
null pointer and a subsequent SIGSEGV.

The previous commit made this impossible on 32-bit systems.

CVE-2021-31871

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0040-klibc-cpio-Fix-possible-crash-on-64-bit-systems.patch

4 years ago[klibc] cpio: Fix possible integer overflow on 32-bit systems
Ben Hutchings [Wed, 28 Apr 2021 03:16:34 +0000 (05:16 +0200)]
[klibc] cpio: Fix possible integer overflow on 32-bit systems

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=9b1c91577aef7f2e72c3aa11a27749160bd278ff
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2021-31872

The maximum name and file sizes in the "new" header format are 32-bit
unsigned values.  However, the I/O functions mostly use long for sizes
and offsets, so that sizes >= 2^31 are handled wrongly on 32-bit
systems.

The current GNU cpio code doesn't seem to have this problem, but the
divergence between this version and that is large enough that I can't
simply cherry-pick a fix for it.

As a short-term fix, in read_in_new_ascii(), fail if c_namesize or
c_filesize is > LONG_MAX.

CVE-2021-31872

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0039-klibc-cpio-Fix-possible-integer-overflow-on-32-bit-s.patch

4 years ago[klibc] calloc: Fail if multiplication overflows
Ben Hutchings [Wed, 28 Apr 2021 02:29:50 +0000 (04:29 +0200)]
[klibc] calloc: Fail if multiplication overflows

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=292650f04c2b5348b4efbad61fb014ed09b4f3f2
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2021-31870

calloc() multiplies its 2 arguments together and passes the result to
malloc().  Since the factors and product both have type size_t, this
can result in an integer overflow and subsequent buffer overflow.
Check for this and fail if it happens.

CVE-2021-31870

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0037-klibc-calloc-Fail-if-multiplication-overflows.patch

4 years ago[klibc] malloc: Fail if requested size > PTRDIFF_MAX
Ben Hutchings [Wed, 28 Apr 2021 02:03:49 +0000 (04:03 +0200)]
[klibc] malloc: Fail if requested size > PTRDIFF_MAX

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=a31ae8c508fc8d1bca4f57e9f9f88127572d5202
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2021-31873

malloc() adds some overhead to the requested size, which may result in
an integer overflow and subsequent buffer overflow if it is close to
SIZE_MAX.  It should fail if size is large enough for this to happen.

Further, it's not legal for a C object to be larger than
PTRDIFF_MAX (half of SIZE_MAX) as pointer arithmetic within it could
overflow.  So return failure immediately if size is greater than that.

CVE-2021-31873

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0036-klibc-malloc-Fail-if-requested-size-PTRDIFF_MAX.patch

4 years ago[klibc] malloc: Set errno on failure
Ben Hutchings [Wed, 28 Apr 2021 01:57:39 +0000 (03:57 +0200)]
[klibc] malloc: Set errno on failure

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=7f6626d12daa2f1efd9953d1f4ba2065348dc5cd

malloc() is specified to set errno = ENOMEM on failure, so do that.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0035-klibc-malloc-Set-errno-on-failure.patch

4 years ago[klibc] ia64: Fix definition of struct sigaction
Ben Hutchings [Fri, 28 Aug 2020 16:36:34 +0000 (17:36 +0100)]
[klibc] ia64: Fix definition of struct sigaction

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=811bff9cec254e3396493f4f2447862d252870ac

ia64 only provides the RT signal API, in which the type of sa_flags is
unsigned long and sa_mask is the last member of the struct.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0001-klibc-ia64-Fix-definition-of-struct-sigaction.patch

4 years ago[klibc] sparc: Set sa_restorer for signals and disable executable stack
Ben Hutchings [Thu, 30 Apr 2020 12:56:47 +0000 (13:56 +0100)]
[klibc] sparc: Set sa_restorer for signals and disable executable stack

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=05350b72cace18417c1ba00c4796a5e19ebb908b

sparc allows specifiying a signal restorer in the usual way.  We
should do this to avoid needing an executable stack.

* Define a __sigreturn() routine that calls rt_sigreturn
* Force the SA_RESTORER flag on for all signal handlers, and set
  __sigreturn as the restorer if none is already set
* Force the SA_SIGINFO flag on for all signal handlers, so that we can
  always return from them with rt_sigreturn
* Set KLIBCEXECSTACK=n

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0005-klibc-sparc-Set-sa_restorer-for-signals-and-disable-.patch

4 years ago[klibc] alpha: Pass restorer to rt_sigaction() and disable executable stack
Ben Hutchings [Sun, 23 Aug 2020 14:18:19 +0000 (15:18 +0100)]
[klibc] alpha: Pass restorer to rt_sigaction() and disable executable stack

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=570ed1e207cbe38ed487c722f8ac7db68e664a94

alpha does not support the SA_RESTORER flag, but allows specifiying a
restorer callback as an additional parameter to rt_sigaction().  We
should do this to avoid needing an executable stack.

* Force the SA_SIGINFO flag on for all signal handlers, so that we can
  always return from them with rt_sigreturn
* Define a __sigreturn() routine that calls rt_sigreturn
* Pass that routine as the last argument to rt_sigaction()
* Set KLIBCEXECSTACK=n

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0004-klibc-alpha-Pass-restorer-to-rt_sigaction-and-disabl.patch

4 years ago[klibc] s390: Set sa_restorer for signals and disable executable stack
Ben Hutchings [Thu, 30 Apr 2020 02:38:34 +0000 (03:38 +0100)]
[klibc] s390: Set sa_restorer for signals and disable executable stack

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=c341c978e3024b9c575fac94012fc5b6f5679334

s390 allows specifiying a signal restorer in the usual way.  We
should do this to avoid needing an executable stack.

* Define a __sigreturn() routine that calls rt_sigreturn
* Force the SA_RESTORER flag on for all signal handlers, and set
  __sigreturn as the restorer if none is already set
* Force the SA_SIGINFO flag on for all signal handlers, so that we can
  always return from them with rt_sigreturn
* Set KLIBCEXECSTACK=n

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0003-klibc-s390-Set-sa_restorer-for-signals-and-disable-e.patch

4 years ago[klibc] signal: Add sysconfig setting to force SA_SIGINFO on
Ben Hutchings [Tue, 25 Aug 2020 00:05:28 +0000 (01:05 +0100)]
[klibc] signal: Add sysconfig setting to force SA_SIGINFO on

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=2a2a0b6b79c2470f529daabd5c193f58fe188337

On alpha, arm, i386, m68k, powerpc, s390, sh, and sparc (32-bit), the
kernel sets up the signal stack frame differently depending on the
SA_SIGINFO flag, not whether the sigaction() or rt_sigaction() system
call was used to install the handler.

On alpha and sparc, we are going to start providing our own restorer
that will call rt_sigaction(), so will need to ensure this flag is
always set.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0002-klibc-signal-Add-sysconfig-setting-to-force-SA_SIGIN.patch

4 years ago[klibc] signal: Note another reason to define _KLIBC_NEEDS_SA_RESTORER
Ben Hutchings [Mon, 24 Aug 2020 23:43:33 +0000 (00:43 +0100)]
[klibc] signal: Note another reason to define _KLIBC_NEEDS_SA_RESTORER

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=ccc5c14c44f3fa76f61b8aae947cf3b853a6c833

On some architectures we should set SA_RESTORER to avoid the need for
a signal trampoline and executable stack.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0001-klibc-signal-Note-another-reason-to-define-_KLIBC_NE.patch

4 years ago[klibc] alpha: Fix definitions of _NSIG and struct sigaction
Ben Hutchings [Thu, 27 Aug 2020 00:58:19 +0000 (01:58 +0100)]
[klibc] alpha: Fix definitions of _NSIG and struct sigaction

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=1cd11aaed1dece773c6b1ce2e99a0fe98b51321e

We use the RT signals API, but include the kernel UAPI header
that defines _NSIG and struct sigaction for the old API.

Copy over all the definitions and fix those two.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0001-klibc-alpha-Fix-definitions-of-_NSIG-and-struct-siga.patch

4 years agoklibc (2.0.8-6.1) unstable; urgency=medium
Thorsten Glaser [Wed, 26 May 2021 22:12:10 +0000 (23:12 +0100)]
klibc (2.0.8-6.1) unstable; urgency=medium

  * Non-maintainer upload.
  * {set,long}jmp [s390x]: save/restore the correct FPU registers
    (f8‥f15 not f1/f3/f5/f7) (Closes: #943425)

[dgit import unpatched klibc 2.0.8-6.1]

4 years agoImport klibc_2.0.8-6.1.debian.tar.xz
Thorsten Glaser [Wed, 26 May 2021 22:12:10 +0000 (23:12 +0100)]
Import klibc_2.0.8-6.1.debian.tar.xz

[dgit import tarball klibc 2.0.8-6.1 klibc_2.0.8-6.1.debian.tar.xz]

4 years agoMerge version 2.0.8-1+rpi1 and 2.0.8-6 to produce 2.0.8-6+rpi1 archive/raspbian/2.0.8-6+rpi1 raspbian/2.0.8-6+rpi1
Raspbian automatic forward porter [Sat, 8 May 2021 13:09:44 +0000 (14:09 +0100)]
Merge version 2.0.8-1+rpi1 and 2.0.8-6 to produce 2.0.8-6+rpi1

4 years agoMerge klibc (2.0.8-6) import into refs/heads/workingbranch
Ben Hutchings [Fri, 30 Apr 2021 01:05:23 +0000 (02:05 +0100)]
Merge klibc (2.0.8-6) import into refs/heads/workingbranch

4 years ago[klibc] cpio: Fix possible crash on 64-bit systems
Ben Hutchings [Wed, 28 Apr 2021 17:46:47 +0000 (19:46 +0200)]
[klibc] cpio: Fix possible crash on 64-bit systems

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=2e48a12ab1e30d43498c2d53e878a11a1b5102d5
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2021-31871

copyin_link() tries to allocate (unsigned int)c_filesize + 1 bytes.
If c_filesize == UINT_MAX, this works out as 0 bytes, resulting in a
null pointer and a subsequent SIGSEGV.

The previous commit made this impossible on 32-bit systems.

CVE-2021-31871

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0040-klibc-cpio-Fix-possible-crash-on-64-bit-systems.patch

4 years ago[klibc] cpio: Fix possible integer overflow on 32-bit systems
Ben Hutchings [Wed, 28 Apr 2021 03:16:34 +0000 (05:16 +0200)]
[klibc] cpio: Fix possible integer overflow on 32-bit systems

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=9b1c91577aef7f2e72c3aa11a27749160bd278ff
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2021-31872

The maximum name and file sizes in the "new" header format are 32-bit
unsigned values.  However, the I/O functions mostly use long for sizes
and offsets, so that sizes >= 2^31 are handled wrongly on 32-bit
systems.

The current GNU cpio code doesn't seem to have this problem, but the
divergence between this version and that is large enough that I can't
simply cherry-pick a fix for it.

As a short-term fix, in read_in_new_ascii(), fail if c_namesize or
c_filesize is > LONG_MAX.

CVE-2021-31872

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0039-klibc-cpio-Fix-possible-integer-overflow-on-32-bit-s.patch

4 years ago[klibc] calloc: Fail if multiplication overflows
Ben Hutchings [Wed, 28 Apr 2021 02:29:50 +0000 (04:29 +0200)]
[klibc] calloc: Fail if multiplication overflows

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=292650f04c2b5348b4efbad61fb014ed09b4f3f2
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2021-31870

calloc() multiplies its 2 arguments together and passes the result to
malloc().  Since the factors and product both have type size_t, this
can result in an integer overflow and subsequent buffer overflow.
Check for this and fail if it happens.

CVE-2021-31870

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0037-klibc-calloc-Fail-if-multiplication-overflows.patch

4 years ago[klibc] malloc: Fail if requested size > PTRDIFF_MAX
Ben Hutchings [Wed, 28 Apr 2021 02:03:49 +0000 (04:03 +0200)]
[klibc] malloc: Fail if requested size > PTRDIFF_MAX

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=a31ae8c508fc8d1bca4f57e9f9f88127572d5202
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2021-31873

malloc() adds some overhead to the requested size, which may result in
an integer overflow and subsequent buffer overflow if it is close to
SIZE_MAX.  It should fail if size is large enough for this to happen.

Further, it's not legal for a C object to be larger than
PTRDIFF_MAX (half of SIZE_MAX) as pointer arithmetic within it could
overflow.  So return failure immediately if size is greater than that.

CVE-2021-31873

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0036-klibc-malloc-Fail-if-requested-size-PTRDIFF_MAX.patch

4 years ago[klibc] malloc: Set errno on failure
Ben Hutchings [Wed, 28 Apr 2021 01:57:39 +0000 (03:57 +0200)]
[klibc] malloc: Set errno on failure

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=7f6626d12daa2f1efd9953d1f4ba2065348dc5cd

malloc() is specified to set errno = ENOMEM on failure, so do that.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0035-klibc-malloc-Set-errno-on-failure.patch

4 years ago[klibc] ia64: Fix definition of struct sigaction
Ben Hutchings [Fri, 28 Aug 2020 16:36:34 +0000 (17:36 +0100)]
[klibc] ia64: Fix definition of struct sigaction

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=811bff9cec254e3396493f4f2447862d252870ac

ia64 only provides the RT signal API, in which the type of sa_flags is
unsigned long and sa_mask is the last member of the struct.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0001-klibc-ia64-Fix-definition-of-struct-sigaction.patch

4 years ago[klibc] sparc: Set sa_restorer for signals and disable executable stack
Ben Hutchings [Thu, 30 Apr 2020 12:56:47 +0000 (13:56 +0100)]
[klibc] sparc: Set sa_restorer for signals and disable executable stack

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=05350b72cace18417c1ba00c4796a5e19ebb908b

sparc allows specifiying a signal restorer in the usual way.  We
should do this to avoid needing an executable stack.

* Define a __sigreturn() routine that calls rt_sigreturn
* Force the SA_RESTORER flag on for all signal handlers, and set
  __sigreturn as the restorer if none is already set
* Force the SA_SIGINFO flag on for all signal handlers, so that we can
  always return from them with rt_sigreturn
* Set KLIBCEXECSTACK=n

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0005-klibc-sparc-Set-sa_restorer-for-signals-and-disable-.patch

4 years ago[klibc] alpha: Pass restorer to rt_sigaction() and disable executable stack
Ben Hutchings [Sun, 23 Aug 2020 14:18:19 +0000 (15:18 +0100)]
[klibc] alpha: Pass restorer to rt_sigaction() and disable executable stack

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=570ed1e207cbe38ed487c722f8ac7db68e664a94

alpha does not support the SA_RESTORER flag, but allows specifiying a
restorer callback as an additional parameter to rt_sigaction().  We
should do this to avoid needing an executable stack.

* Force the SA_SIGINFO flag on for all signal handlers, so that we can
  always return from them with rt_sigreturn
* Define a __sigreturn() routine that calls rt_sigreturn
* Pass that routine as the last argument to rt_sigaction()
* Set KLIBCEXECSTACK=n

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0004-klibc-alpha-Pass-restorer-to-rt_sigaction-and-disabl.patch

4 years ago[klibc] s390: Set sa_restorer for signals and disable executable stack
Ben Hutchings [Thu, 30 Apr 2020 02:38:34 +0000 (03:38 +0100)]
[klibc] s390: Set sa_restorer for signals and disable executable stack

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=c341c978e3024b9c575fac94012fc5b6f5679334

s390 allows specifiying a signal restorer in the usual way.  We
should do this to avoid needing an executable stack.

* Define a __sigreturn() routine that calls rt_sigreturn
* Force the SA_RESTORER flag on for all signal handlers, and set
  __sigreturn as the restorer if none is already set
* Force the SA_SIGINFO flag on for all signal handlers, so that we can
  always return from them with rt_sigreturn
* Set KLIBCEXECSTACK=n

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0003-klibc-s390-Set-sa_restorer-for-signals-and-disable-e.patch

4 years ago[klibc] signal: Add sysconfig setting to force SA_SIGINFO on
Ben Hutchings [Tue, 25 Aug 2020 00:05:28 +0000 (01:05 +0100)]
[klibc] signal: Add sysconfig setting to force SA_SIGINFO on

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=2a2a0b6b79c2470f529daabd5c193f58fe188337

On alpha, arm, i386, m68k, powerpc, s390, sh, and sparc (32-bit), the
kernel sets up the signal stack frame differently depending on the
SA_SIGINFO flag, not whether the sigaction() or rt_sigaction() system
call was used to install the handler.

On alpha and sparc, we are going to start providing our own restorer
that will call rt_sigaction(), so will need to ensure this flag is
always set.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0002-klibc-signal-Add-sysconfig-setting-to-force-SA_SIGIN.patch

4 years ago[klibc] signal: Note another reason to define _KLIBC_NEEDS_SA_RESTORER
Ben Hutchings [Mon, 24 Aug 2020 23:43:33 +0000 (00:43 +0100)]
[klibc] signal: Note another reason to define _KLIBC_NEEDS_SA_RESTORER

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=ccc5c14c44f3fa76f61b8aae947cf3b853a6c833

On some architectures we should set SA_RESTORER to avoid the need for
a signal trampoline and executable stack.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0001-klibc-signal-Note-another-reason-to-define-_KLIBC_NE.patch

4 years ago[klibc] alpha: Fix definitions of _NSIG and struct sigaction
Ben Hutchings [Thu, 27 Aug 2020 00:58:19 +0000 (01:58 +0100)]
[klibc] alpha: Fix definitions of _NSIG and struct sigaction

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=1cd11aaed1dece773c6b1ce2e99a0fe98b51321e

We use the RT signals API, but include the kernel UAPI header
that defines _NSIG and struct sigaction for the old API.

Copy over all the definitions and fix those two.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0001-klibc-alpha-Fix-definitions-of-_NSIG-and-struct-siga.patch

4 years agoklibc (2.0.8-6) unstable; urgency=medium
Ben Hutchings [Fri, 30 Apr 2021 01:05:23 +0000 (02:05 +0100)]
klibc (2.0.8-6) unstable; urgency=medium

  * Upload to unstable
  * malloc: Set errno on failure
  * malloc: Fail if requested size > PTRDIFF_MAX (CVE-2021-31873)
  * calloc: Fail if multiplication overflows (CVE-2021-31870)
  * cpio: Fix possible integer overflow on 32-bit systems (CVE-2021-31872)
  * cpio: Fix possible crash on 64-bit systems (CVE-2021-31871)

[dgit import unpatched klibc 2.0.8-6]

4 years agoImport klibc_2.0.8-6.debian.tar.xz
Ben Hutchings [Fri, 30 Apr 2021 01:05:23 +0000 (02:05 +0100)]
Import klibc_2.0.8-6.debian.tar.xz

[dgit import tarball klibc 2.0.8-6 klibc_2.0.8-6.debian.tar.xz]

5 years agoMerge version 2.0.7-1+rpi1 and 2.0.8-1 to produce 2.0.8-1+rpi1 archive/raspbian/2.0.8-1+rpi1 raspbian/2.0.8-1+rpi1
Raspbian automatic forward porter [Mon, 31 Aug 2020 20:11:44 +0000 (21:11 +0100)]
Merge version 2.0.7-1+rpi1 and 2.0.8-1 to produce 2.0.8-1+rpi1

5 years agoImport klibc_2.0.8.orig.tar.xz
Ben Hutchings [Fri, 21 Aug 2020 00:34:13 +0000 (01:34 +0100)]
Import klibc_2.0.8.orig.tar.xz

[dgit import orig klibc_2.0.8.orig.tar.xz]

5 years agoMerge klibc (2.0.8-1) import into refs/heads/workingbranch
Ben Hutchings [Fri, 21 Aug 2020 00:34:13 +0000 (01:34 +0100)]
Merge klibc (2.0.8-1) import into refs/heads/workingbranch

5 years agoklibc (2.0.8-1) unstable; urgency=medium
Ben Hutchings [Fri, 21 Aug 2020 00:34:13 +0000 (01:34 +0100)]
klibc (2.0.8-1) unstable; urgency=medium

  [ Ben Hutchings ]
  * New upstream version:
    - ipconfig: Ignore NTP server address and any additional fields
      (Closes: #931416)
    - Kbuild: Add "-fcommon" for clang builds (Closes: #957405)
    - Kbuild: Add a per-architecture option to disable exectable stacks
    - arch: Explicitly disable or enable executable stacks (Closes: #959070)
  * debian/control: Use my debian.org email in Uploaders field
  * Use debhelper compatibility level 12:
    - Build-Depend on debhelper-compat and remove debian/compat
    - debian/klibc-utils.triggers: Delete as redundant
  * debian/rules: Really disable stripping libc.so in libklibc-dev

  [ Debian Janitor ]
  * Trim trailing whitespace.
  * Set upstream metadata fields: Repository.

[dgit import unpatched klibc 2.0.8-1]

5 years agoImport klibc_2.0.8-1.debian.tar.xz
Ben Hutchings [Fri, 21 Aug 2020 00:34:13 +0000 (01:34 +0100)]
Import klibc_2.0.8-1.debian.tar.xz

[dgit import tarball klibc 2.0.8-1 klibc_2.0.8-1.debian.tar.xz]

6 years agoManual merge of version 2.0.6-1+rpi1 and 2.0.7-1 to produce 2.0.7-1+rpi1 archive/raspbian/2.0.7-1+rpi1 raspbian/2.0.7-1+rpi1
Peter Michael Green [Tue, 15 Oct 2019 13:16:18 +0000 (13:16 +0000)]
Manual merge of version 2.0.6-1+rpi1 and 2.0.7-1 to produce 2.0.7-1+rpi1

6 years agoMerge klibc (2.0.7-1) import into refs/heads/workingbranch
Ben Hutchings [Tue, 8 Oct 2019 01:14:11 +0000 (02:14 +0100)]
Merge klibc (2.0.7-1) import into refs/heads/workingbranch

6 years agofstype: Drop obsolete support for "ext4dev"
Ben Hutchings [Mon, 7 Oct 2019 19:39:46 +0000 (20:39 +0100)]
fstype: Drop obsolete support for "ext4dev"

This is obsolete since Linux 2.6.28, and it's now causing problems for
people using compressed modules because we don't recognise the ext4
module with a .gz or .xz extension.

Reported-by: Greg Edwards <gedwards@ddn.com>
References: https://bugs.debian.org/932926
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name klibc-fstype-drop-obsolete-support-for-ext4dev.patch

6 years agoklibc (2.0.7-1) unstable; urgency=medium
Ben Hutchings [Tue, 8 Oct 2019 01:14:11 +0000 (02:14 +0100)]
klibc (2.0.7-1) unstable; urgency=medium

  [ Ben Hutchings ]
  * New upstream version:
    - klcc: Enable stripping even if CONFIG_DEBUG_INFO is enabled
    - run-init: Allow the initramfs to be persisted across root changes
      (thanks to Matthew Garrett)
    - ipconfig: Implement support -d ...:dns0:dns1 options (Closes: #931416)
    - Kbuild: Work around broken "ar s" in binutils 2.32 (see #941921)
  * debian/rules: Reorganise make flags variables
  * debian/rules: Define ARCH for klibc, for all architectures
  * debian/rules: Delete redundant architecture mappings
  * debian/rules: Delete redundant export
  * klibc-utils: Trigger update-initramfs on install/upgrade
  * initramfs-tools: Don't install commands that already exist in /sbin
  * initramfs-tools: Exclude kinit and zcat commands earlier
  * initramfs-tools: Exclude gzip command
  * Drop "resume: Backward compatibility for resume_offset", which will
    not be needed in the next release
  * [klibc] fstype: Drop obsolete support for "ext4dev" (Closes: #932926)
  * debian/control: Set Maintainer to Debian Kernel Team; move maks to
    Uploaders

  [ James Clarke ]
  * debian/control: Restrict m4 build dependency to just sparc

  [ Helmut Grohne ]
  * Honour DEB_BUILD_OPTIONS=nocheck. (Closes: #922814)

[dgit import unpatched klibc 2.0.7-1]

6 years agoImport klibc_2.0.7.orig.tar.gz
Ben Hutchings [Tue, 8 Oct 2019 01:14:11 +0000 (02:14 +0100)]
Import klibc_2.0.7.orig.tar.gz

[dgit import orig klibc_2.0.7.orig.tar.gz]

6 years agoImport klibc_2.0.7-1.debian.tar.xz
Ben Hutchings [Tue, 8 Oct 2019 01:14:11 +0000 (02:14 +0100)]
Import klibc_2.0.7-1.debian.tar.xz

[dgit import tarball klibc 2.0.7-1 klibc_2.0.7-1.debian.tar.xz]

6 years agoMerge version 2.0.4-15+rpi1 and 2.0.6-1 to produce 2.0.6-1+rpi1 archive/raspbian/2.0.6-1+rpi1 raspbian/2.0.6-1+rpi1
Raspbian automatic forward porter [Thu, 7 Feb 2019 14:05:03 +0000 (14:05 +0000)]
Merge version 2.0.4-15+rpi1 and 2.0.6-1 to produce 2.0.6-1+rpi1

6 years agoMerge klibc (2.0.6-1) import into refs/heads/workingbranch
Ben Hutchings [Fri, 1 Feb 2019 05:00:57 +0000 (05:00 +0000)]
Merge klibc (2.0.6-1) import into refs/heads/workingbranch

6 years agoresume: Backward compatibility for resume_offset
Ben Hutchings [Thu, 19 Jul 2018 20:34:08 +0000 (21:34 +0100)]
resume: Backward compatibility for resume_offset

In Debian we will need to maintain backward compatibility with Linux
4.9 at least until after the "buster" release.  Therefore we need to
accept that /sys/power/resume_offset might not exist.

If we can't open that file because it doesn't exist, we should check
whether the offset we are trying to set is the offset that the kernel
would use anyway.  In that case, continue.

Gbp-Pq: Name resume-backward-compatibility-for-resume_offset.patch

6 years agoklibc (2.0.6-1) unstable; urgency=medium
Ben Hutchings [Fri, 1 Feb 2019 05:00:57 +0000 (05:00 +0000)]
klibc (2.0.6-1) unstable; urgency=medium

  * New upstream version:
    - ia64: Fix shared build (thanks to James Clarke)
    - Drop nearly all patches, which are either included or obsoleted
  * debian/control: Change Architecture of all packages to linux-any
  * debian/control: Mark libklibc as M-A: same (suggested by Matthias Klose)
  * debian/control: Mark klibc-utils as M-A: foreign
  * initramfs-tools: Remove checks for shell installed as "sh.shared"
  * debian/rules: Change override_dh_auto_test rule to actually run tests

[dgit import unpatched klibc 2.0.6-1]

6 years agoImport klibc_2.0.6.orig.tar.gz
Ben Hutchings [Fri, 1 Feb 2019 05:00:57 +0000 (05:00 +0000)]
Import klibc_2.0.6.orig.tar.gz

[dgit import orig klibc_2.0.6.orig.tar.gz]

6 years agoImport klibc_2.0.6-1.debian.tar.xz
Ben Hutchings [Fri, 1 Feb 2019 05:00:57 +0000 (05:00 +0000)]
Import klibc_2.0.6-1.debian.tar.xz

[dgit import tarball klibc 2.0.6-1 klibc_2.0.6-1.debian.tar.xz]

6 years agoMerge version 2.0.4-14+rpi1 and 2.0.4-15 to produce 2.0.4-15+rpi1 archive/raspbian/2.0.4-15+rpi1 raspbian/2.0.4-15+rpi1
Raspbian automatic forward porter [Tue, 15 Jan 2019 11:32:43 +0000 (11:32 +0000)]
Merge version 2.0.4-14+rpi1 and 2.0.4-15 to produce 2.0.4-15+rpi1

6 years agoMerge klibc (2.0.4-15) import into refs/heads/workingbranch
Ben Hutchings [Sun, 6 Jan 2019 19:33:01 +0000 (19:33 +0000)]
Merge klibc (2.0.4-15) import into refs/heads/workingbranch

6 years agoDisable PIE
Ben Hutchings [Sun, 6 Jan 2019 03:44:40 +0000 (03:44 +0000)]
Disable PIE

We link all executables as non-relocatable, so it makes no sense to
generate PIE code.  In addition, PIE code on i386 requires a working
GOT which we don't generate.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name disable-pie.patch

6 years agoi386: Use -Ttext-segment to avoid address collision
Ben Hutchings [Sun, 6 Jan 2019 03:19:51 +0000 (03:19 +0000)]
i386: Use -Ttext-segment to avoid address collision

Building klibc for i386 with binutils 2.31 adds an extra
.note.gnu.property section to klibc.so, the address of which is not
affected by the -Ttext option.  Loading a klibc executable then
fails with the following kernel log message:

9409 (sh.shared): Uhuuh, elf segment at 0000000000600000 requested but the memory is mapped already

I don't exactly see why this is happening, but it is triggered by the
new section and the collision can be avoided by passing -Ttext-segment
instead of -Ttext, similarly to x86_64.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name i386-use-ttext-segment-to-avoid-address-collision.patch

6 years agoresume: Backward compatibility for resume_offset
Ben Hutchings [Thu, 19 Jul 2018 20:34:08 +0000 (21:34 +0100)]
resume: Backward compatibility for resume_offset

In Debian we will need to maintain backward compatibility with Linux
4.9 at least until after the "buster" release.  Therefore we need to
accept that /sys/power/resume_offset might not exist.

If we can't open that file because it doesn't exist, we should check
whether the offset we are trying to set is the offset that the kernel
would use anyway.  In that case, continue.

Gbp-Pq: Name resume-backward-compatibility-for-resume_offset.patch

6 years agoresume: Write resume_offset attribute
Ben Hutchings [Thu, 19 Jul 2018 19:09:28 +0000 (20:09 +0100)]
resume: Write resume_offset attribute

Support for a device offset as part of the string written to
/sys/power/resume never got into a mainline kernel.

However, since Linux 4.17 there is a separate resume_offset attribute
that we can use to set the offset before attempting to resume.

Change resume() to write the resume_offset attribute instead.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name resume-write-resume_offset-parameter.patch

6 years agoFix sparc assembly when compiled as PIC
James Clarke [Wed, 18 Jul 2018 21:30:42 +0000 (22:30 +0100)]
Fix sparc assembly when compiled as PIC

Some distributions default to PIE for their compilers, which on sparc is passed
on to the assembler. Since the behaviour of %hi/%lo changes under PIC to become
GOT offsets, the current assembly files need adapting to not try to use a GOT
offset as an absolute address.

Gbp-Pq: Name sparc-pie.patch

6 years agoAdd RISC-V (RV64) port
Ben Hutchings [Tue, 17 Jul 2018 01:55:19 +0000 (02:55 +0100)]
Add RISC-V (RV64) port

RISC-V is pretty boring.  I've cribbed most of this from the MIPS and
AArch64 ports.

I ran into difficulty with initialisation of the gp,register, which I
think has to be process-global - the psABI says that signal handlers
can rely on it, and they could come from any module.  This means that
klibc.so and the executable using it need to agree on a single value.
Currently they don't, and this causes gp-relative addressing to go
wrong.

gp-relative addressing is introduced by "relaxation" in the linker,
so I've disabled that for now.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name add-riscv-rv64-port.patch

6 years agorename, renameat: Use renameat2() system call
Ben Hutchings [Mon, 16 Jul 2018 17:24:08 +0000 (18:24 +0100)]
rename, renameat: Use renameat2() system call

New architectures only define the renameat2() system call, which was
added in Linux 3.15.  Define rename() and renameat() as wrappers for
it if necessary.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name rename-renameat-use-rename2-system-call.patch

6 years agox86_64: Use -Ttext-segment to avoid address collision
Ben Hutchings [Sat, 5 Jan 2019 20:59:33 +0000 (20:59 +0000)]
x86_64: Use -Ttext-segment to avoid address collision

Building klibc for x86_64 with binutils 2.31 adds an extra
.note.gnu.property section to klibc.so, the address of which is not
affected by the -Ttext option.  Loading a klibc executable then
fails with the following kernel log message:

9409 (sh.shared): Uhuuh, elf segment at 0000000000200000 requested but the memory is mapped already

I don't exactly see why this is happening, but it is triggered by the
new section and the collision can be avoided by passing -Ttext-segment
instead of -Ttext.  A similar change was applied to MIPS recently.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name x86_64-use-ttext-segment-to-avoid-address-collision.patch

6 years agox86_64: Reduce ld max-page-size option again
Ben Hutchings [Sun, 15 Jul 2018 20:27:09 +0000 (21:27 +0100)]
x86_64: Reduce ld max-page-size option again

Building klibc with binutils 2.30 results in the following layout
for klibc.so:

Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         0000d1ff  0000000000200200  0000000000200200  00000200  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .rodata       000031af  0000000000300000  0000000000300000  00100000  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .data.rel.ro  00000990  0000000000403660  0000000000403660  00103660  2**5
                  CONTENTS, ALLOC, LOAD, DATA
  3 .data         00000140  0000000000404000  0000000000404000  00104000  2**5
                  CONTENTS, ALLOC, LOAD, DATA
  4 .bss          000042f8  0000000000404140  0000000000404140  00104140  2**5
                  ALLOC

The .text and .rodata sections have each been padded to the specified
maximum page size of 1 MB, causing the following sections to overlap
the executable.

This causes all klibc executables to crash immediately.

Since there's no architectural page size betwen 4 KB and 2MB, set
max-page-size to 4 KB.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name x86_64-reduce-ld-max-page-size-option-again.patch

6 years agoadd-reboot-argument-support
maximilian attems [Sun, 6 Jan 2019 19:33:01 +0000 (19:33 +0000)]
add-reboot-argument-support

Bug-Debian ;https://bugs.debian.org/863761
Forwarded: http://www.zytor.com/pipermail/klibc/2017-May/003957.html
Last-Update: 2017-05-22

Gbp-Pq: Name add-reboot-argument-support.patch

6 years agomips64: compile with -mno-abicalls
James Cowgill [Fri, 2 Mar 2018 14:48:21 +0000 (14:48 +0000)]
mips64: compile with -mno-abicalls

By default, the MIPS toolchain compiles all code as PIC. Since klibc
links everything at static addresses, we don't need PIC code so use
-mno-abicalls to disable it. To fix subsequent link errors, use
-Ttext-segment to adjust the base address of klibc to a more sensible
location.

This fixes a bug in the shared library form of klibc where programs
would segfault in the syscall handler because we tried to store into the
"errno" variable without setting up the gp register. This is only required
under the PIC ABI.

Signed-off-by: James Cowgill <james.cowgill@mips.com>
Gbp-Pq: Name mips64-compile-with-mno-abicalls.patch

6 years agomount_main: Fix empty string check
Benjamin Drung [Wed, 13 Jun 2018 09:48:39 +0000 (11:48 +0200)]
mount_main: Fix empty string check

gcc 7.3.0 complains:

```
usr/utils/mount_main.c: In function ‘print_mount’:
usr/utils/mount_main.c:46:46: warning: comparison between pointer and zero character constant [-Wpointer-compare]
   if (mnt->mnt_type != NULL && mnt->mnt_type != '\0')
                                              ^~
usr/utils/mount_main.c:46:32: note: did you mean to dereference the pointer?
   if (mnt->mnt_type != NULL && mnt->mnt_type != '\0')
                                ^
usr/utils/mount_main.c:48:46: warning: comparison between pointer and zero character constant [-Wpointer-compare]
   if (mnt->mnt_opts != NULL && mnt->mnt_opts != '\0')
                                              ^~
usr/utils/mount_main.c:48:32: note: did you mean to dereference the pointer?
   if (mnt->mnt_opts != NULL && mnt->mnt_opts != '\0')
                                ^
```

Gbp-Pq: Name mount_main-Fix-empty-string-check.patch

6 years agoImplement classless static routes
Benjamin Drung [Wed, 13 Dec 2017 22:04:29 +0000 (23:04 +0100)]
Implement classless static routes

Implement classless static routes support as specified in RFC3442.

Bug-Debian: https://bugs.debian.org/884716
Bug-Ubuntu: https://launchpad.net/bugs/1526956
Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
Gbp-Pq: Name Implement-classless-static-routes.patch

6 years agoia64-build-static-tools
maximilian attems [Sun, 6 Jan 2019 19:33:01 +0000 (19:33 +0000)]
ia64-build-static-tools

Gbp-Pq: Name ia64-build-static-tools.patch

6 years agoAdd accept4(), handle fallback from accept() to accept4()
H. Peter Anvin [Wed, 6 Jan 2016 02:31:40 +0000 (18:31 -0800)]
Add accept4(), handle fallback from accept() to accept4()

Add support for the accept4() system call.

Some architectures now have accept4() but not accept(), so introduce a
standard fallback.  However, since accept() is a socketcall, we have
to do some special hacks.

While we are at it, handle conditional socketcall stubs based on
their existence <linux/net.h>, analogous to <asm/unistd.h>.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Gbp-Pq: Name klibc-add-accept4-handle-fallback-from-accept-to-acc.patch

6 years agoi386: remove special handling of socketcall
H. Peter Anvin [Wed, 6 Jan 2016 00:43:50 +0000 (16:43 -0800)]
i386: remove special handling of socketcall

As of kernel 4.3, i386 now has direct system calls for sockets, so
drop the special handling for i386 socketcall.  If built on older
kernels, it will still generate socketcall stubs although they will be
less efficient.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
[bwh: Backported to 2.0.4: adjust context]

Gbp-Pq: Name klibc-i386-remove-special-handling-of-socketcall.patch

6 years agodhcp-one-socket-per-interface
maximilian attems [Sun, 6 Jan 2019 19:33:01 +0000 (19:33 +0000)]
dhcp-one-socket-per-interface

Gbp-Pq: Name dhcp-one-socket-per-interface.patch

6 years agoSet broadcast when sending DHCPREQUEST and DHCPDISCOVER
Mathieu Trudel-Lapierre [Sun, 6 Jan 2019 19:33:01 +0000 (19:33 +0000)]
Set broadcast when sending DHCPREQUEST and DHCPDISCOVER

We need to do this, since our devices are probably not configured yet and
there may be more than one device we're trying to do DHCP on on the same
network. Otherwise, things might be dropped.

Patch is originally from here:
https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/1327412/comments/5
... but the reporter "patpat" has not provided contact information, and
this is independently verifiable by looking at RFC 2131, section 4.1,
page 24.

Gbp-Pq: Name broadcast_dhcp_send.patch

6 years agorun-init: Add dry-run mode
Ben Hutchings [Sun, 17 Jan 2016 19:50:28 +0000 (19:50 +0000)]
run-init: Add dry-run mode

initramfs-tools wants to validate the real init program before running
it, as there is no way out once it has exec'd run-init.  This is
complicated by the increasing use of symlinks for /sbin/init and for
/sbin itself.  We can't simply resolve them with 'readlink -f' because
any absolute symlinks will be resolved using the wrong root.  Add a
dry-run mode (-n option) to run-init that goes as far as possible to
validate that the given init is executable.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name run-init-add-dry-run-mode.patch

6 years agomips/setjmp.S: don't save and restore floating-point registers
YunQiang Su [Sat, 5 Sep 2015 13:39:25 +0000 (06:39 -0700)]
mips/setjmp.S: don't save and restore floating-point registers

Klibc FTBFS with '-mno-odd-spreg' on mips32(el) platforms,
As it try to save/restore odd-number FPR.

Indeed no other architectures save/restore FPR at all.
It shouldn't be needed.

Gbp-Pq: Name klibc-mips-setjmp-s-don-t-save-and-restore-floating-point.patch

6 years agogzip: Fix silent fallback to decompression
Ben Hutchings [Fri, 18 Sep 2015 19:59:17 +0000 (21:59 +0200)]
gzip: Fix silent fallback to decompression

If the gzip utilities are built without support for compression,
they will always attempt to carry out decompression even if the
command name and options don't imply that.  Instead they should
fail with an explicit error in this case.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name gzip-fix-silent-fallback-to-decompression.patch

6 years agoppc64: fix struct stat
Aurelien Jarno [Sat, 25 Apr 2015 12:16:16 +0000 (14:16 +0200)]
ppc64: fix struct stat

On ppc64 the struct stat defined by klibc matches the kernel one.
However it contains implicit padding before the st_rdev field due to the
64-bit alignement. For internal reasons, klibc defines st_rdev as a pair
of 32-bit values (using the __stdev64 macro). They only need to be
32-bit aligned and as a consequence st->st_rdev is incorrectly defined.

The solution is to add an explicit padding in the structure. This fixes
the resume binary on ppc64 BE and LE, and probably other things.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Gbp-Pq: Name klibc-ppc64-fix-struct-stat.patch

6 years agoAdd pread and pwrite 32bit syscall wrappers for parisc
Helge Deller [Wed, 23 Apr 2014 20:52:53 +0000 (22:52 +0200)]
Add pread and pwrite 32bit syscall wrappers for parisc

On the hppa arch (32bit userspace and 32 or 64bit kernel), the fstype
program fails to detect the filesystem.  The reason for this failure
is, that fstype calls the pread() syscall, which has on some
architectures with 32bit userspace a different calling syntax.  I
noticed this bug on hppa, but I assume s390 (32bit) and others might
run into similiar issues.

Signed-off-by: Helge Deller <deller@gmx.de>
Gbp-Pq: Name klibc-add-pread-and-pwrite-32bit-syscall-wrappers-for-parisc.patch

6 years agodash: mkbuiltins: Fix sort order harder
Ben Hutchings [Wed, 9 Sep 2015 01:12:40 +0000 (02:12 +0100)]
dash: mkbuiltins: Fix sort order harder

LC_COLLATE can be overriden by LC_ALL, so set LC_ALL instead when
running sort.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name dash-mkbuiltins-fix-sort-order-harder.patch

6 years agoInstall headers with consistent mode
Ben Hutchings [Wed, 9 Sep 2015 00:24:56 +0000 (01:24 +0100)]
Install headers with consistent mode

Currently we ensure the installed headers are readable by everyone,
but write permissions will depend on the current umask.  Turn off the
group and other writable bits to ensure consistent results.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name install-headers-with-consistent-mode.patch

6 years agoadd-mips64-support-arch-mips64-specific
Dejan Latinovic [Fri, 6 Mar 2015 00:51:45 +0000 (16:51 -0800)]
add-mips64-support-arch-mips64-specific

Description: Adding mips64 specific chagnes.
Modeled on mips 32 and adapted for 64 bit ABI.
 - MCONFIG:  using existing klibc.ld scrpit
 - crt0.S:   adapted gp initialization
 - setjmp.S: do not save floating-point state

Gbp-Pq: Name 0003-add-mips64-support-arch-mips64-specific.patch

6 years agoadd-mips64-support-arch-mips32
Dejan Latinovic [Fri, 6 Mar 2015 00:51:44 +0000 (16:51 -0800)]
add-mips64-support-arch-mips32

Description: Add mips64 support, using existing mips32 code.
 - using mips32 assembler source files: pipe.S vfork.S syscall.S
 - sysstub.ph: copied over from klibc/arch/mips

Gbp-Pq: Name 0002-add-mips64-support-arch-mips32.patch

6 years agoadd-mips64-support-headers
Dejan Latinovic [Fri, 6 Mar 2015 00:51:44 +0000 (16:51 -0800)]
add-mips64-support-headers

Description: Added header files for mips64.
Modeled on mips 32 header files and adapted for 64 bit ABI.
 - archsetjmp.h: do not save floating-point state
 - asm.h:        Symbolic register names for 64 bit ABI

Gbp-Pq: Name 0001-add-mips64-support-headers.patch