Commit Graph

4916 Commits

Author SHA1 Message Date
Rich Felker
bdc9a9ff6f uio.h: add RWF_NOAPPEND flag for pwritev2
added in linux kernel commit 73fa7547c70b32cc69685f79be31135797734eb6.

this is added now as a prerequisite for fixing pwrite/pwritev behavior
for O_APPEND files.
2024-03-13 10:39:37 -04:00
Rich Felker
7ada6dde6f iconv: fix missing bounds checking for shift_jis decoding
the jis0208 table we use is only 84x94 in size, but the shift_jis
encoding supports a 94x94 grid. attempts to convert sequences outside
of the supported zone resulted in out-of-bounds table reads,
misinterpreting adjacent rodata as part of the character table and
thereby converting these sequences to unexpected characters.
2024-03-02 22:17:49 -05:00
Rich Felker
fd7d018521 add missing inline keyword on default a_barrier definition
this is not needed, but may act as a hint to the compiler, and also
serves to suppress unused function warnings if enabled (on by default
since commit 86ac0f7947).
2024-03-02 12:34:05 -05:00
Rich Felker
b5121e2ed8 iconv: add aliases for GBK
these are taken from the IANA registry, restricted to those that match
the forms already used for other supported character encodings.
2024-03-01 16:04:48 -05:00
Rich Felker
ca6f46aff1 iconv: add euro symbol to GBK as single byte 0x80
this is how it's defined in the cp936 document referenced by the IANA
charset registry as defining GBK, and of the mappings defined there,
was the only one missing.

it is not accepted for GB18030, as GB18030 is a UTF and has its own
unique mapping for the euro symbol.
2024-03-01 15:49:58 -05:00
Rich Felker
0784374d56 release 1.2.5 2024-02-29 21:07:33 -05:00
Rich Felker
f5dba42f36 iconv: add cp932 as an alias for shift_jis 2024-02-29 20:40:03 -05:00
Rich Felker
e5aa498451 update INSTALL file archs list with riscv32, loongarch64 additions 2024-02-29 19:23:03 -05:00
wanghongliang
8d9d266573 loongarch64: add new syscall numbers 2024-02-29 17:33:45 -05:00
Rich Felker
8d852cdacd loongarch64: remove getrlimit/setrlimit syscall numbers
these are not supported by the kernel for new archs; prlimit64
replaces them.
2024-02-29 17:32:27 -05:00
wanghongliang
13cd64af31 loongarch64: remove ptrace.h macros 2024-02-29 17:30:11 -05:00
Stefan O'Rear
377c363fb5 configure: enable riscv32 port 2024-02-29 16:59:06 -05:00
Khem Raj
d25f0cccb9 riscv: define REG_S1 and REG_S2
These are used by applications to access members of mcontext, and are
also defined by other libcs on linux.
2024-02-29 16:36:55 -05:00
Khem Raj
8432d16a46 riscv32: add new syscall numbers
- add mount_setattr from linux v5.12
- add epoll_pwait2 from linux v5.11
- add process_madvise from linux v5.10
- add __NR_faccessat2 from linux v5.8
- add pidfd_getfd and openat2 syscall numbers from linux v5.6
- add clone3 syscall number from linux v5.3
- add process_mrelease from linux v5.15
- add futex_waitv from linux v5.16
- add set_mempolicy_home_node from linux v5.17
- add cachestat from linux v6.4
- add __NR_fchmodat2 from linux v6.6
2024-02-29 16:36:55 -05:00
Rich Felker
3ea3fcf78a riscv32: add sysvipc msg/sem/shm bits
despite riscv32 being natively time64, the IPC_TIME64 bit (0x100) is
set in IPC_STAT and derived command macros, differentiating their
values from the raw command values used to interface with the kernel.
this reflects that the kernel ipc structure types are not natively
time64, but have broken-down hi/lo fields that cannot be used in-place
and require translation, and that the userspace struct types differ
from the kernel types (relevant to things like strace).
2024-02-29 16:36:55 -05:00
Stefan O'Rear
b28c44de8c riscv32: add thread support
Identical to riscv64 except for stack offsets in clone.
2024-02-29 16:36:55 -05:00
Stefan O'Rear
c34a8eedff riscv32: add setjmp/longjmp and sigreturn
Largely copied from riscv64 but required recalculation of offsets.
2024-02-29 16:36:55 -05:00
Stefan O'Rear
11eee89e14 riscv32: add dlsym
Identical to riscv64.
2024-02-29 16:36:55 -05:00
Stefan O'Rear
b4f7b2ca35 riscv32: add fenv and math
These are identical to riscv64.
2024-02-29 16:36:55 -05:00
Stefan O'Rear
01d9fe4d9f riscv32: add arch headers
These are mostly copied from riscv64. _Addr and _Reg had to become int
to match compiler-controlled parts of the ABI (result type of sizeof,
etc.). There is no kernel stat struct; the userspace stat matches
glibc in the sizes and offsets of all fields (including glibc's
__dev_t __pad1). The jump buffer is 12 words larger to account for 12
saved double-precision floats; additionally it should be 64-bit
aligned to save doubles.

