Commit Graph

873 Commits

Author SHA1 Message Date
Szabolcs Nagy
47bc7f0afe elf.h: add NT_ARM_PAC{A,G}_KEYS from linux v5.1
to request or change pointer auth keys for criu via ptrace, new in

  linux commit d0a060be573bfbf8753a15dca35497db5e968bb0
  arm64: add ptrace regsets for ptrauth key management
2019-07-01 14:16:49 -04:00
Szabolcs Nagy
eea841e653 netinet/in.h: add INADDR_ALLSNOOPERS_GROUP from linux v5.1
RFC 4286: "The IPv4 multicast address for All-Snoopers is 224.0.0.106."
from

  linux commit 4effd28c1245303dce7fd290c501ac2c11052114
  bridge: join all-snoopers multicast address
2019-07-01 14:16:41 -04:00
Szabolcs Nagy
5b2b682ddc sys/socket.h: add SO_BINDTOIFINDEX from linux v5.1
SO_BINDTOIFINDEX behaves similar to SO_BINDTODEVICE, but takes a
network interface index as argument, rather than the network
interface name. see

  linux commit f5dd3d0c9638a9d9a02b5964c4ad636f06cf7e2c
  net: introduce SO_BINDTOIFINDEX sockopt
2019-07-01 14:12:36 -04:00
Szabolcs Nagy
93b5f6c843 netinet/in.h: add IPV6_ROUTER_ALERT_ISOLATE from linux v5.1
restricts router alert packets received by the socket to the
socket's namespace only. see

  linux commit 9036b2fe092a107856edd1a3bad48b83f2b45000
  net: ipv6: add socket option IPV6_ROUTER_ALERT_ISOLATE
2019-07-01 14:12:14 -04:00
Szabolcs Nagy
c7081edcf8 sys/prctl.h: add PR_SPEC_DISABLE_NOEXEC from linux v5.1
allows specifying that the speculative store bypass disable bit should
be cleared on exec. see

  linux commit 71368af9027f18fe5d1c6f372cfdff7e4bde8b48
  x86/speculation: Add PR_SPEC_DISABLE_NOEXEC
2019-07-01 14:12:06 -04:00
Szabolcs Nagy
9e8dd1c7f1 fcntl.h: add F_SEAL_FUTURE_WRITE from linux v5.1
needed for android so it can migrate from its ashmem to memfd.
allows making the memfd readonly for future users while keeping
a writable mmap of it. see

  linux commit ab3948f58ff841e51feb845720624665ef5b7ef3
  mm/memfd: add an F_SEAL_FUTURE_WRITE seal to memfd
2019-07-01 14:11:56 -04:00
Szabolcs Nagy
f67b3c1799 sys/fanotify.h: update for linux v5.1
includes changes from linux v5.1

  linux commit 235328d1fa4251c6dcb32351219bb553a58838d2
  fanotify: add support for create/attrib/move/delete events

  linux commit 5e469c830fdb5a1ebaa69b375b87f583326fd296
  fanotify: copy event fid info to user

  linux commit e9e0c8903009477b630e37a8b6364b26a00720da
  fanotify: encode file identifier for FAN_REPORT_FID

as well as earlier changes that were missed.

sys/statfs.h is included for fsid_t.
2019-07-01 14:11:42 -04:00
Rich Felker
a31a30a007 remove implicit include of sys/sysmacros.h from sys/types.h
this reverts commit f552c792c7, which
exposed the sysmacros.h macros (device major/minor calculations) for
BSD and GNU profiles to mimic an unintentional glibc behavior some
code depended on. glibc has deprecated and since removed them as the
resolution to bug #19239, so it makes no sense for us to keep this
behavior. affected code should all have been fixed by now, and if it's
not yet fixed it needs to be for use with modern glibc anyway.
2019-06-21 15:49:38 -04:00
Rich Felker
0a48860c27 add riscv64 architecture support
Author: Alex Suykov <alex.suykov@gmail.com>
Author: Aric Belsito <lluixhi@gmail.com>
Author: Drew DeVault <sir@cmpwn.com>
Author: Michael Clark <mjc@sifive.com>
Author: Michael Forney <mforney@mforney.org>
Author: Stefan O'Rear <sorear2@gmail.com>

