Commit graph

24103 commits

Author SHA1 Message Date
John Baldwin
f7180e5d69 libgpio: Fix type mismatch for gpio_pin_[gs]et
Reported by:	GCC 13 via -Wenum-int-mismatch
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42577

(cherry picked from commit 0355ecace82cce8322e5fcdf48f751d253792ce3)
2024-01-03 09:43:48 -08:00
John Baldwin
1dcd996104 libcasper: Neuter false positive -Wuse-after-free warnings from GCC 13
GCC 13 incorrectly thinks a call to free after a failed realloc is a
use after free.

lib/libcasper/services/cap_grp/cap_grp.c: In function 'group_resize':
lib/libcasper/services/cap_grp/cap_grp.c:65:17: error: pointer 'buf' may be used after 'realloc' [-Werror=use-after-free]
   65 |                 free(buf);
      |                 ^~~~~~~~~
lib/libcasper/services/cap_grp/cap_grp.c:63:19: note: call to 'realloc' here
   63 |         gbuffer = realloc(buf, gbufsize);
      |                   ^~~~~~~~~~~~~~~~~~~~~~

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42576

(cherry picked from commit b7f7cc25c01aeacaafb86ebcffdeb258b7933b08)
2024-01-03 09:43:47 -08:00
Brooks Davis
1b0471936f libc: simplify MDASM/NOASM checks
Use boolean evaluation of :M matches and a single if statement.

Reviewed by:	imp, kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42915

(cherry picked from commit fc0288993cdad8a559fcd2c2166cf95f1fa43745)
2024-01-02 16:59:04 +00:00
Brooks Davis
444024241e libc: don't needlessly add vfork.o to NOASM
For architectures where vfork.S was named Ovfork.S this was needed, but
it was always pointless here as an entry in either MDASM or NOASM is
equivalent.

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42914

(cherry picked from commit ec27c0bb3eea73be4db6cd2f275db6c516e12d00)
2024-01-02 16:58:54 +00:00
Brooks Davis
d3f8e4bf1c libc: rename arm and i386 Ovfork.S to vfork.S
While this has been Ovfork.S forever on i386 it differs from other
syscalls that require wrappers for no obvious reason so fix that.

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42909

(cherry picked from commit 0ea469bcd548d29bbbc970325e4fa851d0e4c022)
2024-01-02 16:58:42 +00:00
Brooks Davis
9467188141 libc: Centralize non-building of sbrk stubs
The actual implementation of sbrk(2) is on top of the undocumented
break(2) system call.  On powerpc* this means we don't build _sbrk and
__sys_sbrk which were neither used nor exposed for linkage.  Otherwise
it is a no-op.

The addition to lib/libc/sys/Makefile.inc is a direct commit to
stable/14 in lieu of merging the removal of the sbrk and sstk syscalls.

(cherry picked from commit 7893419d492c40ca82b68fca3dcc0f5f7047d39b)

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43159
2024-01-02 16:22:13 +00:00
Dimitry Andric
8334205c84 Reorganize libclang_rt Makefile and make more lib/arch combos available
Upstream has made more clang runtime libraries available for more
architectures, so add them. To make this easier, split up subdir lists
into functional parts (asan, tsan, etc), and put each architecture into
its own .if block.

Effectively, this adds the following libraries for aarch64: asan, cfi,
fuzzer, msan, safestack, stats, tsan, ubsan, xray.

PR:		262706
MFC after:	3 days

(cherry picked from commit e77a1bb2757471ab3fed0750b76eeb15d0c7b10a)
2024-01-01 17:34:04 +01:00
Robert Clausecker
9a6a587e67 lib/libc/amd64/string: add timingsafe_memcmp() assembly implementation
Conceptually very similar to timingsafe_bcmp(), but with comparison
logic inspired by Elijah Stone's fancy memcmp. A baseline (SSE)
implementation was omitted this time as I was not able to get it to
perform adequately.  Best I got was 8% over the scalar version for
long inputs, but slower for short inputs.