The syscall list was significantly revised by deleting all time32 and
pre-statx syscalls, and renaming several syscalls that have different
names depending on __BITS_PER_LONG, notably mmap2 and _llseek.

futex was added as an alias to futex_time64 since it is widely used by
software which does not pass time arguments.
2024-02-29 16:35:30 -05:00
Alexey Izbyshev
5c653ccaa1 getnameinfo: fix calling __dns_parse with potentially too large rlen
__res_send returns the full answer length even if it didn't fit the
buffer, but __dns_parse expects the length of the filled part of the
buffer.

This is analogous to commit 77327ed064,
which fixed the only other __dns_parse call site.
2024-02-29 10:14:16 -05:00
Alexey Izbyshev
d3a61059c0 posix_spawn: fix child spinning on write to a broken pipe
A child process created by posix_spawn reports errors to its parent via
a pipe, retrying infinitely on any write error to prevent falsely
reporting success. If the (original) parent dies before write is
attempted, there is nobody to report to, but the child will remain
stuck in the write loop forever if SIGPIPE is blocked or ignored.
Fix this by not retrying write if it fails with EPIPE.
2024-02-29 10:07:03 -05:00
wanghongliang
80e3b09823 loongarch64 __clone: align stack pointer mod 16
According to LoongArch ABI Specs, stack need to be 16 align to improve
performance and compiler layout of stack frames.
2024-02-26 15:23:01 -05:00
Hongliang Wang
ec325b3828 add loongarch64 user.h structs; adjust elf_fpreg_t and ELF_NFPREG
user_regs_struct and user_fp_struct were missing from the initial
commit of the port.

the union type for elf_fpreg_t and the new value of ELF_NFPREG are
made consistent with glibc.
2024-02-26 15:22:58 -05:00
wanghongliang
f2c9350543 add loongarch64 signal.h register index macros 2024-02-26 15:22:54 -05:00
Rich Felker
a7239cbc1b switch __STDC_UTF_{16,32}__ macro definitions from #undef to #ifndef
originally, compilers did not provide these macros and we had to
provide them ourselves. this meant we were redefining them, which was
technically invalid unless the token sequence of the original
definition matched exactly.

the original patch proposed by Jules Maselbas to fix this made the
definitions conditional on them not already being defined; however I
suggested using #undef to avoid any possibly-wrong definitions already
in place and ensure that the definitions are 1. the version adopted as
commit 8b70486807 made this change.

unfortunately, gcc is loud about not liking #undef of any __STDC_*
macro name, and while warnings are suppressed in the system include
path, there is apparently no way to suppress this warning if the
system include dir has also been provided via -I.

while normally we don't go out of our way to satisfy warnings over
style in the public headers, in this case, it seems to be a matter of
disagreement over contract of which part of "the implementation" is
entitled to define or undefine macros belonging to the implementation,
and it's quite reasonable to conclude that the compiler may reject
attempts to undefine them.

this commit reverts to the originally-submitted version of the patch
making the definitions conditional.
2024-02-26 14:14:08 -05:00
Stefan O'Rear
2c887f24da riscv: fall back to syscall __riscv_flush_icache
Matches glibc behavior and fixes a case where we could fall off the
function without returning a value.
2024-02-25 20:35:24 -05:00
Rich Felker
69670e3bb3 sh dlsym: fix passing of return address for RTLD_NEXT use
this code dates back to the original commit of the sh port, with no
real clue as to how the bug was introduced. it looks like it was
written to assume the return address was pushed to the stack like on
x86, rather than arriving in the pr special register.
2024-02-25 15:10:26 -05:00
Duncan Bellamy
b817541f1c add statx interface using syscall, fallback to fstatat 2024-02-24 12:27:09 -05:00
Gaël PORTAY
d0ed307e6f use new SYS_fchmodat2 syscall to implement fchmodat with flags
commit 0dc4824479 worked around for lack
of flags argument in syscall for fchmodat.

