]> Git Repo - uclibc-ng.git/log
uclibc-ng.git
19 months agotmp master
Jesse Taube [Mon, 19 Jun 2023 02:35:15 +0000 (22:35 -0400)]
tmp

20 months agouse prlimit if get/setrlimit doesnt exist
Jesse Taube [Fri, 5 May 2023 15:11:21 +0000 (11:11 -0400)]
use prlimit if get/setrlimit doesnt exist

20 months agoadd statx
Jesse Taube [Fri, 5 May 2023 03:01:36 +0000 (23:01 -0400)]
add statx

20 months agoadjtimex
Jesse Taube [Fri, 5 May 2023 01:37:33 +0000 (21:37 -0400)]
adjtimex

21 months agobump version for 1.0.43 release
Waldemar Brodkorb [Tue, 4 Apr 2023 22:01:20 +0000 (00:01 +0200)]
bump version for 1.0.43 release

22 months agoEmulate 'futimesat' when __NR_futimesat is not available.
Elliot Thomas [Mon, 6 Mar 2023 01:21:05 +0000 (01:21 +0000)]
Emulate 'futimesat' when __NR_futimesat is not available.

23 months agoriscv64: fix linking with binutils 2.40
Waldemar Brodkorb [Fri, 3 Feb 2023 07:30:45 +0000 (08:30 +0100)]
riscv64: fix linking with binutils 2.40

See here for details:
https://sourceware.org/bugzilla/show_bug.cgi?id=28509

23 months agoDefined MAP_FIXED_NOREPLACE
linted [Sat, 21 Jan 2023 21:19:23 +0000 (16:19 -0500)]
Defined MAP_FIXED_NOREPLACE

Added definition for MAP_FIXED_NOREPLACE which was added in kernel 4.17

Signed-off-by: linted <[email protected]>
23 months agoFix for CVE-2022-29503.
linted [Sat, 21 Jan 2023 20:22:48 +0000 (15:22 -0500)]
Fix for CVE-2022-29503.

Changed linux thread's stack allocation mmap to use new MAP_FIXED_NOREPLACE flag on kernels >4.17.
For older kernels, a check is added to see if requested address matches the address received.
If the addresses don't match, an error is returned and thread creation is aborted.

Signed-off-by: linted <[email protected]>
2 years agoAdd lost includes. Fix add getauxval() implementation.
Evgeniy Manachkin [Sun, 8 Jan 2023 10:02:57 +0000 (15:02 +0500)]
Add lost includes. Fix add getauxval() implementation.

Signed-off-by: Evgeniy Manachkin <[email protected]>
2 years agogettimeofday() vdso support
ramin [Sat, 10 Dec 2022 16:49:13 +0000 (17:49 +0100)]
gettimeofday() vdso support

2 years agosycall macro for vdso support
ramin [Sat, 10 Dec 2022 16:48:10 +0000 (17:48 +0100)]
sycall macro for vdso support

2 years agoadd getauxval() implementation
ramin [Wed, 7 Dec 2022 10:59:57 +0000 (11:59 +0100)]
add getauxval() implementation

2 years agouclibc-ng: fix overflow warning when compiling string/strchr in ILP32 mode on MIPS.
Evgeniy Manachkin [Wed, 30 Nov 2022 10:06:51 +0000 (15:06 +0500)]
uclibc-ng: fix overflow warning when compiling string/strchr in ILP32 mode on MIPS.

Signed-off-by: Evgeniy Manachkin <[email protected]>
2 years agoRISC-V 32-bit support
[email protected] [Sat, 19 Nov 2022 14:02:55 +0000 (14:02 +0000)]
RISC-V 32-bit support

Added 32-bit RISC-V support. I have managed to get 32-bit RISC-V No-MMU
Linux running based on mainstream buildroot. It's nice to have uclibc
support this 32-bit No-MMU target.

There's no substantial code change except definations and config
options.

Signed-off-by: Yimin Gu <[email protected]>
2 years agoStatic pie support for ppc
linted [Sat, 8 Oct 2022 02:49:12 +0000 (22:49 -0400)]
Static pie support for ppc

Modified config files and crt1.S to support static pie elf generation.

Signed-off-by: linted <[email protected]>
2 years agoarc: add optimized string functions for ARCv3
Pavel Kozlov [Fri, 7 Oct 2022 09:43:45 +0000 (13:43 +0400)]
arc: add optimized string functions for ARCv3

Add ability to use optimized versions of string functions for ARCv3 32-bit
CPUs with UCLIBC_HAS_STRING_ARCH_OPT option. Add optimized
memcpy/memset/memcmp code for ARCv3 CPUs based on the code from newlib
and adapt for ARCv3 existed optimized strchr/strcmp/strcpy/strlen.

Link to the Synopsys newlib repo with code for ARCv3 on GitHub:
https://github.com/foss-for-synopsys-dwc-arc-processors/newlib

Signed-off-by: Pavel Kozlov <[email protected]>
2 years agoarc: add support for ARCv3 32-bit processors
Sergey Matyukevich [Tue, 20 Sep 2022 12:14:21 +0000 (16:14 +0400)]
arc: add support for ARCv3 32-bit processors

New ARCv3 ISA includes both 64-bit and 32-bit CPU family.
This patch adds support for 32-bit ARCv3 HS5x processors.

Signed-off-by: Sergey Matyukevich <[email protected]>
Signed-off-by: Pavel Kozlov <[email protected]>
2 years agoarc: add asm macros
Sergey Matyukevich [Tue, 20 Sep 2022 12:14:20 +0000 (16:14 +0400)]
arc: add asm macros

Add a header file with assembler macros to be able to handle in one
place the differences between ARCv2 and ARCv3 ISAs. It is a preparatory
step before the introduction of support for ARCv3 CPUs.

Signed-off-by: Sergey Matyukevich <[email protected]>
Signed-off-by: Pavel Kozlov <[email protected]>
2 years agoldso: arc: add compiler option check
Sergey Matyukevich [Tue, 20 Sep 2022 12:14:19 +0000 (16:14 +0400)]
ldso: arc: add compiler option check

Option '-mno-long-calls' is not supported by all arc gcc compilers.
For instance, this option is not supported by GCC for ARCv3 processors.
Check if this option is supported before applying it.

Signed-off-by: Sergey Matyukevich <[email protected]>
Signed-off-by: Pavel Kozlov <[email protected]>
2 years agoarc: minor cleanup for ARCv2
Sergey Matyukevich [Tue, 20 Sep 2022 12:14:18 +0000 (16:14 +0400)]
arc: minor cleanup for ARCv2

Add missing ARCv2 check in MATCH_MACHINE macro.
Update comment for EM_ARCV2 define.

Signed-off-by: Sergey Matyukevich <[email protected]>
Signed-off-by: Pavel Kozlov <[email protected]>
2 years agoAdded some documentation on how to add static-pie support to the porting guide
linted [Mon, 26 Sep 2022 17:40:50 +0000 (13:40 -0400)]
Added some documentation on how to add static-pie support to the porting guide

Signed-off-by: linted <[email protected]>
2 years agoxtensa: add static pie support
Max Filippov [Thu, 15 Sep 2022 19:30:54 +0000 (12:30 -0700)]
xtensa: add static pie support

Signed-off-by: Max Filippov <[email protected]>
2 years agoxtensa: drop ARCH_NEEDS_BOOTSTRAP_RELOCS
Max Filippov [Thu, 15 Sep 2022 19:30:53 +0000 (12:30 -0700)]
xtensa: drop ARCH_NEEDS_BOOTSTRAP_RELOCS

Xtensa does not define PERFORM_BOOTSTRAP_RELOC so it doesn't need
ARCH_NEEDS_BOOTSTRAP_RELOCS definition. Remove it.

Signed-off-by: Max Filippov <[email protected]>
2 years agoxtensa: ldso: make GOT protection adjustment conditional
Max Filippov [Thu, 15 Sep 2022 19:30:52 +0000 (12:30 -0700)]
xtensa: ldso: make GOT protection adjustment conditional

