freebsd-nq/lib/libc/locale
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
..
ascii.c
big5.5
big5.c
btowc.3
btowc.c
c16rtomb_iconv.c
c16rtomb.c
c32rtomb_iconv.c
c32rtomb.c
collate.c libc/locale: Use O_CLOEXEC when opening locale tables 2021-07-29 09:14:50 -04:00
collate.h Add collation version support to querylocale(3). 2020-11-08 02:50:34 +00:00
collcmp.c
ctype_l.3
ctype.3
ctype.c
cXXrtomb_iconv.h
DESIGN.xlocale
digittoint.3
duplocale.3
euc.5
euc.c
fix_grouping.c
freelocale.3
gb2312.5
gb2312.c
gb18030.5
gb18030.c
gbk.5
gbk.c
isalnum.3
isalpha.3
isascii.3
isblank.3
iscntrl.3
isctype.c
isdigit.3
isgraph.3
isideogram.3
islower.3
isphonogram.3
isprint.3
ispunct.3
isrune.3
isspace.3
isspecial.3
isupper.3
iswalnum_l.3
iswalnum.3
iswctype.c
isxdigit.3
ldpart.c
ldpart.h
lmessages.c
lmessages.h
lmonetary.c libc/locale: Fix races between localeconv(3) and setlocale(3) 2021-09-17 10:47:46 -04:00
lmonetary.h
lnumeric.c libc/locale: Fix races between localeconv(3) and setlocale(3) 2021-09-17 10:47:46 -04:00
lnumeric.h
localeconv.3
localeconv.c libc/locale: Fix races between localeconv(3) and setlocale(3) 2021-09-17 10:47:46 -04:00
Makefile.inc
mblen.3
mblen.c
mblocal.h
mbrlen.3
mbrlen.c
mbrtoc16_iconv.c
mbrtoc16.c
mbrtoc32_iconv.c
mbrtoc32.c
mbrtocXX_iconv.h
mbrtowc.3
mbrtowc.c
mbsinit.3
mbsinit.c
mbsnrtowcs.c
mbsrtowcs.3 mbsrtowcs(3): Clarify the RETURN VALUES section 2020-08-07 16:56:43 +00:00
mbsrtowcs.c
mbstowcs.3
mbstowcs.c
mbtowc.3
mbtowc.c
mskanji.5
mskanji.c
multibyte.3
newlocale.3 newlocale(3): Fix a memory leak. 2020-10-02 18:35:55 +00:00
nextwctype.3
nextwctype.c
nl_langinfo.3 nl_langinfo(3): document recognized item names 2020-12-17 02:33:52 +00:00
nl_langinfo.c
nomacros.c
none.c
querylocale.3 Add collation version support to querylocale(3). 2020-11-08 02:50:34 +00:00
rpmatch.3
rpmatch.c
rune.c libc/locale: Use O_CLOEXEC when opening locale tables 2021-07-29 09:14:50 -04:00
runefile.h
runetype.c
setlocale.3 libc: Fix most issues reported by mandoc 2020-12-19 14:54:28 +00:00
setlocale.c
setlocale.h
setrunelocale.c Remove __NO_TLS. 2021-02-23 20:08:10 +02:00
Symbol.map
table.c
toascii.3
tolower.3
tolower.c
toupper.3
toupper.c
towlower.3
towupper.3
uselocale.3
utf8.5
utf8.c
wcrtomb.3
wcrtomb.c
wcsftime.3
wcsftime.c
wcsnrtombs.c
wcsrtombs.3
wcsrtombs.c
wcstod.3
wcstod.c
wcstof.c
wcstoimax.c
wcstol.3
wcstol.c
wcstold.c
wcstoll.c
wcstombs.3
wcstombs.c
wcstoul.c
wcstoull.c
wcstoumax.c
wctob.c
wctomb.3
wctomb.c
wctrans.3
wctrans.c
wctype.3
wctype.c
wcwidth.3
wcwidth.c
xlocale_private.h Remove __NO_TLS. 2021-02-23 20:08:10 +02:00
xlocale.3
xlocale.c Remove __NO_TLS. 2021-02-23 20:08:10 +02:00