This port has involved the work of many people over several years. I
have tried to ensure that everyone with substantial contributions has
been credited above; if any omissions are found they will be noted
later in an update to the authors/contributors list in the COPYRIGHT
file.

The version committed here comes from the riscv/riscv-musl repo's
commit 3fe7e2c75df78eef42dcdc352a55757729f451e2, with minor changes by
me for issues found during final review:

- a_ll/a_sc atomics are removed (according to the ISA spec, lr/sc
  are not safe to use in separate inline asm fragments)

- a_cas[_p] is fixed to be a memory barrier

- the call from the _start assembly into the C part of crt1/ldso is
  changed to allow for the possibility that the linker does not place
  them nearby each other.

- DTP_OFFSET is defined correctly so that local-dynamic TLS works

- reloc.h LDSO_ARCH logic is simplified and made explicit.

- unused, non-functional crti/n asm files are removed.

- an empty .sdata section is added to crt1 so that the
  __global_pointer reference is resolvable.

- indentation style errors in some asm files are fixed.
2019-06-14 17:13:05 -04:00
Szabolcs Nagy
e980ca7a57 define FP_FAST_FMA* when fma* can be inlined
FP_FAST_FMA can be defined if "the fma function generally executes about
as fast as, or faster than, a multiply and an add of double operands",
which can only be true if the fma call is inlined as an instruction.

gcc sets __FP_FAST_FMA if __builtin_fma is inlined as an instruction,
but that does not mean an fma call will be inlined (e.g. it is defined
with -fno-builtin-fma), other compilers (clang) don't even have such
macro, but this is the closest we can get.

(even if the libc fma implementation is a single instruction, the extern
call overhead is already too big when the macro is used to decide between
x*y+z and fma(x,y,z) so it cannot be based on libc only, defining the
macro unconditionally on targets which have fma in the base isa is also
incorrect: the compiler might not inline fma anyway.)

this solution works with gcc unless fma inlining is explicitly turned off.
2019-04-17 13:02:47 -04:00
A. Wilcox
65c8be3804 fcntl.h: define O_TTY_INIT to 0
POSIX: "[If] either O_TTY_INIT is set in oflag or O_TTY_INIT has the
value zero, open() shall set any non-standard termios structure
terminal parameters to a state that provides conforming behavior."

The Linux kernel tty drivers always perform initialisation on their
devices to set known good termios values during the open(2) call.  This
means that setting O_TTY_INIT to zero is conforming.
2019-04-10 20:37:04 -04:00
Bobby Bingham
e8e780af98 fix signature of function accepted by makecontext
This parameter was incorrectly declared to be a pointer to a function
accepting zero parameters.  The intent of makecontext is that it is
possible to pass integer parameters to the function, so this should
have been a pointer to a function accepting an unspecified set of
parameters.
2019-04-05 17:29:00 -04:00
Szabolcs Nagy
cff993cf32 sys/prctl.h: add PR_PAC_RESET_KEYS from linux v5.0
aarch64 pointer authentication code related prctl that allows
reinitializing the key for the thread, added in linux commit
ba830885656414101b2f8ca88786524d4bb5e8c1
2019-03-13 12:34:56 -04:00
Szabolcs Nagy
843e453c11 elf.h: add NT_ definitions from linux v5.0
NT_MIPS_MSA for ptrace access to mips simd arch reg set, added in linux
commit 3cd640832894b85b5929d5bda74505452c800421
NT_ARM_PAC_MASK for ptrace access to pointer auth code mask, added in
commit ec6e822d1a22d0eef1d1fa260dff751dba9a4258
2019-03-13 12:34:08 -04:00
Szabolcs Nagy
02f769b20d elf.h: update with C-SKY definitions
C-SKY support was added to binutils 2.32 in commit
b8891f8d622a31306062065813fc278d8a94fe21
the elf.h change was added to glibc 2.29 in commit
4975f0c3d0131fdf697be0b1631c265e5fd39088
2019-03-13 12:34:03 -04:00
Szabolcs Nagy
9e06514e23 netinet/tcp.h: add TCP_NLA_SRTT from linux v5.0
smoothed RTT for SCM_TIMESTAMPING_OPT_STATS control messages.
added in linux commit e8bd8fca6773ef49390269bd467bf940a0841ccf
2019-03-13 12:33:54 -04:00
Szabolcs Nagy
292bda7ceb netinet/udp.h: add UDP_GRO from linux v5.0
sockopt to enable gro for udp.
added in linux commit e20cf8d3f1f763ad28a9cb3b41305b8a8a42653e
2019-03-13 12:33:51 -04:00
Szabolcs Nagy
13c73da72f sys/prctl.h: add PR_SPEC_INDIRECT_BRANCH from linux v4.20
prctls to allow per task control of indirect branch speculation on x86.