Xtensa PERFORM_BOOTSTRAP_GOT macro uses mprotect to make bits of GOT
writable, but noMMU linux kernel returns ENOSYS to mprotect syscalls,
and syscall wrapper tries to update errno with the error code. This
happens well before the relocations are done and results in writes to
unrelated locations, memory corruption or protection violations.

Only define PERFORM_BOOTSTRAP_GOT when building xtensa configuration
with MMU support.

Signed-off-by: Max Filippov <[email protected]>
2 years agoldso: clean up PERFORM_BOOTSTRAP_GOT ifdeferry
Max Filippov [Thu, 15 Sep 2022 19:30:51 +0000 (12:30 -0700)]
ldso: clean up PERFORM_BOOTSTRAP_GOT ifdeferry

3 architectures currently define PERFORM_BOOTSTRAP_GOT: avr32, mips and
xtensa. A block of code that applies relative relocations in the
DL_START is disabled when PERFORM_BOOTSTRAP_GOT is defined, unless it's
avr32 or mips, effectively disabling it only for xtensa.
This may be simplified by removing the call to elf_machine_relative from
the xtensa PERFORM_BOOTSTRAP_GOT and always using common code.

Signed-off-by: Max Filippov <[email protected]>
2 years agostatic pie: fix building static PDE
Max Filippov [Thu, 15 Sep 2022 19:30:50 +0000 (12:30 -0700)]
static pie: fix building static PDE

When uclibc is built with static PIE support the _dl_load_base variable
shared between the libc-tls.c and reloc_static_pie.c creates the
dependency that requires linking reloc_static_pie.o into static
position-dependent executables resulting in the following build errors:
  gcc -static test.c -o test
  ...ld:
  ...usr/lib/libc.a(reloc_static_pie.os):(.text+0x0):