Sponsored by:	The FreeBSD Foundation
Approved by:	security (cperciva)
Inspired by:	https://github.com/moon-chilled/fancy-memcmp
Differential Revision:	https://reviews.freebsd.org/D41696

(cherry picked from commit 5048c1b85506c5e0f441ee7dd98dd8d96d0a4a24)
2023-12-28 18:02:41 +01:00
Robert Clausecker
1347ec5d58 lib/libc/amd64/string: add timingsafe_bcmp(3) scalar, baseline implementations
Very straightforward and similar to memcmp(3). The code has
been written to use only instructions specified as having
data operand independent timing by Intel.

Sponsored by:	The FreeBSD Foundation
Approved by:	security (cperciva)
Differential Revision:	https://reviews.freebsd.org/D41673

(cherry picked from commit 76c2b331bcd9f73c5c8c43a06e328fa0c7b8c39a)
2023-12-28 18:02:41 +01:00
Robert Clausecker
cec0236976 lib/libc/amd64/string/strcspn.S: always return earliest match in 17--32 char case
When matching against a set of 17--32 characters, strcspn() uses two
invocations of PCMPISTRI to match against the first 16 characters
of the set and then the remaining characters.  If a match was found in
the first half of the set, the code originally immediately returned
that match.  However, it is possible for a match in the second half of
the set to occur earlier in the vector, leading to that match being
overlooked.

Fix the code by checking if there is a match in the second half of the
set and taking the earlier of the two matches.

The correctness of the function has been verified with extended unit
tests and test runs against the glibc test suite.

Approved by:	mjg (implicit, via IRC)
MFC after:	1 week
MFC to:		stable/14

(cherry picked from commit c91cd7d03a9dee649ba3a1b9b4014df9de111bb8)
2023-12-28 18:02:41 +01:00
Robert Clausecker
08ad297599 lib/libc/tests/string/strcspn_test.c: add test for correct match order
This new unit test verifies that if there are multiple
matches, the first match is returned, ignoring later
matches.

Approved by:	mjg (blanket, via IRC)
MFC after:	1 week
MFC to:		stable/14

(cherry picked from commit a0ecf2224ea35d029d33541878f0eee42f5fd84f)
2023-12-28 18:02:41 +01:00
Robert Clausecker
c91cfb7f9e lib/libc/tests/string: expand memcmp test to bcmp, timingsafe_{b,mem}cmp
The four functions more or less perform the same operation.
Reuse the same unit test with slight changes so we can cover
them all.  Constant-time operation is not verified for the
timingsafe_* functions.

Sponsored by:	The FreeBSD Foundation
Approved by:	ngie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41528

(cherry picked from commit c6cc06d465a98270ef734ffec7c9012ec3a1bd17)
2023-12-28 18:02:41 +01:00
Robert Clausecker
7aaa37fa1d lib/libc/tests/string/memcmp_test.c: extend test to support custom memcmp function
Extend the tests to permit loading an external memcmp function
and testing it over using the libc version. This was added by the
example of other tests in the test suite doing the same thing and
helped tremendously in development.

This change was originally part of D41442 but was taken out to
permit separate review as extrapolated from @ngie's request in
D41349.

Sponsored by:	FreeBSD Foundation
Approved by:	ngie
Differential Revision:	https://reviews.freebsd.org/D41528

(cherry picked from commit b166580681e3af173ec368656019d02ba1cc55ad)
2023-12-28 18:02:41 +01:00
Robert Clausecker
c35334b085 lib/libc/tests/string: add extended unit tests for strcmp()
This changeset add a new set of tests that comprehensively test strcmp() on
various alignments of the input. This made it easy to smoke out many
exciting new bugs in the new SSE strcmp() implementation from D41971.

MFC after:	1 week
Reviewed by:	ngie
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41970