added in linux commit 9137bb27e60e554dab694eafa4cca241fa3a694f
2019-03-13 12:33:04 -04:00
Szabolcs Nagy
0b026bbd69 netinet/in.h add IPV6_MULTICAST_ALL from linux v4.20
ipv6 analogue of IP_MULTICAST_ALL sockopt.

added in linux commit 15033f0457dca569b284bef0c8d3ad55fb37eacb
2019-03-13 12:32:59 -04:00
Szabolcs Nagy
c6a61df183 add PACKET_IGNORE_OUTGOING sockopt from linux v4.20
new in linux commit fa788d986a3aac5069378ed04697bd06f83d3488
2019-03-13 12:32:19 -04:00
Szabolcs Nagy
db8b53f207 sys/mman.h: add new hugetlb mmap flags from linux v4.19
aarch64 supports 32MB and 512MB hugetlb page sizes too.
added in linux commit 20916d4636a9b3c1bf562b305f91d126771edaf9
2019-03-13 12:32:14 -04:00
Szabolcs Nagy
5640bc5bd5 elf.h: add new mips core dump note values from linux v4.19
NT_MIPS_FP_MODE is new in linux commit
1ae22a0e35636efceab83728ba30b013df761592

NT_MIPS_DSP is new in linux commit
44109c60176ae73924a42a6bef64ef151aba9095
2019-03-13 12:31:13 -04:00
Szabolcs Nagy
3e52f99308 netinet/udp.h: add UDP_ENCAP_RXRPC from linux v4.19
used for optimizing the rxrpc protocol
added in linux commit 5271953cad31b97dea80f848c16e96ad66401199
2019-03-13 12:30:21 -04:00
Szabolcs Nagy
b47723ab3b netinet/tcp.h: add tcp_info fields from linux v4.19
new fields for RFC 4898 tcp stats in linux
tcpi_bytes_sent added in commit ba113c3aa79a7f941ac162d05a3620bdc985c58d
tcpi_bytes_retrans added in commit fb31c9b9f6c85b1bad569ecedbde78d9e37cd87b
tcpi_dsack_dups added in commit 7e10b6554ff2ce7f86d5d3eec3af5db8db482caa
tcpi_reord_seen added in commit 7ec65372ca534217b53fd208500cf7aac223a383

The new fields change the size of a public struct and thus an ABI break,
but this is how the getsockopt TCP_INFO api is designed: the tcp_info
type must only be used with a length parameter in extern interfaces.
2019-03-13 12:30:12 -04:00
Szabolcs Nagy
df4b017bcd sys/inotify.h: add IN_MASK_CREATE from linux v4.19
inotify_add_watch flag to prevent modifying existing watch descriptors,
when used on an already watched inode it fails with EEXIST.
added in linux commit 4d97f7d53da7dc830dbf416a3d2a6778d267ae68
2019-03-13 12:29:27 -04:00
Szabolcs Nagy
31b3efbf3e sys/socket.h: add SO_TXTIME from linux v4.19
added in linux commit 80b14dee2bea128928537d61c333f24cb8cbb62f
2019-03-13 12:29:23 -04:00
Jonathan Neuschäfer
4b125dd408 fix POSIX_FADV_DONTNEED/_NOREUSE on s390x
On s390x, POSIX_FADV_DONTNEED and POSIX_FADV_NOREUSE have different
values than on all other architectures that Linux supports.

