Commit graph

9419 commits

Author SHA1 Message Date
Jessica Clarke
5d10ed57e6 libc: Fix "harmless" iconv one-byte overread
Checking there are still bytes left must be done before dereferencing
the pointer, not the other way round. This is harmless on traditional
architectures since the result will immediately be thrown away, and all
callers are in separate translation units so there is no potential for
optimising based on this out-of-bounds read. However, on CHERI, pointers
are bounded, and so this will trap if fed a string that does not have a
NUL within the first len bytes.

Found by:	CHERI
Reviewed by:	brooks

(cherry picked from commit 6d5297569e)
2022-01-24 23:59:47 +00:00
Konstantin Belousov
7a6364ac77 kqueue(2): Add note about format of the data for NOTE_EXIT
PR:	261346

(cherry picked from commit 7406ec4ea9)
2022-01-22 02:50:23 +02:00
Ed Maste
423fb85f33 libc: correct SPDX tag on strstr.c
It was obtained from musl, and is MIT licensed.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2e9bc9d144)
2022-01-18 19:32:29 -05:00
Ed Maste
e475c5f6ca libc: fix misleading comment in strstr
Obtained from:	musl c53e9b239418

(cherry picked from commit c6750f07b4)
2022-01-18 19:32:29 -05:00
Konstantin Belousov
07d32ede46 libc clnt_com_create: relock rpcsoc_lock earlier when port is obtained from portmapper
PR:	261051

(cherry picked from commit 6d06bc688e)
2022-01-15 02:51:13 +02:00
Konstantin Belousov
8c709f30a1 sched_get/setaffinity(): try to be more compatible with Linux
(cherry picked from commit d9cacbf4b0)
2022-01-14 18:17:31 +02:00
Stefan Eßer
dc4114875e Make CPU_SET macros compliant with other implementations
(cherry picked from commit e2650af157)
2022-01-14 18:17:30 +02:00
Math Ieu
3f8542d396 sched_get/setaffinity(3): pid 0 should designate current process
PR:	260487

(cherry picked from commit caacda7a3e)
2022-01-14 18:17:30 +02:00
Konstantin Belousov
58865d5f8d sched.h: Hide all Linux compat sched_* functions under _WITH_CPU_SET_T
(cherry picked from commit 90fa9705d5)
2022-01-14 18:17:29 +02:00
Konstantin Belousov
d3e9527a10 x86: provide userspace implementation of sched_getcpu() where possible
(cherry picked from commit f239545591)
2022-01-14 18:17:29 +02:00
Konstantin Belousov
a48d9f1900 Add sched_getcpu()
(cherry picked from commit 77b2c2f814)
2022-01-14 18:17:29 +02:00
Konstantin Belousov
526f94cc0e Add sched_get/setaffinity(3)
(cherry picked from commit 43736b71dd)
2022-01-14 18:17:29 +02:00
Alexander Motin
375fdb6e16 libc: Fix build with -DNS_REREAD_CONF.
MFC after:	3 days

(cherry picked from commit 62ed2d0152)
2021-12-31 19:26:43 -05:00
Ed Maste
c56c2f0fe2 getfh: clarify that it is a privileged operation
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33629

(cherry picked from commit 5bc2e6e227)
2021-12-29 19:27:34 -05:00
Konstantin Belousov
0a50e517cd Document new variant of swapoff(2)
(cherry picked from commit 9f0fea5d03)
2021-12-20 02:29:11 +02:00
Konstantin Belousov
1791debf4a swapoff: add one more variant of the syscall
For MFC, COMPAT_FREEBSD13 braces were removed.

(cherry picked from commit 5346570276)
2021-12-20 02:29:11 +02:00
Konstantin Belousov
0c747a70c8 swapoff(2): document extended syscall arguments
(cherry picked from commit 79d650f262)
2021-12-20 02:29:11 +02:00
Florian Walpen
30c3a5f248 Add idle priority scheduling privilege group to MAC/priority
(cherry picked from commit a9545eede4)
2021-12-19 04:42:51 +02:00
Florian Walpen
984b9d89f8 MAC/priority module for realtime privilege group
PR:	239125

