freebsd-nq/lib/libc
Mark Johnston 7eb138a9e5 libc/locale: Fix races between localeconv(3) and setlocale(3)
Each locale embeds a lazily initialized lconv which is populated by
localeconv(3) and localeconv_l(3).  When setlocale(3) updates the global
locale, the lconv needs to be (lazily) reinitialized.  To signal this,
we set flag variables in the locale structure.  There are two problems:

- The flags are set before the locale is fully updated, so a concurrent
  localeconv() call can observe partially initialized locale data.
- No barriers ensure that localeconv() observes a fully initialized
  locale if a flag is set.

So, move the flag update appropriately, and use acq/rel barriers to
provide some synchronization.  Note that this is inadequate in the face
of multiple concurrent calls to setlocale(3), but this is not expected
to work regardless.

Thanks to Henry Hu <henry.hu.sh@gmail.com> for providing a test case
demonstrating the race.

PR:		258360
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31899
2021-09-17 10:47:46 -04:00
..
aarch64 libc: add _get_tp() private function 2021-04-09 23:46:24 +03:00
amd64 libc: add _get_tp() private function 2021-04-09 23:46:24 +03:00
arm libc: add _get_tp() private function 2021-04-09 23:46:24 +03:00
capability Fix a few mandoc issues 2020-10-09 19:12:44 +00:00
compat-43 Adjust history, info source from v1's manuals 2019-09-04 13:44:46 +00:00
db tools/build: Don't redefine open() for the linux bootstrap 2021-08-02 14:33:23 +01:00
gdtoa Remove sparc64 specific parts of libc. 2020-02-26 18:55:09 +00:00
gen libc tls: use TLS_DTV_OFFSET defined by rtld.h 2021-08-16 13:55:35 +03:00
gmon mcount: tidy up ANSIfication 2018-10-20 22:39:35 +00:00
i386 libc: add _get_tp() private function 2021-04-09 23:46:24 +03:00
iconv Remove the SYMVER build option. 2020-04-30 22:08:40 +00:00
include Style 2021-08-03 21:19:32 +03:00
inet libc: fix cases of undefined behavior. 2018-08-07 15:24:19 +00:00
isc
locale libc/locale: Fix races between localeconv(3) and setlocale(3) 2021-09-17 10:47:46 -04:00
md
mips libc: add _get_tp() private function 2021-04-09 23:46:24 +03:00
nameser Bounds check again after advancing cp, otherwise we have a possible 2019-09-05 19:35:30 +00:00
net Correct section reference for examples in RFC3542 2021-08-01 13:55:24 +01:00
nls Implement strerror_l(). 2020-12-16 09:02:09 +00:00
posix1e libc/posix1e: Add acl_extended_file_np() function. 2021-08-27 11:52:26 +03:00
powerpc libc: add _get_tp() private function 2021-04-09 23:46:24 +03:00
powerpc64 libc: add _get_tp() private function 2021-04-09 23:46:24 +03:00
powerpcspe [PowerPC] [PowerPCSPE] Fix multiple issues in fpsetmask(). 2021-02-28 21:11:29 -06:00
quad Add casts and L suffixes to libc quad support, to work around various 2020-02-17 20:14:59 +00:00
regex libc: regex: rework unsafe pointer arithmetic 2021-01-08 13:58:35 -06:00
resolv Rather than using the legacy IP struct fields in the union for the 2019-06-04 20:53:35 +00:00
riscv riscv: Implement non-stub __vdso_gettc and __vdso_gettimekeep 2021-07-05 16:16:53 +01:00
rpc rpc(3): Correct a few common typos in source code comments 2021-08-22 08:16:09 +02:00
secure Remove the SYMVER build option. 2020-04-30 22:08:40 +00:00
softfloat libc: use standard LF line endings, not CRLF 2021-04-03 16:20:07 -04:00
stdio getdelim(3): Fix losing data on [EAGAIN] 2021-09-02 11:26:26 -07:00
stdlib Fix null pointer subtraction in mergesort() 2021-08-27 19:46:18 +02:00
stdtime tzcode: Implement timezone change detection 2021-09-12 03:07:58 +00:00
string memcpy.3: remove BUGS section allowing overlapping strings 2021-08-24 09:58:10 -04:00
sys procctl(2): Add PROC_WXMAP_CTL/STATUS 2021-09-17 15:42:01 +03:00
tests getdelim(3): Fix losing data on [EAGAIN] 2021-09-02 11:26:26 -07:00
uuid
x86 libc: vDSO timekeeping: Add pvclock support 2021-08-14 15:57:54 +03:00
xdr typo: s/impelmentation/implementation/. 2020-02-07 15:14:29 +00:00
yp Increase the size of the send and receive buffers for YP client rpc 2019-09-16 06:42:01 +00:00
libc_nossp.ldscript
libc.ldscript
Makefile libc: Use the initial-exec TLS model 2021-07-15 22:41:10 -04:00
Makefile.depend Update Makefile.depend files 2019-12-11 17:37:53 +00:00
Makefile.depend.options Update libssp paths in various Makefile.depend* files 2020-01-06 18:15:55 +00:00
Versions.def Create namespace for the symbols added during 14-CURRENT cycle. 2021-07-15 19:40:28 +03:00