Handle this difference by wrapping their definitions in
include/fcntl.h in #ifdef, so that arch/s390x/bits/fcntl.h can
override them.
2019-03-13 11:37:29 -04:00
Rich Felker
81221e13f9 expose TSVTX unconditionally in tar.h
as noted in Austin Group issue #1236, the XSI shading for TSVTX is
misplaced in the html version of the standard; it was only supposed to
be on the description text. the intent was that the definition always
be visible, which is reflected in the pdf version of the standard.

this reverts commits d93c0740d8 and
729fef0a93.
2019-03-13 10:42:57 -04:00
Rich Felker
f368d9fd26 make FILE a complete type for pre-C11 standard profiles
C11 removed the requirement that FILE be a complete type, which was
deemed erroneous, as part of the changes introduced by N1439 regarding
completeness of types (see footnote 6 for specific mention of FILE).
however the current version of POSIX is still based on C99 and
incorporates the old requirement that FILE be a complete type.

expose an arbitrary, useless complete type definition because the
actual object used to represent FILE streams cannot be public/ABI.

thanks to commit 13d1afa46f, we now have
a framework for suppressing the public complete-type definition of FILE
when stdio.h is included internally, so that a different internal
definition can be provided. this is perfectly well-defined, since the
same struct tag can refer to different types in different translation
units. it would be a problem if the implementation were accessing the
application's FILE objects or vice versa, but either would be
undefined behavior.
2019-03-12 15:24:00 -04:00
Rich Felker
ba18c1ecc6 add membarrier syscall wrapper, refactor dynamic tls install to use it
the motivation for this change is twofold. first, it gets the fallback
logic out of the dynamic linker, improving code readability and
organization. second, it provides application code that wants to use
the membarrier syscall, which depends on preregistration of intent
before the process becomes multithreaded unless unbounded latency is
acceptable, with a symbol that, when linked, ensures that this
registration happens.
2019-02-22 03:25:39 -05:00
Bobby Bingham
1dd915c370 update line discipline constants 2019-02-07 12:43:22 -05:00
Bobby Bingham
3517d74a5e move arch-invariant definitions out of bits/ioctl.h 2019-02-07 12:43:19 -05:00
Szabolcs Nagy
1de4788610 add NT_VMCOREDD to elf.h from linux v4.18
used for device driver dump in /proc/vmcore
new in linux commit 2724273e8fd00b512596a77ee063f49b25f36507
2018-12-09 22:30:05 -05:00
Szabolcs Nagy
836022b1c3 add AT_MINSIGSTKSZ to elf.h from linux v4.18
new in linux commit 94b07c1f8c39c6d839df35fa28ffd1785d385897

currently only supported on aarch64
2018-12-09 22:29:44 -05:00
Szabolcs Nagy
ca73bea05d add TRAP_UNK si_code to signal.h from linux v4.18
used for undiagnosed trap exceptions where linux previously set si_code
to 0. new in linux commit db78e6a0a6f9f7d7277965600eeb1a5b3a6f55a8
2018-12-09 22:29:07 -05:00
Szabolcs Nagy
a71276e258 add SIGSYS support to sys/signalfd.h from linux v4.18
new in linux commit 76b7f670730e87974f71df9f6129811e2769666e