(cherry picked from commit bf2fa8d9d1)
2021-12-19 04:42:51 +02:00
Andrew Turner
c71bfb1013 Revert "Switch to Arm Optimized Routines for mem* & str*"
The Arm Optimized Routines don't exist in 13. I missed this as my
builds succeeded, likely due to stale depends files.

This reverts commit bfd10d146b.
2021-12-14 12:34:09 +00:00
Andrew Turner
bfd10d146b Switch to Arm Optimized Routines for mem* & str*
These are the updated version of the older Cortex Strings Library we
previously used. The Arm Optimized Routines also support CPU features
that are currently in development on FreeBSD, e.g. Branch Target
Identification (BTI). Rather than add BTI support to the old code it's
easier to just use the maintained version.

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32774

(cherry picked from commit 2e8ff4d1d5)
2021-12-14 10:58:01 +00:00
Mark Johnston
a5659943e3 libc: Add pdfork to the list of interposed system calls
Otherwise the asm stub is used and libthr interposition does not work.

Reviewed by:	kib
Fixes:		21f749da82 ("libthr: wrap pdfork(2), same as fork(2).")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cbdec8db18)
2021-12-13 08:26:58 -05:00
Konstantin Belousov
ba6f5ed72e fcntl(2): be more precise about third arg type
(cherry picked from commit 97722455cc)
2021-12-13 02:58:22 +02:00
Konstantin Belousov
9258e9e3a8 fcntl(2): add F_KINFO operation
(cherry picked from commit 794d3e8e63)
2021-12-13 02:58:22 +02:00
Ed Maste
bf4a70bb40 libc: Use musl's optimized strchr and strchrnul
Parentheses added to HASZERO macro to avoid a GCC warning, and formatted
with clang-format as we have adopted these and don't consider them
'contrib' code.

Obtained from:	musl (snapshot at commit 4d0a82170a25)
Reviewed by:	kib (libc integration), mjg (both earlier)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17630

(cherry picked from commit 7f72497ef7)
2021-12-12 17:32:33 -05:00
Mike Karels
1ab4b70db5 res_init: remove unused inet_makeaddr with IN_LOOPBACKNET
Remove code that is ifdefed out on USELOOPBACK, which uses historical
class.  No functional change intended.

(cherry picked from commit 0bf7f99b2a)
2021-12-10 10:26:14 -06:00
Mike Karels
d98a0edb26 man pages: deprecate Internet Class A/B/C
Mark functions inet_netof(), inet_lnaof(), and inet_makeaddr() as
deprecated, as they assume Class A/B/C.  inet_makeaddr() mostly works
when networks are a multiple of 8 bits, but warn for anything other
than historical classes.  Reduce other mentions of network classes.

(cherry picked from commit 12bd931d8c)
2021-12-10 10:25:45 -06:00
Michael Tuexen
4bf3c8ea0d libc sctp: improve conformance of sctp_getpaddrs()
When there is no association, don't return -1 and indicate ENOENT,
but return 0 instead. This is specified in RFC 6458.

PR:		260117
MFC after:	1 week

(cherry picked from commit 83a103ec42)
2021-12-10 11:39:15 +01:00
Michael Tuexen
6a5487e34b libc sctp: fix sctp_getladdrs() when reporting no addresses
Section 9.5 of RFC 6458 (SCTP Socket API) requires that
sctp_getladdrs() returns 0 in case the socket is unbound. This
is the cause of reporting 0 addresses. So don't indicate an
error, just report this case as required.

PR:		260117
MFC after:	1 week

(cherry picked from commit 071966e874)
2021-12-10 11:38:31 +01:00
Michael Tuexen
4749d55fb3 libc sctp: improve error reporting of sctp_getladdrs()
Do not hide errno from getsockopt() called internally.

MFC after:	1 week

(cherry picked from commit 6e9309bd3b)
2021-12-10 11:26:31 +01:00
Michael Tuexen
30e6da1149 libc sctp: fix sctp_getladdrs() for 64-bit BE platforms
When calling getsockopt() with SCTP_GET_LOCAL_ADDR_SIZE, use a
pointer to a 32-bit variable, since this is what the kernel
expects.
While there, do some cleanups.