undefined reference to `_DYNAMIC'

Move _dl_load_base definition to libc-tls.c to resolve this dependency
and fix static PDE build.

Signed-off-by: Max Filippov <[email protected]>
2 years agonptl: use mmap to allocate initial TLS data for static PIE on noMMU
Max Filippov [Tue, 6 Sep 2022 13:44:44 +0000 (06:44 -0700)]
nptl: use mmap to allocate initial TLS data for static PIE on noMMU

Static PIE ELFs may be loaded on noMMU linux platforms with FDPIC
support, but they don't have adjustable brk, and thus cannot allocate
memory for the TLS. Use mmap instead of sbrk to allocate initial TLS
memory when building with static PIE support for noMMU.

Signed-off-by: Max Filippov <[email protected]>
2 years agoAdded support for creation of Static Position-Independent Executables (PIE) on mips
linted [Sat, 20 Aug 2022 20:41:38 +0000 (16:41 -0400)]
Added support for creation of Static Position-Independent Executables (PIE) on mips

Updated config to allow compilation of rcrt1.o for mips and modified it's crt1.S to perform relocates in __start.

The mips architecture performs relocations differently then most other architectures. reloc_static_pie was rewritten, taking code from dl-startup.c, in order to perfrom the additional relocations. Modifications were made to mips' dl-startup.h to allow for the use of contained macros without including _start definition.

Signed-off-by: linted <[email protected]>
2 years agobump version for 1.0.42 release
Waldemar Brodkorb [Wed, 10 Aug 2022 23:42:15 +0000 (01:42 +0200)]
bump version for 1.0.42 release

2 years agofix ARCH_NATIVE_BIT for aarch64
Waldemar Brodkorb [Wed, 10 Aug 2022 23:20:10 +0000 (01:20 +0200)]
fix ARCH_NATIVE_BIT for aarch64

Patch suggested by Thomas Petazzoni and tested by me.

Reported-by: Thomas Petazzoni <[email protected]>
2 years agoAdded support for creation of Static Position-Independent Executables (PIE) on aarch64
linted [Sat, 16 Jul 2022 20:23:45 +0000 (16:23 -0400)]
Added support for creation of Static Position-Independent Executables (PIE) on aarch64

Updated config to allow compilation of rcrt1.o for aarch64 and modified it's crt1.S to relocate dynamic section prior to __uClibc_main.

Disabled stack protector when compiling reloc_static_pie.c to avoid TLS access prior to it being setup.

Signed-off-by: linted <[email protected]>
2 years agoresource.h: add missing RUSAGE_THREAD
Waldemar Brodkorb [Mon, 8 Aug 2022 12:46:34 +0000 (14:46 +0200)]
resource.h: add missing RUSAGE_THREAD

There is a real-world usage of RUSAGE_THREAD by the pistache project,
https://github.com/oktal/pistache.

Reported-By: Thomas Petazzoni <[email protected]>
2 years agoAdded support for creation of Static Position-Independent Executables (PIE) on i386...
linted [Sat, 23 Jul 2022 20:25:41 +0000 (16:25 -0400)]
Added support for creation of Static Position-Independent Executables (PIE) on i386, x86_64, and arm.

This patch adds the generation of rcrt1.o which is used by gcc when compiling with the --static-pie flag.

rcrt1.o differs from crt1.o and Scrt1.o in that it the executable has a dynamic section but no relocations have been performed prior to _start being called.
crt1.o assumes there to be no dynamic relocations, and Scrt1.o has all relocations performed prior to execution by lsdo.

The new reloc_static_pie function handles parsing the dynamic section, and performing the relocations in a architecture agnostic method.
It also sets _dl_load_base which is used when initalizing TLS to ensure loading from the proper location.
This allows for easier porting of static-pie support to additional architectures as only modifications to crt1.S to find the load address are required.

Signed-off-by: linted <[email protected]>
2 years agolinuxthread/arm: Unlock ldrex/strex varsion of testandset for __ARM_ARCH >= 7
Vladimir Murzin [Mon, 18 Jul 2022 11:57:24 +0000 (12:57 +0100)]
linuxthread/arm: Unlock ldrex/strex varsion of testandset for __ARM_ARCH >= 7

Thomas has repored failure building ARM 32-bit systems for ARMv8 cores

  CC libpthread/linuxthreads/mutex.os
/tmp/ccn8SFKU.s: Assembler messages:
/tmp/ccn8SFKU.s:162: Error: swp{b} use is obsoleted for ARMv8 and later
/tmp/ccn8SFKU.s:186: Error: swp{b} use is obsoleted for ARMv8 and later
/tmp/ccn8SFKU.s:203: Error: swp{b} use is obsoleted for ARMv8 and later
/tmp/ccn8SFKU.s:224: Error: swp{b} use is obsoleted for ARMv8 and later
make[1]: *** [Makerules:369: libpthread/linuxthreads/mutex.os] Error 1

This is due to libpthread/linuxthreads/sysdeps/arm/pt-machine.h which
uses the swp instruction that is not allowed on ARMv8.

All __ARM_ARCH >= 7 support ldrex/strex instructions, so unlock
testandset() varaint for them.

Reported-by: Thomas Petazzoni <[email protected]>
Signed-off-by: Vladimir Murzin <[email protected]>
2 years agolinuxthreads/arm: fix ldrex/strex loop when built with O0
Vladimir Murzin [Mon, 18 Jul 2022 11:57:23 +0000 (12:57 +0100)]
linuxthreads/arm: fix ldrex/strex loop when built with O0

O0 build result in the following codegen

00000000 <ldrex>:
   0: b480       push {r7}
   2: b085       sub sp, #20
   4: af00       add r7, sp, #0
   6: 6078       str r0, [r7, #4]
   8: 687b       ldr r3, [r7, #4]
   a: e853 3f00  ldrex r3, [r3]
   e: 60fb       str r3, [r7, #12]
  10: 68fb       ldr r3, [r7, #12]
  12: 4618       mov r0, r3
  14: 3714       adds r7, #20
  16: 46bd       mov sp, r7
  18: f85d 7b04  ldr.w r7, [sp], #4
  1c: 4770       bx lr

0000001e <strex>:
  1e: b480       push {r7}
  20: b085       sub sp, #20
  22: af00       add r7, sp, #0
  24: 6078       str r0, [r7, #4]
  26: 6039       str r1, [r7, #0]
  28: 687b       ldr r3, [r7, #4]
  2a: 683a       ldr r2, [r7, #0]
  2c: e842 3300  strex r3, r3, [r2]
  30: 60fb       str r3, [r7, #12]
  32: 68fb       ldr r3, [r7, #12]
  34: 4618       mov r0, r3
  36: 3714       adds r7, #20
  38: 46bd       mov sp, r7
  3a: f85d 7b04  ldr.w r7, [sp], #4
  3e: 4770       bx lr

00000040 <testandset>:
  40: b590       push {r4, r7, lr}
  42: b083       sub sp, #12
  44: af00       add r7, sp, #0
  46: 6078       str r0, [r7, #4]
  48: 6878       ldr r0, [r7, #4]
  4a: f7ff fffe  bl 0 <ldrex>
  4e: 4603       mov r3, r0
  50: 461c       mov r4, r3
  52: 6879       ldr r1, [r7, #4]
  54: 2001       movs r0, #1
  56: f7ff fffe  bl 1e <strex>
  5a: 4603       mov r3, r0
  5c: 2b00       cmp r3, #0
  5e: d1f3       bne.n 48 <testandset+0x8>
  60: 4623       mov r3, r4
  62: 4618       mov r0, r3
  64: 370c       adds r7, #12
  66: 46bd       mov sp, r7
  68: bd90       pop {r4, r7, pc}

ARM ARM suggests that LoadExcl/StoreExcl loops are guaranteed to make
forward progress only if, for any LoadExcl/StoreExcl loop within a
single thread of execution, the software meets all of the following
conditions:

1 Between the Load-Exclusive and the Store-Exclusive, there are no
  explicit memory accesses, preloads, direct or indirect System
  register writes, address translation instructions, cache or TLB
  maintenance instructions, exception generating instructions,
  exception returns, or indirect branches.

...

Obviously condition is not met for O0 builds.

O2 build (which is highly likely the most common setting) able to do
the right thing resulting in

00000000 <ldrex>:
   0: e850 0f00  ldrex r0, [r0]
   4: 4770       bx lr
   6: bf00       nop

00000008 <strex>:
   8: e841 0000  strex r0, r0, [r1]
   c: 4770       bx lr
   e: bf00       nop

00000010 <testandset>:
  10: 2101       movs r1, #1
  12: 4603       mov r3, r0
  14: e853 0f00  ldrex r0, [r3]
  18: e843 1200  strex r2, r1, [r3]
  1c: 2a00       cmp r2, #0
  1e: d1f9       bne.n 14 <testandset+0x4>
  20: 4770       bx lr
  22: bf00       nop

Rather than depending on level of optimisation implement whole
ldrex/strex loop in inline assembly.

Signed-off-by: Vladimir Murzin <[email protected]>
2 years agoassert: Add static_assert macro
Nicolas Cavallari [Thu, 23 Jun 2022 15:21:11 +0000 (17:21 +0200)]
assert: Add static_assert macro

See the C11 standard 7.2 §3

The definition is copied from glibc.

Signed-off-by: Nicolas Cavallari <[email protected]>
2 years agoxtensa: implement user context manipulation functions
Max Filippov [Fri, 17 Jun 2022 09:40:11 +0000 (02:40 -0700)]
xtensa: implement user context manipulation functions

Implement getcontext, makecontext, setcontext and swapcontext.

Signed-off-by: Max Filippov <[email protected]>
2 years agoinet: gethostid: only accept v4 addresses
наб [Tue, 7 Jun 2022 15:39:04 +0000 (17:39 +0200)]
inet: gethostid: only accept v4 addresses

getaddrinfo() returns addresses from, at least, ip(7) and ipv6(7),
but _addr() always uses sin_addr from struct sockaddr_in;
we're saved from wild unsoundness (or incompatibility)
by virtue of struct sockaddr_in6 having an always-0 u32 sin6_flowinfo
at the same offset, so we end up returning 0 anyway,
but in a round-about and definitely unintended way

Instead, limit the request to AF_INET, and fall through to the end
early, returning the default id=0

Signed-off-by: Ahelenia Ziemiańska <[email protected]>
2 years agoDnsLookup: stdint, timeforced reseeding
hanishkvc [Mon, 23 May 2022 20:45:16 +0000 (02:15 +0530)]
DnsLookup: stdint, timeforced reseeding

Explicitly include stdint header as logic uses INT[64]_MAX, just
in case for future, even though the chain of headers from existing
includes brings in the definition indirectly as of now.

Cross check for time gap between prngplus reseeding, periodically,
has the internal state is being consumed, so that if there is too
much time gap, then prng reseeding can be forced, before the normal
reseed window is reached. This is useful for long running programs
which trigger dns queries only intermittently.

If clock_gettime is not available, then reseed more frequently, by
default. A platform developer may change the reseed frequence, to
be bit more less often in this case, if needed, by tweaking the
defines in the source.

Signed-off-by: hanishkvc <[email protected]>
2 years agolibc/misc/getloadavg: Add getloadavg support to uClibc-ng
lancethepants [Sat, 21 May 2022 02:37:10 +0000 (20:37 -0600)]
libc/misc/getloadavg: Add getloadavg support to uClibc-ng

This borrows getloadavg.c from musl.
getloadavg pops up often. Recently llvm and rust are dependent on it.
glibc and musl have it and no-one actually checks if it's available in your libc.
It's just become way easier to add it in uclibc-ng rather than patch everything else.

Signed-off-by: Lance Fredrickson <[email protected]>
2 years agobump version for 1.0.41 release
Waldemar Brodkorb [Fri, 20 May 2022 15:06:47 +0000 (17:06 +0200)]
bump version for 1.0.41 release

2 years agodefine RLIMIT_RTTIME, bump RLIMIT_NLIMITS
Romain Naour [Mon, 16 May 2022 21:13:05 +0000 (23:13 +0200)]
define RLIMIT_RTTIME, bump RLIMIT_NLIMITS

This macro exists since Linux 2.6.25 [1] and is defined in glibc
since 2.14 [2] for sparc and most supported architectures.

RLIMIT_RTTIME has been added later for mips [3] and alpha [4].

For example, RLIMIT_RTTIME is needed to build qemu 7.0.0 with
Linux user-land emulation support [5].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=78f2c7db6068fd6ef75b8c120f04a388848eacb5
[2] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=67f86a251e0d36107fe28999281d46e76941c7b9
[3] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=8969f4df1a526aa60dd0bc1c4736cf02104d4a05
[4] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=53c2cb7641bd866398156625ef672bbd2d78a0d8
[5] https://git.qemu.org/?p=qemu.git;a=commitdiff;h=244fd08323088db73590ff2317dfe86f810b51d7

Signed-off-by: Romain Naour <[email protected]>
2 years agoDnsLookup: Configurable dnsQueryId generation including random
hanishkvc [Tue, 10 May 2022 21:14:43 +0000 (02:44 +0530)]
DnsLookup: Configurable dnsQueryId generation including random

Dns lookup logic has been updated to provide a configurable compile
time selection of dns query id generation logics, including random,
where possible, instead of the previous simple counter mode.

This should make dns poison attempts more difficult. The uclibc
developers wish to thank the white hat teams which alerted the
community about the possible weakness in the dns path, given the
increased resources with adversaries today.

Given that embedded systems may or may not have sources for trying
to generate random numbers, and also to try and keep the load on
the system low, by default it uses the standard random prng based
logic to indirectly generate the ids.

However if either urandom or else if realtime clock is available on
the target, then the same is used to reseed the prng periodically
in a slightly non deterministic manner. Also additional transform
(one way where possible) is used to avoid directly exposing the
internal random sequence.

The dns lookup logic maintains its own state wrt the random prng
functions, so that other users of the library's random prng are
not affected wrt their operations with the prng.

Note to Platform developers:

If you want to change from the default prngplus based logic, to one
of the other logics provided, then during compile/config time you can
switch to one of these additional choices wrt dns query id generation,
by using make config and companions.

If your platform doesnt support urandom nor a realtime clock backed
by a source with sufficient resolution, and or for some reason if you
want to revert to previous simple counter, rather than the transformed
random prng plus logic, you can force the same at compile time by
selecting SimpleCounter mode.

If you want to increase the randomness of the generated ids, and dont
mind the increased system load and latency then you could select the
Urandom mode during config. Do note that it will be dipping into the
entropy pool maintained by ur system.

If your target has a system realtime clock available and exposed to
user space, and inturn if you want to keep the underlying logic simple,
you could try using the clock option from the config. However do note
that the clock should have nanosecond resolution to help generate ids
which are plausibly random. Also improvements to processor and or io
performance can affect this.

Wrt the URandom and Clock modes, if there is a failure with generation
of the next random value, the logic tries to fallback to simple counter
mode.

If you want to change the underlying logic to make it more random
and or more simple, look at dnsrand_setup and dnsrand_next.

Signed-off-by: hanishkvc <[email protected]>
2 years agoFix bug in ARM memset implementation
Tom Bannink [Tue, 12 Apr 2022 13:36:51 +0000 (13:36 +0000)]
Fix bug in ARM memset implementation

The ARM implementation of memset has a bug when the fill-value is negative or outside the
[0, 255] range. To reproduce:

    char array[256];
    memset(array, -5, 256);

This is supposed to fill the array with int8 values -5, -5, -5, ... . On ARM, this does
not work because the implementation assumes the high bytes of the fill-value argument are
already zero. However in this test case they are filled with 1-bits. The aarch64 and x86_64
implementations do not have this problem: they first convert the fill-value to an unsigned
byte following the specification of memset.

With GCC one can use  `memset(ptr, (-5 & 0xFF), size)` as a workaround, but for clang
users that does not work: clang optimizes the `& 0xFF` away because it assumes that
memset will do it.

Signed-off-by: Tom Bannink <[email protected]>
Acked-by: Peter Korsgaard <[email protected]>
2 years agolibm: fix bug in lrint.c
Waldemar Brodkorb [Tue, 12 Apr 2022 10:42:24 +0000 (12:42 +0200)]
libm: fix bug in lrint.c

Following test case returns 2, which should be 0.
int main() {
  long x = lrint(0.5);
  printf("%ld", x);
  return 0;
}

Fix from glibc commit 6624dbc07b5a9fb316ed188ef01f65b8eea8b47c

2 years agoarpa/nameser.h: add ns_t_tkey
Waldemar Brodkorb [Mon, 21 Mar 2022 19:07:10 +0000 (20:07 +0100)]
arpa/nameser.h: add ns_t_tkey

2 years agodl-elf: Supress adding double '/' in library pathname
Daniel Dorau [Fri, 4 Mar 2022 10:14:18 +0000 (11:14 +0100)]
dl-elf: Supress adding double '/' in library pathname

When searching for shared libraries, it could happen that redudant '/'
were added to the pathname with would later be reported via dladdr() in
the dli_fname member.

Signed-off-by: Daniel Dorau <[email protected]>
2 years agoguard prlimit, reported by Lance Fredrickson
Waldemar Brodkorb [Sun, 27 Feb 2022 01:40:00 +0000 (02:40 +0100)]
guard prlimit, reported by Lance Fredrickson

2 years agosched.h: Add SCHED_DEADLINE
Petr Vorel [Wed, 26 Jan 2022 22:20:57 +0000 (23:20 +0100)]
sched.h: Add SCHED_DEADLINE

Defined in kernel v3.14, commit
aab03e05e8f7 ("sched/deadline: Add SCHED_DEADLINE structures & implementation")

Signed-off-by: Petr Vorel <[email protected]>
2 years agobump version for 1.0.40 release
Waldemar Brodkorb [Mon, 24 Jan 2022 22:07:35 +0000 (23:07 +0100)]
bump version for 1.0.40 release

2 years agofix compile for Linuxthreads enabled
Waldemar Brodkorb [Fri, 21 Jan 2022 17:26:15 +0000 (18:26 +0100)]
fix compile for Linuxthreads enabled

Signed-off-by: Peter Seiderer <[email protected]>
2 years agoadd prlimit syscall wrapper, now for real
Waldemar Brodkorb [Fri, 21 Jan 2022 17:25:59 +0000 (18:25 +0100)]
add prlimit syscall wrapper, now for real

2 years agoadd prlimit syscall wrapper
Waldemar Brodkorb [Fri, 21 Jan 2022 03:20:30 +0000 (04:20 +0100)]
add prlimit syscall wrapper

2 years agonds32: sync with binutils 2.37, gcc 11.2 and linux 5.10.93 changes
Waldemar Brodkorb [Fri, 21 Jan 2022 02:43:00 +0000 (03:43 +0100)]
nds32: sync with binutils 2.37, gcc 11.2 and linux 5.10.93 changes

3 years agoarc: fix signal handler restorer
Sergey Matyukevich [Sat, 8 Jan 2022 20:53:42 +0000 (23:53 +0300)]
arc: fix signal handler restorer

When MD_FALLBACK_FRAME_STATE_FOR handler in libgcc unwind code checks
the second instruction opcode in __default_rt_sa_restorer function,
it expects to see the following values for ARC cores:
- 0x7ee0781e for ARCv2 LE
- 0x003f226f for ARC700 LE

ARC700 value correspond to trap0 instruction. ARCv2 value corresponds
to the following code:
        traps_0
        j_s     [blink]

However, unlike glibc, uClibc implementation of __default_rt_sa_restorer
for ARC does not have that jump. Hence libgcc unwind code is not able
to recognize signal frame correctly on ARCv2 and completes too early.

This change fixes libgcc unwinding over signal frame on ARCv2 adding
missing jump to __default_rt_sa_restorer.

Signed-off-by: Sergey Matyukevich <[email protected]>
3 years agoFix some warnings due to type issues
Yann Sionneau [Mon, 29 Nov 2021 15:33:35 +0000 (16:33 +0100)]
Fix some warnings due to type issues

Fixes those two warnings:

In file included from <command-line>:
libc/sysdeps/linux/common/openat64.c:18:33: warning: 'openat64' alias between functions of incompatible types 'int(int,  const char *, int,  ...)' and 'int(int,  const char *, int,  mode_t)' {aka 'int(int,  const char *, int,  unsigned int)'} [-Wattribute-alias=]
   18 | strong_alias_untyped(__openat64,openat64)
      |                                 ^~~~~~~~
./include/libc-symbols.h:177:31: note: in definition of macro '_strong_alias_untyped'
  177 |   extern __typeof (aliasname) aliasname __attribute__ ((alias (#name))) __attribute_copy__ (name);
      |                               ^~~~~~~~~
libc/sysdeps/linux/common/openat64.c:18:1: note: in expansion of macro 'strong_alias_untyped'
   18 | strong_alias_untyped(__openat64,openat64)
      | ^~~~~~~~~~~~~~~~~~~~
libc/sysdeps/linux/common/openat64.c:14:12: note: aliased declaration here
   14 | static int __openat64(int fd, const char *file, int oflag, mode_t mode)
      |            ^~~~~~~~~~

and

  CC libc/sysdeps/linux/common/stat.os
libc/sysdeps/linux/common/stat.c: In function 'stat':
libc/sysdeps/linux/common/stat.c:28:40: warning: passing argument 3 of 'fstatat64' from incompatible pointer type [-Wincompatible-pointer-types]
   28 |  return fstatat64(AT_FDCWD, file_name, buf, 0);
      |                                        ^~~
      |                                        |
      |                                        struct stat *
In file included from libc/sysdeps/linux/common/stat.c:11:
./include/sys/stat.h:258:35: note: expected 'struct stat64 * restrict' but argument is of type 'struct stat *'
  258 |         struct stat64 *__restrict __buf, int __flag)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~

Signed-off-by: Yann Sionneau <[email protected]>
3 years agoFix -Wundef related warnings
Yann Sionneau [Mon, 29 Nov 2021 15:33:34 +0000 (16:33 +0100)]
Fix -Wundef related warnings

Signed-off-by: Yann Sionneau <[email protected]>
3 years agokvx: fix warning about __BITS_PER_LONG not being defined
Yann Sionneau [Mon, 29 Nov 2021 15:33:33 +0000 (16:33 +0100)]
kvx: fix warning about __BITS_PER_LONG not being defined

Signed-off-by: Yann Sionneau <[email protected]>
3 years agolibc/inet/resolv: fix per thread res_state access
Peter Seiderer [Thu, 25 Nov 2021 20:18:25 +0000 (21:18 +0100)]
libc/inet/resolv: fix per thread res_state access

- use the provided __res_state() method instead of direct access
  to struct __res_state pointer &_res/*__resp

- change the __UCLIBC_HAS_TLS__ protected __res_state() implementation
  to the one where the comment 'When threaded, _res may be a per-thread
  variable.' indicates this should be used with threads/TLS enabled

Fixes the following segfaults with buildroot raspberrypi3_64_defconfig
(uclibc, -Os, Note: runs fine using the raspberrypi3_defconfig):

  $ /usr/sbin/ntpd -n -d
  1970-01-01T00:01:49 ntpd[249]: INIT: ntpd ntpsec-1.2.0 2021-11-03T20:39:50Z: Starting
  1970-01-01T00:01:49 ntpd[249]: INIT: Command line: /usr/sbin/ntpd -n -d
  1970-01-01T00:01:49 ntpd[249]: INIT: precision = 7.240 usec (-17)
  1970-01-01T00:01:49 ntpd[249]: INIT: successfully locked into RAM
  1970-01-01T00:01:49 ntpd[249]: CONFIG: readconfig: parsing file: /etc/ntp.conf
  1970-01-01T00:01:49 ntpd[249]: CONFIG: restrict nopeer ignored
  1970-01-01T00:01:49 ntpd[249]: INIT: Using SO_TIMESTAMPNS
  1970-01-01T00:01:49 ntpd[249]: IO: Listen and drop on 0 v6wildcard [::]:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listen and drop on 1 v4wildcard 0.0.0.0:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listen normally on 2 lo 127.0.0.1:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listen normally on 3 eth0 172.16.0.30:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listen normally on 4 lo [::1]:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listen normally on 5 eth0 [fe80::ba27:ebff:fea6:340%2]:123
  1970-01-01T00:01:49 ntpd[249]: IO: Listening on routing socket on fd #22 for interface updates
  1970-01-01T00:01:50 ntpd[249]: SYNC: Found 10 servers, suggest minsane at least 3
  1970-01-01T00:01:50 ntpd[249]: INIT: MRU 10922 entries, 13 hash bits, 65536 bytes
  1970-01-01T00:01:50 ntpd[249]: statistics directory /var/NTP/ does not exist or is unwriteable, error No such file or directory
  1970-01-01T00:01:51 ntpd[249]: DNS: dns_probe: 0.pool.ntp.org, cast_flags:8, flags:101
  Segmentation fault (core dumped)

  $ ./host/bin/aarch64-buildroot-linux-uclibc-gdb ./build/ntpsec-1_2_0/build/main/ntpd/ntpd core
  Core was generated by `/usr/sbin/ntpd -n -d'.
  Program terminated with signal SIGSEGV, Segmentation fault.
  (gdb) where
  #0  0x0000007f8ff1f150 in res_sync_func () at libc/inet/resolv.c:3356
  #1  0x0000007f8ff1c468 in __open_nameservers () at libc/inet/resolv.c:949
  #2  0x0000007f8ff1b498 in __dns_lookup (name=0x55943c67f0 "0.pool.ntp.org",
      type=1, outpacket=0x7f8fe91c48, a=0x7f8fe91c08) at libc/inet/resolv.c:1134
  #3  0x0000007f8ff1d744 in __GI_gethostbyname_r (
      name=0x55943c67f0 "0.pool.ntp.org", result_buf=0x7f8fe92628,
      buf=0x7f8fe91d90 "", buflen=992, result=0x7f8fe92670,
      h_errnop=0x7f8fe92668) at libc/inet/resolv.c:1966
  #4  0x0000007f8ff1d9a0 in __GI_gethostbyname2_r (
      name=0x55943c67f0 "0.pool.ntp.org", family=2, result_buf=0x7f8fe92628,
      buf=0x7f8fe91d70 "0.pool.ntp.org", buflen=1024, result=0x7f8fe92670,
      h_errnop=0x7f8fe92668) at libc/inet/resolv.c:2065
  #5  0x0000007f8ff16924 in gaih_inet (name=0x55943c67f0 "0.pool.ntp.org",
      service=0x7f8fe92828, req=0x7f8fe92890, pai=0x7f8fe92838)
      at libc/inet/getaddrinfo.c:596
  #6  0x0000007f8ff17624 in __GI_getaddrinfo (
      name=0x55943c67f0 "0.pool.ntp.org",
      service=0x5582eb8acd "\377H\213D$\bL\211\367H\213\260\270",
      hints=0x7f8fe92890, pai=0x5582ee1bf8) at libc/inet/getaddrinfo.c:957
  #7  0x0000005582ea60f4 in _start ()
  (gdb) p _res
  $1 = {options = 0, nsaddr_list = {{sin_family = 0, sin_port = 0, sin_addr = {
          s_addr = 0}, sin_zero = "\000\000\000\000\000\000\000"}, {
        sin_family = 0, sin_port = 0, sin_addr = {s_addr = 0},
        sin_zero = "\000\000\000\000\000\000\000"}, {sin_family = 0,
        sin_port = 0, sin_addr = {s_addr = 0},
        sin_zero = "\000\000\000\000\000\000\000"}}, dnsrch = {0x0, 0x0, 0x0,
      0x0, 0x0, 0x0, 0x0}, nscount = 0 '\000', ndots = 0 '\000',
    retrans = 0 '\000', retry = 0 '\000', defdname = '\000' <repeats 255 times>,
    nsort = 0 '\000', pfcode = 0, id = 0, res_h_errno = 0, sort_list = {{addr = {
          s_addr = 0}, mask = 0}, {addr = {s_addr = 0}, mask = 0}, {addr = {
          s_addr = 0}, mask = 0}, {addr = {s_addr = 0}, mask = 0}, {addr = {
          s_addr = 0}, mask = 0}, {addr = {s_addr = 0}, mask = 0}, {addr = {
          s_addr = 0}, mask = 0}, {addr = {s_addr = 0}, mask = 0}, {addr = {
          s_addr = 0}, mask = 0}, {addr = {s_addr = 0}, mask = 0}}, _u = {
      _ext = {nsaddrs = {0x0, 0x0, 0x0}, nscount = 0 '\000', nstimes = {0, 0,
          0}, nssocks = {0, 0, 0}, nscount6 = 0, nsinit = 0}}}
  (gdb) p &_res
  $2 = (struct __res_state *) 0x7f8ff8fd98 <_res>
  (gdb) p rp
  $3 = (struct __res_state *) 0x7fffffffff

  And the following uclibc code at libc/inet/resolv.c:3356:

  3345 static void res_sync_func(void)
  3346 {
  3347         struct __res_state *rp = &(_res);
  3348         int n;
  3349
  3350         /* If we didn't get malloc failure earlier... */
  3351         if (__nameserver != (void*) &__local_nameserver) {
  3352                 /* TODO:
  3353                  * if (__nameservers < rp->nscount) - try to grow __nameserver[]?
  3354                  */
  3355 #ifdef __UCLIBC_HAS_IPV6__
  3356                 if (__nameservers > rp->_u._ext.nscount)
  3357                         __nameservers = rp->_u._ext.nscount;
  3358                 n = __nameservers;

  The special thing about ntpsec is the DNS lookup in an extra thread
  and/or the call to res_init(), see ntpsec-1_2_0/ntpd/ntp_dns.c:

   69         msyslog(LOG_INFO, "DNS: dns_probe: %s, cast_flags:%x, flags:%x%s",
   70                 hostname, pp->cast_flags, pp->cfg.flags, busy);
   71         if (NULL != active)     /* normally redundant */
   72                 return false;
   73
   74         active = pp;
   75
   76         sigfillset(&block_mask);
   77         pthread_sigmask(SIG_BLOCK, &block_mask, &saved_sig_mask);
   78         rc = pthread_create(&worker, NULL, dns_lookup, pp);

  and

  165 static void* dns_lookup(void* arg)
  166 {
  167         struct peer *pp = (struct peer *) arg;
  168         struct addrinfo hints;
  169
  170 #ifdef HAVE_SECCOMP_H
  171         setup_SIGSYS_trap();      /* enable trap for this thread */
  172 #endif
  173
  174 #ifdef HAVE_RES_INIT
  175         /* Reload DNS servers from /etc/resolv.conf in case DHCP has updated it.
  176          * We only need to do this occasionally, but it's not expensive
  177          * and simpler to do it every time than it is to figure out when
  178          * to do it.
  179          * This res_init() covers NTS too.
  180          */
  181         res_init();
  182 #endif
  183
  184         if (pp->cfg.flags & FLAG_NTS) {
  185 #ifndef DISABLE_NTS
  186                 nts_probe(pp);
  187 #endif
  188         } else {
  189                 ZERO(hints);
  190                 hints.ai_protocol = IPPROTO_UDP;
  191                 hints.ai_socktype = SOCK_DGRAM;
  192                 hints.ai_family = AF(&pp->srcadr);
  193                 gai_rc = getaddrinfo(pp->hostname, NTP_PORTA, &hints, &answer);
  194         }

  $ /usr/lib/uclibc-ng-test/test/inet/tst-res
  Segmentation fault (core dumped)

  $ ./host/bin/aarch64-buildroot-linux-uclibc-gdb ./build/uclibc-ng-test-0844445e7358eb10e716155b55b0fb23e88d644a/test/inet/tst-res core
  Core was generated by `/usr/lib/uclibc-ng-test/test/inet/tst-res'.
  Program terminated with signal SIGSEGV, Segmentation fault.
  (gdb) where
  #0  __GI___res_init () at libc/inet/resolv.c:3514
  #1  0x0000005591e507e4 in main (argc=<optimized out>, argv=<optimized out>)
      at tst-res.c:20

First reported here:
https://lore.kernel.org/buildroot/20211028230131.5f50d6e7@gmx.net/
https://www.mail-archive.com/[email protected]/msg01085.html

Signed-off-by: Peter Seiderer <[email protected]>
3 years agobump version for 1.0.39 release
Waldemar Brodkorb [Wed, 6 Oct 2021 19:50:49 +0000 (21:50 +0200)]
bump version for 1.0.39 release

3 years agoFix warnings due to missing attributes for __EI_ prefixed symbols
Yann Sionneau [Tue, 17 Aug 2021 20:09:53 +0000 (22:09 +0200)]
Fix warnings due to missing attributes for __EI_ prefixed symbols

With new compiler (gcc >= 9 ?) building uClibc-ng now gives this sort of warnings:

./include/libc-symbols.h:426:25: warning: '__EI_localeconv' specifies less restrictive attribute than its target 'localeconv': 'nothrow' [-Wmissing-attributes]
  426 |  extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local))))
      |                         ^~~~~
./include/libc-symbols.h:429:29: note: in expansion of macro '__hidden_ver1'
  429 | #  define hidden_def(name)  __hidden_ver1(__GI_##name, name, name);
      |                             ^~~~~~~~~~~~~
./include/libc-symbols.h:497:32: note: in expansion of macro 'hidden_def'
  497 | # define libc_hidden_def(name) hidden_def (name)
      |                                ^~~~~~~~~~
libc/misc/locale/locale.c:306:1: note: in expansion of macro 'libc_hidden_def'
  306 | libc_hidden_def(localeconv)
      | ^~~~~~~~~~~~~~~
In file included from libc/misc/locale/localeconv.c:8:
libc/misc/locale/locale.c:261:15: note: '__EI_localeconv' target declared here
  261 | struct lconv *localeconv(void)
      |               ^~~~~~~~~~

The fix is mostly being backported/adapted from glibc.

3 years agoMerge remote-tracking branch 'evolvis/dns-things'
Waldemar Brodkorb [Wed, 25 Aug 2021 12:12:15 +0000 (14:12 +0200)]
Merge remote-tracking branch 'evolvis/dns-things'

3 years agolibc/inet/resolv.c: add __hnbad to check DNS entries for validity…
mirabilos [Mon, 9 Aug 2021 01:37:31 +0000 (03:37 +0200)]
libc/inet/resolv.c: add __hnbad to check DNS entries for validity…

… using the same rules glibc does

also call __hnbad in some places to check answers

3 years agomake __{en,de}code_dotted into macros
mirabilos [Mon, 9 Aug 2021 01:36:58 +0000 (03:36 +0200)]
make __{en,de}code_dotted into macros

they merely call dn_{comp,expand} slightly rearranging the arguments

Signed-off-by: mirabilos <[email protected]>
3 years agoactually remove the ifdeffed-out code from the previous commit
mirabilos [Mon, 9 Aug 2021 01:33:00 +0000 (03:33 +0200)]
actually remove the ifdeffed-out code from the previous commit

Signed-off-by: mirabilos <[email protected]>
3 years agolibc/inet/resolv.c: use dn_{comp,expand} for __{en,de}code_dotted
mirabilos [Mon, 9 Aug 2021 01:30:47 +0000 (03:30 +0200)]
libc/inet/resolv.c: use dn_{comp,expand} for __{en,de}code_dotted

Minimal-invasive change: just ifdeffing away the older code.

There is no reason to have two different sets of functions doing
the same thing, one used in half the code and another, doing less
escaping, in the other half; just use one.

Signed-off-by: mirabilos <[email protected]>
3 years agopowerpc: fix PIE/PIC builds with newer gcc/binutils which use secureplt by default
Yann Sionneau [Thu, 3 Jun 2021 05:40:39 +0000 (07:40 +0200)]
powerpc: fix PIE/PIC builds with newer gcc/binutils which use secureplt by default

This patch fixes segfault of all user space processes (including init, which caused a panic) on recent buildroot powerpc32 builds.

The issue has been reported by Romain Naour in this thread: https://mailman.uclibc-ng.org/pipermail/devel/2021-May/002068.html

Recent buildroot toolchain enables secure PLT in powerpc gcc.
The latter will then supply -msecure-plt to gas invocations by default.
Recent buildroot also enables PIE by defaults.

For the secure PLT to work in PIC, the r30 register needs to point to the GOT.
Old "bss plt" was just a one-instruction-wide PLT slot, pointed-to by a R_PPC_JMP_SLOT relocation, which was written on-the-fly to contain a branch instruction to the correct address. It therefore had to stay writable.
New secure PLT only contains read-only code which loads the branch address from the writable GOT.

Note: secure PLT without PIC does not need r30 to be set. Because offset between plt stub code and got is known at link-time. In this case the PLT entry looks like:
1009b3e0 <__uClibc_main@plt>:
1009b3e0:       3d 60 10 0e     lis     r11,4110
1009b3e4:       81 6b 03 74     lwz     r11,884(r11)
1009b3e8:       7d 69 03 a6     mtctr   r11
1009b3ec:       4e 80 04 20     bctr

Whereas secure PLT with PIC - offset between plt and got is unknown at link-time - looks like this:
000af800 <00000000.plt_pic32.__uClibc_main>:
   af800:       81 7e 03 80     lwz     r11,896(r30)
   af804:       7d 69 03 a6     mtctr   r11
   af808:       4e 80 04 20     bctr
   af80c:       60 00 00 00     nop

Signed-off-by: Yann Sionneau <[email protected]>
3 years agoinclude/sys/personality.h: resync with glibc
Thomas Petazzoni [Fri, 23 Apr 2021 20:55:17 +0000 (22:55 +0200)]
include/sys/personality.h: resync with glibc

The trigger for this resync was ADDR_NO_RANDOMIZE, which was not
defined in uClibc-ng, but is used for example by the uftrace project.

Signed-off-by: Thomas Petazzoni <[email protected]>
3 years agolibpthread/nptl: create timer thread with sufficiant stack size (account for TLS)
Peter Seiderer [Fri, 16 Apr 2021 21:12:51 +0000 (23:12 +0200)]
libpthread/nptl: create timer thread with sufficiant stack size (account for TLS)

Create timer thread with sufficiant stack size (take into account
allocated space for thread-local-storage), for this backport glibc
commit 'Create internal threads with sufficient stack size' ([1],
[2]) introducing __pthread_get_minstack() and use it in
__start_helper_thread().

Fixes timer_create() in case of linking with library using large
TLS area (e.g openblas, see [3]).

[1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=2c1094bd700e63a8d7f547b3f5495bedb55c0a08
[2] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=630f4cc3aa019ede55976ea561f1a7af2f068639
[3] http://lists.busybox.net/pipermail/buildroot/2021-April/308281.html

Signed-off-by: Peter Seiderer <[email protected]>
3 years agoopen: Add support for O_TMPFILE
Nicolas Cavallari [Wed, 7 Apr 2021 17:08:23 +0000 (19:08 +0200)]
open: Add support for O_TMPFILE

Since Linux 3.11, O_TMPFILE allows to create unnamed files that can be
linked later on.  It is internally defined as (O_TMPFILE | O_DIRECTORY)
to make it fail on old kernels.

Copying definitions from glibc for O_TMPFILE is not enough to support
O_TMPFILE; The open() wrapper also need to pass the mode when the flag
contains O_TMPFILE, otherwise, it will pass mode 000 which will succeed
but yield unexpected results.

openat() is curiously not affected since it passes the mode
unconditionally..

Signed-off-by: Nicolas Cavallari <[email protected]>
3 years agobump version for 1.0.38 release
Waldemar Brodkorb [Sat, 27 Mar 2021 14:56:52 +0000 (15:56 +0100)]
bump version for 1.0.38 release

3 years agofcntl.h: Make F_DUPFD_CLOEXEC if _USE_XOPEN2K8
Paul Cercueil [Thu, 18 Feb 2021 22:23:19 +0000 (22:23 +0000)]
fcntl.h: Make F_DUPFD_CLOEXEC if _USE_XOPEN2K8

The F_DUPFD_CLOEXEC flag was added in POSIX 2008.09.

Signed-off-by: Paul Cercueil <[email protected]>
3 years agostring.h: Make strdup() available if _USE_XOPEN2K8
Paul Cercueil [Thu, 18 Feb 2021 22:23:18 +0000 (22:23 +0000)]
string.h: Make strdup() available if _USE_XOPEN2K8

The strdup() function is present in POSIX 2008.09.

Signed-off-by: Paul Cercueil <[email protected]>
3 years agoriscv64: sync ldso relocations with or1k, fixes 5 testsuite errors
Waldemar Brodkorb [Mon, 8 Feb 2021 15:12:15 +0000 (16:12 +0100)]
riscv64: sync ldso relocations with or1k, fixes 5 testsuite errors

3 years agouse renameat2 syscall, when renameat isn't available
Waldemar Brodkorb [Thu, 28 Jan 2021 03:10:42 +0000 (04:10 +0100)]
use renameat2 syscall, when renameat isn't available

3 years agofix umount2 compilation for alpha on Linux 5.x
Waldemar Brodkorb [Wed, 27 Jan 2021 06:06:01 +0000 (07:06 +0100)]
fix umount2 compilation for alpha on Linux 5.x

3 years agosh: Add 64-bit time types from kernel
Geoffrey Le Gourriérec [Tue, 26 Jan 2021 21:54:57 +0000 (22:54 +0100)]
sh: Add 64-bit time types from kernel

Building uclibc 1.0.37 for SuperH architecture with linux-headers 5.10.7
fails at libpthread level due to missing time-related data structures,
usually defined by the kernel.

Define those missing data structures in SuperH-specific kernel_types.h.

Context: building for sh4eb-r2d[1] and sh4-r2d[1] boards emulations for
QEMU using the buildroot image generation tool.

Regarding the issue, a patch[3] was already issued in the kernel some
time ago, which aimed to solve precisely this problem. After coming up
with a quick and dirty patch for buildroot modifying Linux headers[4],
some discussion was sparked on the subject with Linux folks[5]. Some
analyzing later, conclusion was that:
1) Previously mentioned patch[4] was fixing the symptom, not the ill
2) SuperH-specific code in uclibc could be patched instead, to solve
   the problem for other use cases (e.g. building just a toolchain)

[1] https://git.buildroot.net/buildroot/tree/configs/qemu_sh4eb_r2d_defconfig?h=2020.02.9
[2] https://git.buildroot.net/buildroot/tree/configs/qemu_sh4_r2d_defconfig?h=2020.02.9
[3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc94cf2092c7c1267fa2deb8388d624f50eba808
[4] https://git.buildroot.net/buildroot/commit/?id=742f37de8d0e3797698411dfc6a63bd7e98aafe2
[5] https://patchwork.kernel.org/project/linux-sh/patch/20210123165652[email protected]/

Signed-off-by: Geoffrey Le Gourriérec <[email protected]>
4 years agoextra/locale: fix gen_wc8bit diagnostic output
Max Filippov [Thu, 7 Jan 2021 08:45:30 +0000 (00:45 -0800)]
extra/locale: fix gen_wc8bit diagnostic output

Diagnostic for missing UTF locale is printed to stdout instead of
stderr, fix that.

Signed-off-by: Max Filippov <[email protected]>
4 years agobump to 1.0.37
Waldemar Brodkorb [Thu, 24 Dec 2020 10:55:14 +0000 (11:55 +0100)]
bump to 1.0.37

4 years agoGNU hash style support disable for MIPS
Waldemar Brodkorb [Thu, 24 Dec 2020 10:54:53 +0000 (11:54 +0100)]
GNU hash style support disable for MIPS

4 years agostdlib: fix potential UB and integer overflow with huge allocations using malloc...
Yann Sionneau [Sun, 20 Dec 2020 18:15:14 +0000 (19:15 +0100)]
stdlib: fix potential UB and integer overflow with huge allocations using malloc-simple allocator

Two things are fixed by this commit:

1/ It is wrong to allocate an object of size > PTRDIFF_MAX.
It is explained in this thread: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63303

2/ There was a possible integer overflow in both malloc() and memalign() implementations
of stdlib/malloc-simple.
The malloc() integer overflow issue is fixed by the side effect of fixing the PTRDIFF_MAX issue.
The memalign() one is fixed by adding a comparison.

Signed-off-by: Yann Sionneau <[email protected]>
4 years agolibcrypt: add missing errno.h header
Yann Sionneau [Mon, 23 Nov 2020 13:01:45 +0000 (14:01 +0100)]
libcrypt: add missing errno.h header

Fixes:
libcrypt/crypt.c:29:15: error: 'EINVAL' undeclared (first use in this function)
   __set_errno(EINVAL);
               ^~~~~~

Signed-off-by: Yann Sionneau <[email protected]>
4 years agolibcrypt: set_errno to something valid
Waldemar Brodkorb [Fri, 13 Nov 2020 03:21:04 +0000 (04:21 +0100)]
libcrypt: set_errno to something valid

4 years agohasmntopt: better option matching
Yann Sionneau [Mon, 19 Oct 2020 06:09:54 +0000 (08:09 +0200)]
hasmntopt: better option matching

Previous implementation was respecting the man page description
of what the function should do.
Also the function does not seem to be defined by POSIX.

But... to be really useful the function needs to handle
option matching and not just substring matching.

This is copy pasted from glibc.

This fixes issue reported by https://github.com/wbx-github/uclibc-ng/issues/8
that can happen for instance there: https://github.com/frida/glib/blob/master/gio/gunixmounts.c#L622

Signed-off-by: Yann Sionneau <[email protected]>
4 years agobump version to 1.0.36
Waldemar Brodkorb [Fri, 2 Oct 2020 17:11:36 +0000 (19:11 +0200)]
bump version to 1.0.36

4 years agokvx: add support for kvx arch to uClibc-ng
Yann Sionneau [Fri, 2 Oct 2020 14:24:55 +0000 (16:24 +0200)]
kvx: add support for kvx arch to uClibc-ng

This commit adds support for Kalray VLIW family (kvx)

Kalray kv3 core is embedded in Kalray Coolidge SoC. This core which is the
third of the KV family has the following features:

    32/64 bits execution mode
    6-issue VLIW architecture
    64 x 64bits general purpose registers
    SIMD instructions
    little-endian

In order to build a usable toolchain, build scripts are provided at the
following address: https://github.com/kalray/build-scripts.

Kalray uses FOSS which is available at https://github.com/kalray
This includes Linux kernel, uClibc-ng, gcc, binutils, etc.

Signed-off-by: Clément Léger <[email protected]>
Signed-off-by: Guillaume Thouvenin <[email protected]>
Signed-off-by: Laurent Thevenoux <[email protected]>
Signed-off-by: Marc Poulhies <[email protected]>
Signed-off-by: Marius Gligor <[email protected]>
Signed-off-by: Yann Sionneau <[email protected]>
4 years agoFix warning due to unused label in NPTL
Yann Sionneau [Tue, 22 Sep 2020 12:17:03 +0000 (14:17 +0200)]
Fix warning due to unused label in NPTL

Fixes this:

In file included from libpthread/nptl/pthread_create.c:48:0:
libpthread/nptl/allocatestack.c: In function 'allocate_stack':
libpthread/nptl/allocatestack.c:602:6: warning: label 'mprot_error' defined but not used [-Wunused-label]
      mprot_error:
      ^~~~~~~~~~~

Signed-off-by: Yann Sionneau <[email protected]>
4 years agoFix warning due to relaxed function declaration prototype
Yann Sionneau [Tue, 22 Sep 2020 12:17:02 +0000 (14:17 +0200)]
Fix warning due to relaxed function declaration prototype

Fixes this:

libintl/libintl.c:81:13: warning: function declaration isn't a prototype [-Wstrict-prototypes]
 const char *_nl_expand_alias () { return NULL; }
             ^~~~~~~~~~~~~~~~

Signed-off-by: Yann Sionneau <[email protected]>
4 years agoFix warning due to unused variable in strlen
Yann Sionneau [Tue, 22 Sep 2020 12:17:01 +0000 (14:17 +0200)]
Fix warning due to unused variable in strlen

Fixes this:

libc/string/generic/strlen.c: In function 'strlen':
libc/string/generic/strlen.c:31:31: warning: variable 'magic_bits' set but not used [-Wunused-but-set-variable]
   unsigned long int longword, magic_bits, himagic, lomagic;
                               ^~~~~~~~~~

Signed-off-by: Yann Sionneau <[email protected]>
4 years agoFix warning about macro redefinition
Yann Sionneau [Tue, 22 Sep 2020 12:17:00 +0000 (14:17 +0200)]
Fix warning about macro redefinition

Fixes this:

libc/misc/internals/tempname.c: In function 'brain_damaged_fillrand':
libc/misc/internals/tempname.c:155:0: warning: "L" redefined
 #define L ((UINT32_MAX % NUM_LETTERS + 1) % NUM_LETTERS)

In file included from ./libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.h:24:0,
                 from ./include/bits/libc-lock.h:35,
                 from ./include/bits/stdio-lock.h:22,
                 from ./include/bits/uClibc_mutex.h:73,
                 from ./include/bits/uClibc_stdio.h:83,
                 from ./include/stdio.h:71,
                 from libc/misc/internals/tempname.c:35:
./libc/sysdeps/linux/kvx/sysdep.h:40:0: note: this is the location of the previous definition
 #  define L(name) $L##name

Signed-off-by: Yann Sionneau <[email protected]>
4 years agoFix warning about missing const qualifier
Yann Sionneau [Tue, 22 Sep 2020 12:16:59 +0000 (14:16 +0200)]
Fix warning about missing const qualifier

Fixes this:

In file included from libc/misc/fnmatch/fnmatch.c:235:0:
libc/misc/fnmatch/fnmatch_loop.c: In function 'internal_fnmatch':
libc/misc/fnmatch/fnmatch_loop.c:207:21: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      CHAR *p_init = p;
                     ^
libc/misc/fnmatch/fnmatch_loop.c:208:21: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      CHAR *n_init = n;

Signed-off-by: Yann Sionneau <[email protected]>
4 years agoFix unused variable warning in dl-startup.c
Yann Sionneau [Tue, 22 Sep 2020 12:16:58 +0000 (14:16 +0200)]
Fix unused variable warning in dl-startup.c

SEND_STDERR_DEBUG does nothing if __SUPPORT_LD_DEBUG_EARLY__ is not defined
thus causing a warning.

Fixes this:

In file included from ldso/ldso/ldso.c:86:0:
ldso/ldso/dl-startup.c: In function '_dl_start':
ldso/ldso/dl-startup.c:313:13: warning: variable 'strtab' set but not used [-Wunused-but-set-variable]
       char *strtab;
             ^~~~~~

Signed-off-by: Yann Sionneau <[email protected]>
4 years agoSupport b64_ntop(), b64_pton() (bsd-compat)
Waldemar Brodkorb [Mon, 21 Sep 2020 11:39:06 +0000 (13:39 +0200)]
Support b64_ntop(), b64_pton() (bsd-compat)

Signed-off-by: akater <[email protected]>
4 years agoFix memory corruption due to struct stat field
Yann Sionneau [Tue, 15 Sep 2020 12:45:24 +0000 (14:45 +0200)]
Fix memory corruption due to struct stat field

Kernel stat/stat64 structure and uClibc-ng ones were not
in sync regarding the timespec fields.
Kernel had them but uClibc did not expose it in some cases.

Man page says that stat struct should have timespec fields if:
* _POSIX_C_SOURCE is defined to 200809L or greater
or
* _XOPEN_SOURCE is defined to 700 or greater
or
* _BSD_SOURCE is defined
or
* _SVID_SOURCE is defined

In the case of buildroot vim build, neither _BSD_SOURCE nor _SVID_SOURCE were defined.
Only _POSIX_C_SOURCE and _XOPEN_SOURCE were defined.

uClibc-ng header only checked for _BSD_SOURCE and _SVID_SOURCE via __USE_MISC.

This patch adds a check to __USE_XOPEN2K8 which is defined
if _POSIX_C_SOURCE >= 200809L or _XOPEN_SOURCE >= 700

This for instance fixes a crash at startup of vim (not the busybox one) on aarch64 and all other
arch where in kernel STAT_HAVE_NSEC is set and where stat.h in uClibc-ng comes from libc/sysdeps/linux/common-generic/bits

Signed-off-by: Yann Sionneau <[email protected]>
4 years agolibrt: avoid compilation error
Damien Le Moal [Wed, 9 Sep 2020 07:18:04 +0000 (16:18 +0900)]
librt: avoid compilation error

For NOMMU builds, LIBC_CANCEL_ASYNC and LIBC_CANCEL_RESET are not
defined. Prevent these macros from being visible by the compiler in
clock_nanosleep() by replacing "if (SINGLE_THREAD_P) {" with the
pre-compiler directive "#if defined(SINGLE_THREAD_P)".

Signed-off-by: Damien Le Moal <[email protected]>
4 years agoutils/getconf: Fix compilation error
Damien Le Moal [Wed, 9 Sep 2020 07:18:03 +0000 (16:18 +0900)]
utils/getconf: Fix compilation error

In the main() function, all cases of the "switch (specs[i].num)"
switch-case are all conditionally defined. Depending on the target
environementi, none of them may endup being defined, resulting in the
code block before the no-op default case to generate a
"warning: statement will never be executed" compilation error.

Avoid this by conditionally defining this code block with the macro
DO_GETCONF_NAME which is itself defined if any of the switc cases is
defined too.

Signed-off-by: Damien Le Moal <[email protected]>
4 years agoadd MAX_HANDLE_SZ
Waldemar Brodkorb [Wed, 9 Sep 2020 12:37:31 +0000 (14:37 +0200)]
add MAX_HANDLE_SZ

4 years agofix static builds with gcc 10.x
Waldemar Brodkorb [Thu, 3 Sep 2020 13:08:24 +0000 (15:08 +0200)]
fix static builds with gcc 10.x

4 years agoRevert "Fix static linking with GCC-10"
Waldemar Brodkorb [Wed, 2 Sep 2020 07:45:17 +0000 (09:45 +0200)]
Revert "Fix static linking with GCC-10"

This reverts commit 5b58a1ebd89a4f05778441814e81817c82193fa3.

This breaks all static builds earlier to gcc 10 :(
Bad testing on my side.

This page took 0.086441 seconds and 4 git commands to generate.