freebsd-src/lib
Olivier Certner aadb4a1b3f
pthread_attr_get_np(): Use malloc(), report ENOMEM, don't tamper on error
Similarly as in the previous commit, using calloc() instead of malloc()
is useless here in the regular case since the subsequent call to
cpuset_getaffinify() is going to completely fill the allocated memory.

However, there is an additional complication.  This function tries to
allocate memory to hold the cpuset if it previously wasn't, and does so
before the thread lock is acquired, which can fail on a bad thread ID.
In this case, it is necessary to deallocate the memory allocated in this
function so that the attributes object appears unmodified to the caller
when an error is returned.  Without this, a subsequent call to
pthread_attr_getaffinity_np() would expose uninitialized memory (not
a security problem per se, since it comes from the same process) instead
of returning a full mask as it would before the failing call to
pthread_attr_get_np().  So the caller would be able to notice a change
in the state of the attributes object even if pthread_attr_get_np()
reported failure, which would be quite surprising.  A similar problem
that could occur on failure of cpuset_setaffinity() has been fixed.

Finally, we shall always report memory allocation failure.  This already
goes for pthread_attr_init(), so, if for nothing else, just be
consistent.

Reviewed by:            emaste, kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43329
2024-01-10 18:50:19 +01:00
..
atf
clang
csu
flua
geom
googletest
lib9p
lib80211
libalias
libarchive
libauditd
libbe
libbearssl libsecureboot: be more verbose about validation failures 2023-12-10 15:13:56 -05:00
libbegemot
libblacklist
libblocksruntime
libbluetooth
libbsddialog
libbsdstat
libbsm
libbsnmp
libbz2
libc History for arc4random_*() 2024-01-09 22:09:47 -08:00
libc++ Add missing /usr/include/c++/v1/__mdspan/mdspan.h header 2023-12-20 20:16:57 +01:00
libc++experimental
libc_nonshared
libcalendar
libcam
libcapsicum
libcasper libcasper: Fix typo (triple T) 2023-12-27 20:24:30 -07:00
libcbor
libclang_rt Reorganize libclang_rt Makefile and make more lib/arch combos available 2023-12-28 13:57:41 +01:00
libcom_err
libcompat
libcompiler_rt
libcrypt
libcuse
libcxxrt
libdevctl
libdevdctl libdevdctl: Fix typo (triple S) 2023-12-27 20:24:30 -07:00
libdevinfo
libdevstat
libdl
libdpv
libdwarf
libedit
libefivar
libelf
libelftc
libevent1
libexecinfo
libexpat
libfetch
libfido2
libfigpar
libgcc_eh
libgcc_s
libgeom
libgpio
libgssapi
libiconv_modules
libifconfig libifconfig: Fix bridge status member list 2023-12-21 16:50:27 +01:00
libipsec
libipt
libiscsiutil
libjail
libkiconv
libkvm
libldns
liblua
liblutok
liblzma
libmagic
libmd
libmemstat
libmilter
libmixer
libmp
libmt
libnetbsd
libnetgraph
libnetmap libnetmap: remove interface name validation 2023-12-21 14:43:57 +00:00
libnv
libomp
libopenbsd
libopencsd
libpam
libpathconv
libpcap
libpe
libpfctl libpfctl: introduce a handle-enabled variant of pfctl_add_rule() 2024-01-04 23:10:44 +01:00
libpjdlog
libpmc jevents: fix bootstrapping on Linux with Clang 16 2023-12-11 21:14:56 -08:00
libpmcstat
libproc
libprocstat
libradius
libregex
librpcsec_gss
librpcsvc
librss
librt
librtld_db
libsbuf
libsdp
libsecureboot libsecureboot: be more verbose about validation failures 2023-12-10 15:13:56 -05:00
libsm
libsmb
libsmdb
libsmutil
libsqlite3
libssp
libssp_nonshared
libstats
libstdbuf
libstdthreads
libsysdecode
libtacplus
libtelnet
libthr pthread_attr_get_np(): Use malloc(), report ENOMEM, don't tamper on error 2024-01-10 18:50:19 +01:00
libthread_db
libucl
libufs
libugidfw
libulog
libunbound
libusb
libusbhid
libutil
libveriexec
libvgl
libvmmapi
libwrap
libxo
liby
libypclnt
libz
libzstd
msun
ncurses
nss_tacplus
ofed
tests
Makefile
Makefile.inc