in struct signalfd_siginfo the pad member is changed to __pad to keep
the namespace clean, it's not part of the public api.
2018-12-09 22:25:21 -05:00
Szabolcs Nagy
0a9a5c20c7 add AF_XDP to sys/socket.h from linux v4.18
new address family and related macros were added in linux commit
68e8b849b221b37a78a110a0307717d45e3593a0
2018-12-09 22:24:12 -05:00
Szabolcs Nagy
4b9b8c8ee6 update netinet/udp.h for linux v4.18
add UDP_NO_CHECK6_* to restrict zero UDP6 checksums, new in linux commit
1c19448c9ba6545b80ded18488a64a7f3d8e6998 (pre-v4.18 change, was missed)
add UDP_SEGMENT to support generic segmentation offload for udp datagrams,
bec1f6f697362c5bc635dacd7ac8499d0a10a4e7 (new in v4.18)
2018-12-09 22:23:48 -05:00
Szabolcs Nagy
ac1af87e1d update netinet/tcp.h for linux v4.18
add packet delivery info to tcp_info,
new in linux commit feb5f2ec646483fb66f9ad7218b1aad2a93a2a5c
add TCP_ZEROCOPY_RECEIVE socket option for zerocopy receive,
new in linux commit 05255b823a6173525587f29c4e8f1ca33fd7677d
add TCP_INQ socket option and TCP_CM_INQ cmsg to get in-queue bytes in cmsg
upon read, new in linux commit b75eba76d3d72e2374fac999926dafef2997edd2
add TCP_REPAIR_* to fix repair socket window probe patch,
new in linux commit 31048d7aedf31bf0f69c54a662944632f29d82f2
2018-12-09 22:23:30 -05:00
Rich Felker
bf453d6839 restore attribute((const)) to pthread_self and errno location decls
revert commit a603a75a72.

as a result of commit 1c84c99913 this is
now safe, assuming an interpretation of the somewhat-underspecified
attribute((const)) consistent with real-world usage.
2018-10-16 14:10:27 -04:00
Khem Raj
7d7f44253f define MAX_HANDLE_SZ for use with name_to_handle_at
MAX_HANDLE_SZ is described in name_to_handle_at() to contain maximum
expected size for a file handle
2018-09-13 11:46:46 -04:00
Khem Raj
3e14bbcd19 wireup linux/name_to_handle_at and name_to_handle_at syscalls 2018-09-12 21:28:39 -04:00
Rich Felker
fe61a7aa53 rework mechanism for posix_spawnp calling posix_spawn
previously, a common __posix_spawnx backend was used that accepted an
additional argument for the execve variant to call in the child. this
moderately bloated up the posix_spawn function, shuffling arguments
between stack and/or registers to call a 7-argument function from a
6-argument one.

instead, tuck the exec function pointer in an unused part of the
(large) pthread_spawnattr_t structure, and have posix_spawnp duplicate
the attributes and fill in a pointer to __execvpe. the net code size
change is minimal, but the weight is shifted to the "heavier" function
which already pulls in more dependencies.

as a bonus, we get rid of an external symbol (__posix_spawnx) that had
no really good place for a declaration because it shouldn't have
existed to begin with.
2018-09-12 14:34:32 -04:00
Rich Felker
cdbbcfb8f5 fix dubious char signedness check in limits.h
commit 201995f382 introduced a hack
utilizing the signedness of character constants at the preprocessor
level to avoid depending on the gcc-specific __CHAR_UNSIGNED__ predef.
while this trick works on gcc and presumably other compilers being
used, it's not clear that the behavior it depends on is actually
conforming. C11 6.4.4.4 ¶10 defines character constants as having type
int, and 6.10.1 ¶4 defines preprocessor #if arithmetic to take place
in intmax_t or uintmax_t, depending on the signedness of the integer
operand types, and it is specified that "this includes interpreting
character constants".

if character literals had type char and just promoted to int, it would
be clear that when char is unsigned they should behave as uintmax_t at
the preprocessor level. however, as written the text of the standard
seems to require that character constants always behave as intmax_t,
corresponding to int, at the preprocessor level.

since there is a good deal of ambiguity about the correct behavior and
a risk that compilers will disagree or that an interpretation may
mandate a change in the behavior, do not rely on it for defining
CHAR_MIN and CHAR_MAX correctly. instead, use the signedness of the
value (as opposed to the type) of '\xff', which will be positive if
and only if plain char is unsigned. this behavior is clearly
specified, and the specific case '\xff' is even used in an example,
under 6.4.4.4 of the standard.
2018-08-28 13:54:50 -04:00
Rich Felker
184ef36f85 fix FP_ILOGB0 and FP_ILOGBNAN definitions to be valid for use in #if
commit 98c9af5001 wrongly claimed they
do not need to be valid for such usage, but the last sentence of C11
7.1.4 ¶1 imposes a broad requirement that all macros specified as
integer constant expressions also need to be valid for #if.