(cherry picked from commit b49596de2622a51e5673ba2c0b3718cd88a2aa41)
2023-12-28 18:02:40 +01:00
Brooks Davis
c6e072f15c memfd_create: don't allocate heap memory
Rather than calling calloc() to allocate space for a page size array to
pass to getpagesizes(), just follow the getpagesizes() implementation
and allocate MAXPAGESIZES elements on the stack.  This avoids the need
for the allocation.

While this does mean that a new libc is required to take advantage of a
new huge page size, that was already true due to getpagesizes() using a
static buffer of MAXPAGESIZES elements.

Reviewed by:	kevans, imp, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42710

(cherry picked from commit c96772227b7dfcaf4eec4d07acb5c916643aca3a)
2023-12-21 18:13:19 +00:00
Brooks Davis
89ebe0ce1f memfd_create: move implementation to libc/gen
Due to memfd_create(3)'s construction of a path to pass to shm_open2(2),
it has a much larger than typical dependency footprint for a system
call wrapper (the list currently includes calloc, memset, sprintf, and
strlen).  As such, split it off into its own file under libc/gen to
lighten libc/sys's dependency list.

Reviewed by:	kevans, imp, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42709

(cherry picked from commit c3207e2d2554c8e36f9cf5950f8cd52a19fedfd5)
2023-12-21 18:13:18 +00:00
Peter Eriksson
e373880312 libc: correct some memory leaks in acl_to_text(3) and acl_to_text_np(3)
PR:	275232

(cherry picked from commit 7aa375dcc61e48cc56da45c9d5a11371693c8043)
2023-12-20 10:29:55 +02:00
Konstantin Belousov
79ca908fde strfmon.c: Use the restrict keyword directly
(cherry picked from commit 86e2bcbf47fb4c8dbd799f2f21c0ed338b2e8f1b)
2023-12-16 06:17:51 +02:00
Jose Luis Duran
2f427cbb35 strfmon: style fixes
(cherry picked from commit 56a0d5444d6f39302f3476b61c1b81ed39abe589)
2023-12-16 06:17:51 +02:00
Jose Luis Duran
ea99922484 strfmon: Silence scan-build warning
(cherry picked from commit 6abee52e0d79f68fd725de748d7027ca8eef2294)
2023-12-16 06:17:51 +02:00
Jose Luis Duran
9f1c1cfe69 strfmon.3: Cleanup example code
(cherry picked from commit 2a163c3649e59dd616e057994ec02092362f0ae7)
2023-12-16 06:17:51 +02:00
Kyle Evans
20baa89501 ncurses: avoid hardcoded assumptions about the layout of .OBJDIR
Abstract out the details of the FreeBSD build into a $TINFO_OBJDIR that
external builds can override if they orchestrate the build a bit
differently and have a different objdir layout as a result.  This makes
the ncurses build a little bit more flexible without requiring weird
backflips.

Reviewed by:	bapt, sjg
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.

(cherry picked from commit c086d1cbc3d13967c031e6420831349967dbcfa2)
2023-12-14 18:58:04 -06:00
Kenneth D. Merry
a9262d053b Add IBM TS1170 density codes and specs.
These were obtained from a drive, but they agree with the IBM
documentation.