linux 6.6 introduced a new syscall, SYS_fchmodat2, fixing this
deficiency. use it if any flags are passed, and fallback to the old
strategy on ENOSYS. continue using the old syscall when there are no
flags. this is the exact same strategy used when SYS_faccessat2 was used
to implement faccessat with flags.
2024-02-22 19:27:23 -05:00
Gaël PORTAY
3d5c9fe39f bits/syscall.h: add __NR_fchmodat2 from linux v6.6
the linux fchmodat syscall lacks a flag argument that is necessary to
implement the posix api, see

  linux commit 09da082b07bbae1c11d9560c8502800039aebcea
  fs: Add fchmodat2()

  linux commit 78252deb023cf0879256fcfbafe37022c390762b
  arch: Register fchmodat2, usually as syscall 452
2024-02-22 19:24:18 -05:00
Gaël PORTAY
fb9d976cc2 remove flag argument from fchmodat syscall
linux's does not have the flag argument for fchmodat syscall.
2024-02-22 19:24:06 -05:00
Gaël PORTAY
dd690c4909 bits/syscall.h: add cachestat from linux v6.4
see

    linux commit cf264e1329fb0307e044f7675849f9f38b44c11a
    cachestat: implement cachestat syscall

    linux commit 946e697c69ffeeefdd84dad90eac307284df46be
    cachestat: wire up cachestat for other architectures
2024-02-22 19:23:47 -05:00
Gaël PORTAY
33e8c469a9 bits/syscall.h: add set_mempolicy_home_node from linux v5.17
see

    linux commit c6018b4b254971863bd0ad36bb5e7d0fa0f0ddb0
    mm/mempolicy: add set_mempolicy_home_node syscall

    linux commit 21b084fdf2a49ca1634e8e360e9ab6f9ff0dee11
    mm/mempolicy: wire up syscall set_mempolicy_home_node
2024-02-22 19:23:37 -05:00
Gaël PORTAY
b2c4c3d590 bits/syscall.h: add futex_waitv from linux v5.16
see

    linux commit 039c0ec9bb77446d7ada7f55f90af9299b28ca49
    futex,x86: Wire up sys_futex_waitv()

    linux commit ea7c45fde5aa3e761aaddb7902a31a95cb120e7b
    futex,arm: Wire up sys_futex_waitv()

    linux commit b3ff2881ba18b852f79f5476d7631940071f1adb
    MIPS: syscalls: Wire up futex_waitv syscall

    linux commit 6c122360cf2f4c5a856fcbd79b4485b7baec942a
    s390: wire up sys_futex_waitv system call

    linux commit a0eb2da92b715d0c97b96b09979689ea09faefe6
    futex: Wireup futex_waitv syscall
2024-02-22 19:23:13 -05:00
Rich Felker
e975127947 bits/syscall.h: add process_mrelease from linux v5.15
see

    linux commit 884a7e5964e06ed93c7771c0d7cf19c09a8946f1
    mm: introduce process_mrelease system call

    linux commit dce49103962840dd61423d7627748d6c558d58c5
    mm: wire up syscall process_mrelease
2024-02-22 19:23:05 -05:00
Gaël PORTAY
a526314c80 bits/syscall.h: add memfd_secret from linux v5.14
see

    linux commit 7bb7f2ac24a028b20fca466b9633847b289b156a
    arch, mm: wire up memfd_secret system call where relevant

    linux commit 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49
    mm: introduce memfd_secret system call to create "secret" memory areas

    linux commit b633896314c0f78f2b4eb7b19a530d68f2a35445
    tools headers UAPI: Sync s390 syscall table file that wires up the
    memfd_secret syscall
2024-02-22 19:22:38 -05:00
Rich Felker
19563e1850 add framework to support archs without a native wait4 syscall
this commit should make no codegen change for existing archs, but is a
prerequisite for new archs including riscv32. the wait4 emulation
backend provides both cancellable and non-cancellable variants because
waitpid is required to be a cancellation point, but all of our other
uses are not, and most of them cannot be.