simply write the value out explicitly. there is no value here in
pretending that the width of int will vary.
2018-08-22 19:11:58 -04:00
Rich Felker
767f7a1091 remove erroneous SYMLINK_MAX definition from limits.h, pathconf
POSIX requires the symlink function to fail with ENAMETOOLONG if the
link contents to be written exceed SYMLINK_MAX in length, but neither
Linux nor our syscall wrapper code enforce this. the value 255 for
SYMLINK_MAX is not meaningful and does not seem to have been motivated
by anything except perhaps a wrong assumption that a definition was
mandatory. it has been present (though moving through bits to
top-level limits.h) since the beginning of the project history.

[f]pathconf is entitled to return -1 as the limit for conf names for
which there is no hard limit, with the usual POSIX note that an
indefinite limit does not imply an infinite limit. in principle we
might should report a limit for filesystems that impose one, but such
functionality is not currently present for any of the pathconf limits,
and adding it is beyond the scope of fixing the incorrect limit.
2018-08-20 20:33:19 -04:00
midipix
f2c6dbe244 move inclusion of linux headers for kd.h, soundcard.h, vt.h to bits
maintainer's note: while musl does not use the linux kernel headers,
it does provide these three sys/* headers which do nothing but include
the corresponding linux/* headers, since the sys/* versions are the
ones documented for application use (and they arguably provide
interfaces that are not linux-specific but common to other unices).
these headers should probably not be provided by libc (rather by a
separate package), but as long as they are, use the bits header
framework as an aid to out-of-tree ports of musl for non-linux systems
that want to implement them in some other way.
2018-07-20 01:06:41 -04:00
midipix
2fab90a71a remove inclusion guard hacks for sys/kd.h
maintainer's note: at some point, probably long before linux separated
the uapi headers, it was the case, or at least I believed it was the
case, that linux/types.h was unsafe to include from userspace. thus,
the inclusion guard macro _LINUX_TYPES_H was defined in sys/kd.h to
prevent linux/kd.h from including linux/types.h (which it spuriously
includes but does not use). as far as I can tell, whatever problem
this was meant to solve does not seem to have been present for a long
time, and the hack was not done correctly anyway, so removing it is
the right thing to do.
2018-07-20 01:06:03 -04:00
Szabolcs Nagy
df6d9450ea add support for arch-specific ptrace command macros
sys/ptrace.h is target specific, use bits/ptrace.h to add target
specific macro definitions.

these macros are kept in the generic sys/ptrace.h even though some
targets don't support them:

PTRACE_GETREGS
PTRACE_SETREGS
PTRACE_GETFPREGS
PTRACE_SETFPREGS
PTRACE_GETFPXREGS
PTRACE_SETFPXREGS

so no macro definition got removed in this patch on any target. only
s390x has a numerically conflicting macro definition (PTRACE_SINGLEBLOCK).

the PT_ aliases follow glibc headers, otherwise the definitions come
from linux uapi headers except ones that are skipped in glibc and
there is no real kernel support (s390x PTRACE_*_AREA) or need special
type definitions (mips PTRACE_*_WATCH_*) or only relevant for linux
2.4 compatibility (PTRACE_OLDSETOPTIONS).
2018-07-17 22:25:08 -04:00
Szabolcs Nagy
7ea32a8282 sys/ptrace.h: add missing PTRACE_EVENT_STOP
new in linux v3.1 commit 3544d72a0e10d0aa1c1bd59ed77a53a59cdc12f7
changed in linux v3.4 commit 5cdf389aee90109e2e3d88085dea4dd5508a3be7

A tracer recieves this event in the waitpid status of a PTRACED_SEIZED
process.
2018-07-17 22:24:15 -04:00