The bpi/bpmm values are the same as TS1160, but the number of
tracks is much larger (18944 tracks vs 8704 for TS1160).  The tapes
are also longer, 1337m total.  (According to the MAM on a sample JF
tape.  I don't have a JE tape handy to compare.)  The end result
is a 50TB raw capacity (150TB compressed) for TS1170 with a JF
cartridge vs 20TB raw capacity (60TB compressed) for TS1160 with
a JE cartridge.

lib/libmt/mtlib.c:
	Add the TS1170 density codes to the denstiy table in libmt.

usr.bin/mt/mt.1:
	Add the TS1170 density codes and specs to the density table
	in the mt(1) man page.  As usual for TS drives, there is an
	encrypted and non-encrypted density code (0x79 and 0x59
	respectively).

Sponsored by:	Spectra Logic

(cherry picked from commit 83823d063ab57db8d3954c1530d036f1ccdceb41)
2023-12-14 15:55:24 -05:00
Brooks Davis
83c9481db9 libc: remove some obsolete VCS data
These wide char support files were copied from the previous versions
with expanded $FreeBSD$ strings in #if 0 blocks.  Remove them and the
scssid definitions in the same #if 0 blocks.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42688

(cherry picked from commit 9fc0ff9d85b1497b45a4c6d74e0bc7eea9dcf37b)
2023-12-13 23:08:50 +00:00
Brooks Davis
acf0f65f52 libc: remove unused stub vdso timecounter implementations
All supported architectures have shared page support so remove this
unused stub.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42619

(cherry picked from commit 500bf0592cf1de1d26369efe3877d812f724f5c0)
2023-12-13 22:08:14 +00:00
Brooks Davis
f695db9fba libc: centralize a few numeric symbols
fabs, __infinity, and __nan are universally implemented so declare them
in gen/Symbol.map.

We would also include __flt_rounds, but  it's under FBSD_1.3 on arm so
until that's gone we're stuck with it.  Likewise, everyone but i386
implements fp[gs]etmask.

Reviewed by:	imp, kib, emaste
Differential Revision:	https://reviews.freebsd.org/D42618

(cherry picked from commit c7045186819dbc64c3f005cb1138a1948868cf5a)
2023-12-13 22:08:14 +00:00
Brooks Davis
01edb548c5 libc: centralize makecontext symbols
Declare makecontext() and __makecontext() symbols centrally as they are
always implemented.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42617

(cherry picked from commit 5d79b5445e12873b316a04de352d12a02bfe2d53)
2023-12-13 22:08:14 +00:00
Brooks Davis
ba1279da0f libc: centralize {_,sig,}{set,long}jmp symbols
These symbols are universally exposed and documented so declare them
centrally.  Double- and triple-underscore versions exist on some
platforms, but leave those alone for now.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42616

(cherry picked from commit 1c656143be734de4b1e1bac27c0c48ef4d974510)
2023-12-13 22:08:14 +00:00
Brooks Davis
9d67dced83 libc: centralize ntoh symbols
These are implemented by net/ntoh.c via headers and compiler intrinsics
so declare them in net/Symbol.map.

Reviewed by:	imp, kib, emaste
Differential Revision:	https://reviews.freebsd.org/D42615

(cherry picked from commit ff3a9d8e2909692c73ce9f9279cac2f15848b3f4)
2023-12-13 22:08:14 +00:00
Brooks Davis
e150833764 libc: further centralize syscall symbols
All architectures necessarily implement _exit(2) and vfork(2) so
declare them in sys/Symbol.map.

Reviewed by:	imp, kib, emaste
Differential Revision:	https://reviews.freebsd.org/D42614

(cherry picked from commit e4a1800f06884dc00931f55d0fa8cd9ce473a83e)
2023-12-13 22:08:13 +00:00
Brooks Davis
e0f6b29f6a lib{c,lzma,z}: remove -DSYMBOL_VERSIONING from CFLAGS
This was part of a libkse and libpthread transition aide when libc
gained symbol versions in e62165c8b0
(March 2006).  The code that cared about this macro was removed in
commit 00fb440c1a (May 2007) when symbol
versioning was enabled by default and libthr became the default
threading library.  For unknown reasons, it stayed in libc (which
seemingly never used it) and seems to have been copied to liblzma and
libz.

Reviewed by:	imp, kib, emaste
Differential Revision:	https://reviews.freebsd.org/D42613

(cherry picked from commit e3e9c205ff54aac287309e03a808d9e9ec5c49eb)
2023-12-13 22:08:13 +00:00
Brooks Davis
695639d2f4 libc: Remove empty comments in Symbol.map
These were left over from $FreeBSD$ removal.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42612

(cherry picked from commit 1ca63a8219b88b752b064d19bd3428c61dbcf1f9)
2023-12-13 22:08:13 +00:00
Brooks Davis
9a2bee998b libc/<arch>/sys/Makefile.inc: remove cruft
Remove stray blank lines left over from $FreeBSD$ removal as well as
some CVS-era (perhaps pre-repocopy) version comments.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42611

(cherry picked from commit b73eace889f1db518a7b0b3372351e0cbf550085)
2023-12-13 22:08:13 +00:00
Dag-Erling Smørgrav
6a2dd26311 hesiod: Modernize.
Reviewed by:	zlei
Differential Revision:	https://reviews.freebsd.org/D42190

(cherry picked from commit 64fc8a936c868345a8f687fe2797474c5fcf35cb)
2023-12-13 17:41:48 +01:00
Dag-Erling Smørgrav
6d0ea82cc2 libfetch, fetch: Stop recommending the use of ca_root_nss.
MFC after:	3 days
Reviewed by:	kevans, emaste
Differential Revision:	https://reviews.freebsd.org/D42119

(cherry picked from commit 2821a7498f65d357c68166e1978b491abef1ca4a)
2023-12-13 17:23:57 +01:00
Xin LI
29553f9e8c MFV: xz 5.4.5
(cherry picked from commit ca6a6373bdaed010d6cbfb27f7249ae96009409d)
2023-12-10 01:06:26 -08:00
Brooks Davis
1c63aa2989 procctl.2: improve phrasing for ASLR disable
Reported by:	jrtc27
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D42364

(cherry picked from commit 4894205482555447c6b3372598c7589a66596724)
2023-12-02 00:03:25 +00:00
Alan Somers
f23f9941f1 aio_read.2: correct the description of aio_buf
Looks like a copypasta from aio_write.2.

[skip ci]

Reported by:	Paul Floyd <pjfloyd@wanadoo.fr>
Sponsored by:	Axcient
Reviewed by:	jilles (manpages)
Differential Revision: https://reviews.freebsd.org/D42621

(cherry picked from commit 04cfe6c12ccc75624dc87ab8f44c4852b16f0c4f)
2023-11-30 13:38:09 -07:00
Alan Somers
60314995ef libc/libc/rpc: refactor some global variables
* Combine dg_fd_locks and dg_cv into one array.
* Similarly for vc_fd_locks and vc_cv
* Turn some macros into inline functions

This is a mostly cosmetic change to make refactoring these strutures in
a future commit easier.

Sponsored by:	Axcient
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D42597

(cherry picked from commit a5c2f4e939430f0048136c39fb9fa6093d401905)

lib/libc/rpc: switch the per-fd structs in clnt_{dg,vc}.c to RB Trees

This saves oodles of memory, especially when "ulimit -n" is large.  It
also prevents a buffer overflow if getrlimit should fail.

Also replace per-fd condvars with mutexes to simplify the code.

PR:		274968
Sponsored by:	Axcient
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D42597

(cherry picked from commit 24938f9311c9c9acc1ce747f4e6a088c2dbc967d)
2023-11-29 20:16:16 -07:00
Cy Schubert
1318715277 Unbound: Manually update version strings
This was missed earlier today.

Reported by:	"Herbert J. Skuhra" <herbert@gojira.at>
Fixes:		16fd0b249104

(cherry picked from commit 67267734315c6a48db31697f0a0669fa1f985969)
2023-11-28 07:15:25 -08:00
Warner Losh
4025b5b527 libc: Purge unneeded cdefs.h
These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D42385

(cherry picked from commit 559a218c9b257775fb249b67945fe4a05b7a6b9f)
2023-11-26 21:20:09 -07:00
Gordon Bergling
14dcb4cfe4 libcasper: Fix a typo in a source code comment
- s/mutiple/multiple/

(cherry picked from commit 637e4ef1a6bcd8677dabd8c08916df3091be5f64)
2023-11-26 08:53:30 +01:00
Gordon Bergling
7041faf5a5 Add a HISTORY section for memcpy(3) and mempcpy(3)
The memcpy() function first appeared in AT&T System V UNIX and was
reimplemented for 4.3BSD-Tahoe. The mempcpy() function first appeared in
FreeBSD 13.1.

PR:	272227
Differential Revision:	https://reviews.freebsd.org/D42630

(cherry picked from commit 8c8ffe541eabb23e21ddffb534ecda7ac6d7e04a)
2023-11-25 09:25:03 +01:00
Kristof Provost
68013761ce libpfctl: handle pfctl_do_ioctl() failures better
Ensure that we free nvlists and other allocations if pfctl_do_ioctl()
fails.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 498934c5ff51e6b0d3199db5d27ed11b1e8b9582)
2023-11-24 10:19:13 +01:00
Kristof Provost
8423bf2a9e libpfctl: handle allocation failure
While it's unlikely for userspace to fail to allocate memory it is still
possible. Handle malloc() returning NULL.