MFC after:	1 week

(cherry picked from commit dabd8bf914)
2021-12-10 11:25:21 +01:00
Konstantin Belousov
bc663f746e Document posix_spawn_file_actions_addclosefrom_np(3)
(cherry picked from commit 78963d796d)
2021-12-07 02:25:55 +02:00
Konstantin Belousov
54cdfdf12a posix_spawn: add closefrom non-portable action
(cherry picked from commit a18ddf7757)
2021-12-07 02:25:55 +02:00
Konstantin Belousov
ef39284e94 Document posix_spawn_file_actions_addchdir_np(3)
(cherry picked from commit bd44dce5b3)
2021-12-07 02:25:55 +02:00
Konstantin Belousov
c7b624979a posix_spawn: add chdir-related non-portable actions
(cherry picked from commit 25cda42a49)
2021-12-07 02:25:53 +02:00
Konstantin Belousov
4529cb3db2 posix_spawn(3), posix_spawn_file_actions_addopen(3): use .Fo/.Fc
(cherry picked from commit 8ed1e4a5c1)
2021-12-07 02:25:01 +02:00
Konstantin Belousov
94f97c0424 posix_spawn: style, use return ()
(cherry picked from commit b239cc204a)
2021-12-07 02:25:01 +02:00
Konstantin Belousov
198932fd77 posix_spawn.c: format fae_action anon enum more stylish
(cherry picked from commit adbaf1b443)
2021-12-07 02:25:01 +02:00
Konstantin Belousov
f457e04994 citrus_prop.c: do not ignore sign
(cherry picked from commit 181751a8b6)
2021-12-06 02:23:45 +02:00
Konstantin Belousov
c20c7a3122 libc/tests/stdlib/dynthr_mod/dynthr_mod.c: mark dummy as used
(cherry picked from commit a64a3b7988)
2021-12-06 02:23:45 +02:00
Konstantin Belousov
f19aa58ee6 libc/stdio/vfwscanf.c::convert_wstring(): wcp0 is write-only
(cherry picked from commit c8a4a49d58)
2021-12-06 02:23:45 +02:00
Konstantin Belousov
f894975dda libc/x86/__vdso_gettc.c::tsc_selector_idx(): cpu_id is calculated but not used
(cherry picked from commit 4b6f4db341)
2021-12-06 02:23:45 +02:00
Konstantin Belousov
f4669d7064 acl_delete_entry(): remove write-only variable
(cherry picked from commit 959c7ab51e)
2021-12-06 02:23:45 +02:00
Konstantin Belousov
065166c76a setproctitle_internal(): remove kbuf local, it is write-only
(cherry picked from commit 412fd7a34c)
2021-12-06 02:23:45 +02:00
Konstantin Belousov
5298739f2d libc/rpc/getrpcent.c: Mark write-only variables as unused
(cherry picked from commit 16b238b740)
2021-12-06 02:23:44 +02:00
Konstantin Belousov
9cb9ecafac libc/net/nscachedcli.c: remove write-only variables
(cherry picked from commit 0e00befcaf)
2021-12-06 02:23:44 +02:00
Konstantin Belousov
9e8f0f6934 libc/net/getservent.c: Mark write-only variables as unused
(cherry picked from commit 346eaa41f8)
2021-12-06 02:23:44 +02:00
Konstantin Belousov
75f8750524 libc/net/getprotoent.c: Mark write-only variables as unused
(cherry picked from commit f6d403743c)
2021-12-06 02:23:44 +02:00
Konstantin Belousov
4914a141fb libc/net/getnetnamadr.c: Mark write-only variables as unused
(cherry picked from commit 1c4f305d21)
2021-12-06 02:23:44 +02:00
Konstantin Belousov
20e0f16d35 libc/net/gethostnamadr.c: mark write-only variables as __unused
(cherry picked from commit 024547c9bd)
2021-12-06 02:23:44 +02:00