based on patch by Stefan O'Rear.
2024-02-22 18:50:34 -05:00
Rich Felker
7020e85fd7 sh: fix sigsetjmp corrupting call-saved register r8
due to incorrect base address register when attempting to reload the
saved value of r8, the caller's value of r8 was not preserved.
2024-02-17 20:36:42 -05:00
Hongliang Wang
522bd54eda add loongarch64 port
Author: Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
Author: Meidan Li <limeidan@loongson.cn>
Author: Guoqi Chen <chenguoqi@loongson.cn>
Author: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Author: Fan peng <fanpeng@loongson.cn>
Author: Jiantao Shan <shanjiantao@loongson.cn>
Author: Xuhui Qiang <qiangxuhui@loongson.cn>
Author: Jingyun Hua <huajingyun@loongson.cn>
Author: Liu xue <liuxue@loongson.cn>
Author: Hongliang Wang <wanghongliang@loongson.cn>
2024-02-16 09:33:10 -05:00
Rich Felker
4a16ddf53e strftime: fix breakage in last change (uninitialized pointer access)
commit f47a5d400b overlooked that
strtoul was responsible for setting p to a const-laundered copy of the
format string pointer f, even in the case where there was no number to
parse. by making the call conditional on isdigit, that copy was lost.

the logic here is a mess and should be cleaned up, but for now, this
seems to be the least invasive change that undoes the breakage.
2024-02-16 09:33:03 -05:00
Rich Felker
cf91e9b393 fix erroneous feature test macro check for ppoll
commit f247462b08 incorrectly hid ppoll
in the presence of _GNU_SOURCE due to an oversight that defining
_BSD_SOURCE does not implicitly define _GNU_SOURCE. at present,
headers still have to explicitly check for each feature profile level;
this may be changed at some point in the future via features.h, but
has not been changed yet.
2024-02-08 21:57:38 -05:00
Rich Felker
39838619bb syslog: use C locale for timestamp generation
depending on contents of the LC_TIME locale, log messages could be
malformatted (especially if the ABMON strings contain non-alphabetic
characters) or the subsequent code could invoke undefined behavior,
via passing a timebuf[] with unspecified contents to snprintf, if
the translated ABMON string did not fit in the 16-byte timebuf.

this does not appear to be a security-relevant bug, as locale loading
functionality is intentionally not available to set*id programs -- the
MUSL_LOCPATH environment variable is ignored when libc.secure is true,
and custom locales are not loadable without it.
2024-02-07 16:08:11 -05:00
Jules Maselbas
8b70486807 stdc-predef.h: prevent redefining __STDC_UTF_{16,32}__ macros
Undefine any previous __STDC_UTF_{16,32}__ macros before defining
them to prenvent any warnings of redefining macros.

This happens as a result of some compiler versions defining the macros
themselves.
2024-02-03 20:04:42 -05:00
Rich Felker
407aea628a riscv: add TLSDESC support 2024-02-03 19:59:26 -05:00
Tim Cuthbertson
2e1bb87af2 install.sh: avoid creating symlinks with restricted permissions
Linux and most systems do not have symlink permissions, but some
systems, including MacOS, do, and creation of the symlink with umask
set to 0777 makes the symlink inaccessible on such systems.

clear umask when making a symlink so that the behavior is uniform.
2024-02-03 19:57:30 -05:00
Rich Felker
0e330722c3 sqrtl: fix invalid use of a non-constant-expression as static initializer
having these constants be static was unnecessary, so just remove the
static.

this error should have been caught by compilers, but recent versions
of both gcc and clang accept these as "other forms of constant
expressions" which the C standard allows.
2024-02-03 19:50:58 -05:00
gns
bd3138b74a riscv: correct symbol version of __vdso_flush_icache
Previously, __riscv_flush_icache would not work correctly as
__vdso_flush_icache had a wrong symbol version. Fix this by correcting
symbol version.

Fixes: 0a48860c27 ("add riscv64 architecture support")
2024-02-03 19:49:42 -05:00
Elliott Hughes
15aa7abd34 elf.h: add NT_RISCV_CSR and NT_RISCV_VECTOR constants
See Linux commit 9300f00439743c4a34d735e1a27118eb68a1504e ("RISC-V: Add
ptrace support for vectors").
2024-02-03 19:48:25 -05:00
Fangrui Song
25c4123629 elf.h: update RISC-V relocation types
Note: Some relocation types were only used by binutils and
accidentally exposed to previous versions of psABI. One of the values
has been reused by GOT32_PCREL.
2024-02-03 19:45:53 -05:00