Reported by:	Bill Meeks <bill@themeeks.net>
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 33d55d0d0f33787e9e2796b5000be73af42573bc)
2023-11-24 10:19:08 +01:00
Gordon Bergling
edb6d4f50d getpeerid.3: Clarify the 's' argument
The argument 's' of getpeerid(3) must be a connected UNIX-domain socket,
so document it.

PR:	248614
Differential Revision:	https://reviews.freebsd.org/D42629

(cherry picked from commit fa9f74220146233b7224da7c94870540dc39ae68)
2023-11-21 07:49:28 +01:00
Kristof Provost
94b8a547c5 pf: expose more syncookie state information to userspace
Allow userspace to retrieve low and high water marks, as well as the
current number of half open states.

MFC after:	1 week
Sponsored by:	Modirum MDPay

(cherry picked from commit a6173e94635b03aa7aab90a67785c8c3e7c6247b)
2023-11-13 08:10:27 +01:00
Doug Rabson
e968616046 pkgbase: Move headers and libs out of runtime and utilities
Headers from src/include were in the runtime-dev package but
subdirectories of src/include ended up in utilities-dev by default.
Neither package is a good choice - the headers in src/include are not
useful without the libraries contained in clibs-dev.

This moves the standard C headers to clibs-dev (C++ headers are already
in this package). While working on this, I found that various clang
libraries and headers were also bundled into utilities-dev by default
so these are also moved to clang-dev.

I also added a FreeBSD-build-essential meta package to make it simple to
install all the toolchain parts.

PR:		254173
Reviewed byb:	manu
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D41815

(cherry picked from commit 78847e1e592789dc85bddf4d2f1d9a8ce4614ff1)
2023-11-12 10:37:16 +00:00
Ed Maste
d2c65a1c94 fflush: correct buffer handling in __sflush
Two additional stdio changes followed 86a16ada1e and need to be
reverted as part of the fflush fix.

This reverts commit 6e13794fbe.
This reverts commit bafaa70b6f.

Fixes: d09a3bf72c0b ("fflush: correct buffer handling in __sflush")
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42491

(cherry picked from commit 4e0e01bf6511c28212d7dff94fe131a502e13026)

Approved by:	so
2023-11-07 12:31:34 -05:00
Ed Maste
abe12d2f4c libc: remove unused errno.h include
errno.h was added in 44cf1e5eb4, which has been reverted.

Fixes: d09a3bf72c0b ("fflush: correct buffer handling in __sflush")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 418f026bd5a5084c1c4e2e91ad38051f6caa928c)

Approved by:	so
2023-11-07 12:29:20 -05:00