From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyKXS-00053D-8a for guix-patches@gnu.org; Tue, 20 Mar 2018 12:55:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyKXO-0002oq-6H for guix-patches@gnu.org; Tue, 20 Mar 2018 12:55:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:36240) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eyKXN-0002oh-U7 for guix-patches@gnu.org; Tue, 20 Mar 2018 12:55:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eyKXN-0006p4-Kg for guix-patches@gnu.org; Tue, 20 Mar 2018 12:55:01 -0400 Subject: [bug#30873] [PATCH core-updates 1/3] gnu: glibc: Update to 2.27. Resent-Message-ID: From: Marius Bakke In-Reply-To: <87r2oe6g36.fsf@gnu.org> References: <20180320102045.31795-1-mbakke@fastmail.com> <20180320102419.32286-1-mbakke@fastmail.com> <87r2oe6g36.fsf@gnu.org> Date: Tue, 20 Mar 2018 17:54:36 +0100 Message-ID: <877eq6adrn.fsf@fastmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 30873@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: > Hello! > > Thanks for working on this update! Crazy that it turned out to be this > difficult. > > Marius Bakke skribis: > >> +++ b/gnu/packages/patches/glibc-2.27-git-fixes.patch >> @@ -0,0 +1,12765 @@ >> +This patch includes all post-release fixes for version 2.27 up to commit >> +3b922526415d1af93fe5a0e3caf7e6a790cb1619. >> + >> +https://sourceware.org/git/?p=3Dglibc.git;a=3Dshortlog;h=3Drefs/heads/r= elease/2.27/master >> + >> +Generated by "git diff glibc-2.27..release/2.27/master". > > In general I=E2=80=99d be in favor of not doing that, unless the fixes are > important (build issue, security issue, etc.), as was the case when we > packaged 2.26; and, if there are important fixes, I=E2=80=99d rather extr= act > them from the whole patch stream, and skip unrelated changes. > > For example, I=E2=80=99m sure we can live without the locale updates that= show > up in this patch set. :-) > > Do you know which of these patches are really needed? > > Thoughts? Hello! I was hoping you'd comment on this ;-) There are actually not a lot of high severity fixes in 2.27 yet. I opted for this mostly as a proof-of-concept for a couple of reasons. * Giving the GNU C Library special treatment is OK IMO. * In 2.26, cherry-picking individual fixes was not feasible. ** However, using the same method, the 2.26 diff is "only" 27k lines/904k. It does mean growing the Guix repository up to ~1MiB every six months, but in the large scale of things, it doesn't seem that bad. Yet, I'm not sure if it makes sense to do this now. There are only a handful of "important" commits on 2.27 so far. Additionally, the 2.27 release manager has said he would do 2.27.1 once (if?) enough patches has piled up, so maybe there is hope for the future. The question is which do we pick? Portability fixes for arches we don't (yet) support? Some of the locale fixes seem genuine, and not just typos, e.g.: * https://sourceware.org/bugzilla/show_bug.cgi?id=3D22517 * https://sourceware.org/bugzilla/show_bug.cgi?id=3D22848 Actually, now that I've scoured the history, reverting this one commit brings the patch from 12921 to 2391 lines: . ~2k isn't too bad IMO. Yet, I've attached a patch with only the following commits, and without NEWS and ChangeLog updates. It's 547 lines, which is more palatable; but may grow longer than the unified approach since it includes git commit logs. 56170e064e2b21ce204f0817733e92f1730541ea 516fa6080481a1433c173320b1c1432868e1e38a f36553bf6a4f69070f99badbdab5802b43e6e211 7c6304182b9f422b782ace1cdd3efbde056aec36 78a90c2f74a2012dd3eff302189e47ff6779a757 1e52d8e65a58c49a48549053a1b89c06240e0c6c But, we risk missing important commits this way, and may cause headaches for people wanting to port Guix to a new architecture. And the approach doesn't really scale for branches approaching ~100 commits. Regardless, here is a patch with just the above commits. Let me know if you spot others in the history that look important. WDYT? I suppose we'll have to revisit this with every 'core-updates'. :-) --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-gnu-glibc-Update-to-2.27.patch Content-Transfer-Encoding: quoted-printable From=20494630cf5011d6111cd080afb33449d0e70c366e Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Thu, 15 Mar 2018 21:08:37 +0100 Subject: [PATCH] gnu: glibc: Update to 2.27. * gnu/packages/base.scm (glibc/linux): Update to 2.27. [source](patches): Add 'glibc-hidden-visibility-ldconfig.patch' and 'glibc-2.27.git-fixes.patch'. [native-inputs]: Add BISON. [arguments]: Remove deprecated "--enable-add-ons" from #:configure-flags. Also remove unneeded "libc_cv_ssp=3Dno" and "libcv_ssp_strong=3Dno" flags. (glibc-2.26): New public variable. * gnu/packages/commencement.scm (glibc-final-with-bootstrap-bash)[native-in= puts]: Add BISON-BOOT0. * gnu/packages/patches/glibc-2.27-git-fixes.patch, gnu/packages/patches/glibc-hidden-visibility-ldconfig.patch: New files. * gnu/local.mk (dist_patch_DATA): Register them. =2D-- gnu/local.mk | 2 + gnu/packages/base.scm | 49 +- gnu/packages/commencement.scm | 3 +- gnu/packages/patches/glibc-2.27-git-fixes.patch | 547 +++++++++++++++++= ++++ .../patches/glibc-hidden-visibility-ldconfig.patch | 16 + 5 files changed, 596 insertions(+), 21 deletions(-) create mode 100644 gnu/packages/patches/glibc-2.27-git-fixes.patch create mode 100644 gnu/packages/patches/glibc-hidden-visibility-ldconfig.p= atch diff --git a/gnu/local.mk b/gnu/local.mk index 902f2cf9e..e61b404b9 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -715,12 +715,14 @@ dist_patch_DATA =3D \ %D%/packages/patches/glibc-CVE-2017-1000366-pt3.patch \ %D%/packages/patches/glibc-allow-kernel-2.6.32.patch \ %D%/packages/patches/glibc-bootstrap-system.patch \ + %D%/packages/patches/glibc-hidden-visibility-ldconfig.patch \ %D%/packages/patches/glibc-ldd-x86_64.patch \ %D%/packages/patches/glibc-locales.patch \ %D%/packages/patches/glibc-memchr-overflow-i686.patch \ %D%/packages/patches/glibc-o-largefile.patch \ %D%/packages/patches/glibc-vectorized-strcspn-guards.patch \ %D%/packages/patches/glibc-versioned-locpath.patch \ + %D%/packages/patches/glibc-2.27-git-fixes.patch \ %D%/packages/patches/glusterfs-use-PATH-instead-of-hardcodes.patch \ %D%/packages/patches/glog-gcc-5-demangling.patch \ %D%/packages/patches/gmp-arm-asm-nothumb.patch \ diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index c6b21e725..57c7cd514 100644 =2D-- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -36,6 +36,7 @@ #:use-module (gnu packages) #:use-module (gnu packages acl) #:use-module (gnu packages bash) + #:use-module (gnu packages bison) #:use-module (gnu packages ed) #:use-module (gnu packages guile) #:use-module (gnu packages multiprecision) @@ -538,26 +539,15 @@ store.") (define-public glibc/linux (package (name "glibc") =2D ;; Glibc has stable branches that continuously pick fixes for each su= pported =2D ;; release. Unfortunately they do not do point-releases, so we are s= tuck =2D ;; with copying almost all patches, or use a snapshot of the release = branch. =2D ;; =2D ;; This version number corresponds to the output of `git describe` an= d the =2D ;; archive can be generated by checking out the commit ID and running: =2D ;; git archive --prefix=3D$(git describe)/ HEAD | xz > $(git describ= e).tar.xz =2D ;; See for details. =2D ;; ;; Note: Always use a dot after the minor version since various places = rely ;; on "version-major+minor" to determine where locales are found. =2D (version "2.26.105-g0890d5379c") + (version "2.27") (source (origin (method url-fetch) =2D (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/" =2D "glibc-" (version-major+minor version) "= -" =2D (caddr (string-split version #\.)) ".tar= .xz")) + (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.= xz")) (sha256 (base32 =2D "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g")) + "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji")) (snippet ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is ;; required on LFS distros to avoid loading the distro's libc= .so @@ -569,6 +559,8 @@ store.") #t)) (modules '((guix build utils))) (patches (search-patches "glibc-ldd-x86_64.patch" + "glibc-2.27-git-fixes.patch" + "glibc-hidden-visibility-ldconfig.pat= ch" "glibc-versioned-locpath.patch" "glibc-allow-kernel-2.6.32.patch")))) (build-system gnu-build-system) @@ -595,8 +587,7 @@ store.") (guix build gnu-build-system)) =20 #:configure-flags =2D (list "--enable-add-ons" =2D "--sysconfdir=3D/etc" + (list "--sysconfdir=3D/etc" =20 ;; Installing a locale archive with all the locales is to ;; expensive (~100 MiB), so we rely on users to install the @@ -631,10 +622,7 @@ store.") ;; Use our Bash instead of /bin/sh. (string-append "BASH_SHELL=3D" (assoc-ref %build-inputs "bash") =2D "/bin/bash") =2D =2D ;; XXX: Work around "undefined reference to `__stack_chk_gua= rd'". =2D "libc_cv_ssp=3Dno" "libc_cv_ssp_strong=3Dno") + "/bin/bash")) =20 #:tests? #f ; XXX #:phases (modify-phases %standard-phases @@ -745,6 +733,7 @@ store.") ;; install the message catalogs, with 'msgfmt'. (native-inputs `(("texinfo" ,texinfo) ("perl" ,perl) + ("bison" ,bison) ("gettext" ,gettext-minimal))) =20 (native-search-paths @@ -853,6 +842,26 @@ GLIBC/HURD for a Hurd host" ;; Below are old libc versions, which we use mostly to build locale data in ;; the old format (which the new libc cannot cope with.) =20 +(define-public glibc-2.26 + (package + (inherit glibc) + ;; This version number corresponds to the output of `git describe` and= the + ;; archive can be generated by checking out the commit ID and running: + ;; git archive --prefix=3D$(git describe)/ HEAD | xz > $(git describe= ).tar.xz + ;; See for why this was necessary. + (version "2.26.105-g0890d5379c") + (source (origin + (inherit (package-source glibc)) + (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/" + "glibc-" (version-major+minor version) "= -" + (caddr (string-split version #\.)) ".tar= .xz")) + (sha256 + (base32 + "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g")) + (patches (search-patches "glibc-ldd-x86_64.patch" + "glibc-versioned-locpath.patch" + "glibc-allow-kernel-2.6.32.patch"))= )))) + (define-public glibc-2.25 (package (inherit glibc) diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index 92766de6e..3a7555b07 100644 =2D-- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -522,7 +522,8 @@ the bootstrap environment." #t))))))) (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0)))) (native-inputs =2D `(("texinfo" ,texinfo-boot0) + `(("bison" ,bison-boot0) + ("texinfo" ,texinfo-boot0) ("perl" ,perl-boot0))) (inputs `(;; The boot inputs. That includes the bootstrap libc. We don't w= ant diff --git a/gnu/packages/patches/glibc-2.27-git-fixes.patch b/gnu/packages= /patches/glibc-2.27-git-fixes.patch new file mode 100644 index 000000000..a54cf0954 =2D-- /dev/null +++ b/gnu/packages/patches/glibc-2.27-git-fixes.patch @@ -0,0 +1,547 @@ +These commits are cherry-picked from the "release/2.27/master" branch. + +https://sourceware.org/git/?p=3Dglibc.git;a=3Dshortlog;h=3Drefs/heads/rele= ase/2.27/master + +Currently, we have the following (with NEWS and ChangeLog entries ommitted= ). + +56170e064e2b21ce204f0817733e92f1730541ea +516fa6080481a1433c173320b1c1432868e1e38a +f36553bf6a4f69070f99badbdab5802b43e6e211 +7c6304182b9f422b782ace1cdd3efbde056aec36 +78a90c2f74a2012dd3eff302189e47ff6779a757 +1e52d8e65a58c49a48549053a1b89c06240e0c6c + +From 56170e064e2b21ce204f0817733e92f1730541ea Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Wed, 7 Feb 2018 13:53:10 +0100 +Subject: [PATCH] Linux: use reserved name __key in pkey_get [BZ #22797] + +_key is not reserved name and we should avoid using that. It seems that +it was simple typo when pkey_* was implemented. + +(cherry picked from commit 388ff7bd0d57d7061fdd39a2f26f65687e8058da) + +diff --git a/sysdeps/unix/sysv/linux/bits/mman-shared.h b/sysdeps/unix/sys= v/linux/bits/mman-shared.h +index 7715e680ca..d15ba95c9d 100644 +--- a/sysdeps/unix/sysv/linux/bits/mman-shared.h ++++ b/sysdeps/unix/sysv/linux/bits/mman-shared.h +@@ -61,7 +61,7 @@ int pkey_set (int __key, unsigned int __access_rights) _= _THROW; +=20 + /* Return the access rights for the current thread for KEY, which must + have been allocated using pkey_alloc. */ +-int pkey_get (int _key) __THROW; ++int pkey_get (int __key) __THROW; +=20 + /* Free an allocated protection key, which must have been allocated + using pkey_alloc. */ + +From 516fa6080481a1433c173320b1c1432868e1e38a Mon Sep 17 00:00:00 2001 +From: "Dmitry V. Levin" +Date: Fri, 29 Dec 2017 23:19:32 +0000 +Subject: [PATCH] linux/aarch64: sync sys/ptrace.h with Linux 4.15 [BZ #224= 33] + +Remove compat-specific constants that were never exported by kernel +headers under these names. Before linux commit v3.7-rc1~16^2~1 they +were exported with COMPAT_ prefix, and since that commit they are not +exported at all. + +* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_request): +Remove arm-specific PTRACE_GET_THREAD_AREA, PTRACE_GETHBPREGS, +and PTRACE_SETHBPREGS. + +(cherry picked from commit 2fd4bbaa1446f1be700e10c526cf585a796c4991) + +diff --git a/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h b/sysdeps/unix/s= ysv/linux/aarch64/sys/ptrace.h +index 4be45b95ff..444edbb702 100644 +--- a/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h ++++ b/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h +@@ -78,18 +78,10 @@ enum __ptrace_request + PTRACE_DETACH =3D 17, + #define PT_DETACH PTRACE_DETACH +=20 +- PTRACE_GET_THREAD_AREA =3D 22, +- + /* Continue and stop at the next entry to or return from syscall. */ + PTRACE_SYSCALL =3D 24, + #define PT_SYSCALL PTRACE_SYSCALL +=20 +- /* Get all hardware breakpoint registers. */ +- PTRACE_GETHBPREGS =3D 29, +- +- /* Set all hardware breakpoint registers. */ +- PTRACE_SETHBPREGS =3D 30, +- + /* Set ptrace filter options. */ + PTRACE_SETOPTIONS =3D 0x4200, + #define PT_SETOPTIONS PTRACE_SETOPTIONS + +From f36553bf6a4f69070f99badbdab5802b43e6e211 Mon Sep 17 00:00:00 2001 +From: Mike FABIAN +Date: Mon, 19 Feb 2018 21:59:30 +0100 +Subject: [PATCH] =3D?UTF-8?q?Add=3D20missing=3D20=3DE2=3D80=3D9Creorder-en= d=3DE2=3D80=3D9D?=3D + =3D?UTF-8?q?=3D20in=3D20LC=3D5FCOLLATE=3D20of=3D20et=3D5FEE=3D20[BZ=3D20#= 22517]?=3D +MIME-Version: 1.0 +Content-Type: text/plain; charset=3DUTF-8 +Content-Transfer-Encoding: 8bit + + [BZ #22517] + * localedata/locales/et_EE (LC_COLLATE): add missing =E2=80=9Creorder-end= =E2=80=9D + +(cherry picked from commit 7ec5f9465e732e668d0dc94ac078ba68056d6d0a) + +diff --git a/localedata/locales/et_EE b/localedata/locales/et_EE +index 9cb55b568f..bab7493c98 100644 +--- a/localedata/locales/et_EE ++++ b/localedata/locales/et_EE +@@ -103,6 +103,8 @@ reorder-after + ;;;IGNORE % =C3=BC + ;;;IGNORE % =C3=9C +=20 ++reorder-end ++ + END LC_COLLATE +=20 + LC_CTYPE + +From 7c6304182b9f422b782ace1cdd3efbde056aec36 Mon Sep 17 00:00:00 2001 +From: DJ Delorie +Date: Thu, 1 Mar 2018 23:20:45 -0500 +Subject: [PATCH] [BZ #22342] Fix netgroup cache keys. + +Unlike other nscd caches, the netgroup cache contains two types of +records - those for "iterate through a netgroup" (i.e. setnetgrent()) +and those for "is this user in this netgroup" (i.e. innetgr()), +i.e. full and partial records. The timeout code assumes these records +have the same key for the group name, so that the collection of records +that is "this netgroup" can be expired as a unit. + +However, the keys are not the same, as the in-netgroup key is generated +by nscd rather than being passed to it from elsewhere, and is generated +without the trailing NUL. All other keys have the trailing NUL, and as +noted in the linked BZ, debug statements confirm that two keys for the +same netgroup are added to the cache with two different lengths. + +The result of this is that as records in the cache expire, the purge +code only cleans out one of the two types of entries, resulting in +stale, possibly incorrect, and possibly inconsistent cache data. + +The patch simply includes the existing NUL in the computation for the +key length ('key' points to the char after the NUL, and 'group' to the +first char of the group, so 'key-group' includes the first char to the +NUL, inclusive). + + [BZ #22342] + * nscd/netgroupcache.c (addinnetgrX): Include trailing NUL in + key value. + +Reviewed-by: Carlos O'Donell +(cherry picked from commit 1c81d55fc4b07b51adf68558ba74ce975153e580) + +diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c +index b832c9315f..2f187b208c 100644 +--- a/nscd/netgroupcache.c ++++ b/nscd/netgroupcache.c +@@ -480,7 +480,7 @@ addinnetgrX (struct database_dyn *db, int fd, request_= header *req, + { + const char *group =3D key; + key =3D (char *) rawmemchr (key, '\0') + 1; +- size_t group_len =3D key - group - 1; ++ size_t group_len =3D key - group; + const char *host =3D *key++ ? key : NULL; + if (host !=3D NULL) + key =3D (char *) rawmemchr (key, '\0') + 1; + +From 78a90c2f74a2012dd3eff302189e47ff6779a757 Mon Sep 17 00:00:00 2001 +From: Andreas Schwab +Date: Fri, 2 Mar 2018 23:07:14 +0100 +Subject: [PATCH] Fix multiple definitions of __nss_*_database (bug 22918) + +(cherry picked from commit eaf6753f8aac33a36deb98c1031d1bad7b593d2d) + +diff --git a/nscd/gai.c b/nscd/gai.c +index d081747797..576fd0045b 100644 +--- a/nscd/gai.c ++++ b/nscd/gai.c +@@ -45,3 +45,6 @@ + #ifdef HAVE_LIBIDN + # include + #endif ++ ++/* Some variables normally defined in libc. */ ++service_user *__nss_hosts_database attribute_hidden; +diff --git a/nss/nsswitch.c b/nss/nsswitch.c +index d5e655974f..b0f0c11a3e 100644 +--- a/nss/nsswitch.c ++++ b/nss/nsswitch.c +@@ -62,7 +62,7 @@ static service_library *nss_new_service (name_database *= database, +=20 + /* Declare external database variables. */ + #define DEFINE_DATABASE(name) \ +- extern service_user *__nss_##name##_database attribute_hidden; \ ++ service_user *__nss_##name##_database attribute_hidden; \ + weak_extern (__nss_##name##_database) + #include "databases.def" + #undef DEFINE_DATABASE +diff --git a/nss/nsswitch.h b/nss/nsswitch.h +index eccb535ef5..63573b9ebc 100644 +--- a/nss/nsswitch.h ++++ b/nss/nsswitch.h +@@ -226,10 +226,10 @@ libc_hidden_proto (__nss_hostname_digits_dots) + #define MAX_NR_ADDRS 48 +=20 + /* Prototypes for __nss_*_lookup2 functions. */ +-#define DEFINE_DATABASE(arg) \ +- service_user *__nss_##arg##_database attribute_hidden; \ +- int __nss_##arg##_lookup2 (service_user **, const char *, \ +- const char *, void **); \ ++#define DEFINE_DATABASE(arg) \ ++ extern service_user *__nss_##arg##_database attribute_hidden; \ ++ int __nss_##arg##_lookup2 (service_user **, const char *, \ ++ const char *, void **); \ + libc_hidden_proto (__nss_##arg##_lookup2) + #include "databases.def" + #undef DEFINE_DATABASE +diff --git a/posix/tst-rfc3484-2.c b/posix/tst-rfc3484-2.c +index f509534ca9..8c64ac59ff 100644 +--- a/posix/tst-rfc3484-2.c ++++ b/posix/tst-rfc3484-2.c +@@ -58,6 +58,7 @@ _res_hconf_init (void) + #undef USE_NSCD + #include "../sysdeps/posix/getaddrinfo.c" +=20 ++service_user *__nss_hosts_database attribute_hidden; +=20 + /* This is the beginning of the real test code. The above defines + (among other things) the function rfc3484_sort. */ +diff --git a/posix/tst-rfc3484-3.c b/posix/tst-rfc3484-3.c +index ae44087a10..1c61aaf844 100644 +--- a/posix/tst-rfc3484-3.c ++++ b/posix/tst-rfc3484-3.c +@@ -58,6 +58,7 @@ _res_hconf_init (void) + #undef USE_NSCD + #include "../sysdeps/posix/getaddrinfo.c" +=20 ++service_user *__nss_hosts_database attribute_hidden; +=20 + /* This is the beginning of the real test code. The above defines + (among other things) the function rfc3484_sort. */ +diff --git a/posix/tst-rfc3484.c b/posix/tst-rfc3484.c +index 7f191abbbc..8f45848e44 100644 +--- a/posix/tst-rfc3484.c ++++ b/posix/tst-rfc3484.c +@@ -58,6 +58,7 @@ _res_hconf_init (void) + #undef USE_NSCD + #include "../sysdeps/posix/getaddrinfo.c" +=20 ++service_user *__nss_hosts_database attribute_hidden; +=20 + /* This is the beginning of the real test code. The above defines + (among other things) the function rfc3484_sort. */ + +From 1e52d8e65a58c49a48549053a1b89c06240e0c6c Mon Sep 17 00:00:00 2001 +From: Adhemerval Zanella +Date: Fri, 17 Nov 2017 16:04:29 -0200 +Subject: [PATCH] i386: Fix i386 sigaction sa_restorer initialization + (BZ#21269) + +This patch fixes the i386 sa_restorer field initialization for sigaction +syscall for kernel with vDSO. As described in bug report, i386 Linux +(and compat on x86_64) interprets SA_RESTORER clear with nonzero +sa_restorer as a request for stack switching if the SS segment is 'funny'. +This means that anything that tries to mix glibc's signal handling with +segmentation (for instance through modify_ldt syscall) is randomly broken +depending on what values lands in sa_restorer. + +The testcase added is based on Linux test tools/testing/selftests/x86/ldt= _gdt.c, +more specifically in do_multicpu_tests function. The main changes are: + + - C11 atomics instead of plain access. + + - Remove x86_64 support which simplifies the syscall handling and fallba= cks. + + - Replicate only the test required to trigger the issue. + +Checked on i686-linux-gnu. + + [BZ #21269] + * sysdeps/unix/sysv/linux/i386/Makefile (tests): Add tst-bz21269. + * sysdeps/unix/sysv/linux/i386/sigaction.c (SET_SA_RESTORER): Clear + sa_restorer for vDSO case. + * sysdeps/unix/sysv/linux/i386/tst-bz21269.c: New file. + +(cherry picked from commit 68448be208ee06e76665918b37b0a57e3e00c8b4) + +diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/lin= ux/i386/Makefile +index 4080b8c966..da716e2c1b 100644 +--- a/sysdeps/unix/sysv/linux/i386/Makefile ++++ b/sysdeps/unix/sysv/linux/i386/Makefile +@@ -3,6 +3,9 @@ default-abi :=3D 32 +=20 + ifeq ($(subdir),misc) + sysdep_routines +=3D ioperm iopl vm86 ++ ++tests +=3D tst-bz21269 ++$(objpfx)tst-bz21269: $(shared-thread-library) + endif +=20 + ifeq ($(subdir),elf) +diff --git a/sysdeps/unix/sysv/linux/i386/sigaction.c b/sysdeps/unix/sysv/= linux/i386/sigaction.c +index a5eb9e0d3e..177ff60ee6 100644 +--- a/sysdeps/unix/sysv/linux/i386/sigaction.c ++++ b/sysdeps/unix/sysv/linux/i386/sigaction.c +@@ -42,7 +42,6 @@ extern void restore_rt (void) asm ("__restore_rt") attri= bute_hidden; + #endif + extern void restore (void) asm ("__restore") attribute_hidden; +=20 +- + /* If ACT is not NULL, change the action for SIG to *ACT. + If OACT is not NULL, put the old action for SIG in *OACT. */ + int +@@ -65,6 +64,8 @@ __libc_sigaction (int sig, const struct sigaction *act, = struct sigaction *oact) + kact.sa_restorer =3D ((act->sa_flags & SA_SIGINFO) + ? &restore_rt : &restore); + } ++ else ++ kact.sa_restorer =3D NULL; + } +=20 + /* XXX The size argument hopefully will have to be changed to the +diff --git a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c b/sysdeps/unix/sys= v/linux/i386/tst-bz21269.c +new file mode 100644 +index 0000000000..353e36507d +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c +@@ -0,0 +1,233 @@ ++/* Test for i386 sigaction sa_restorer handling (BZ#21269) ++ Copyright (C) 2017 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++/* This is based on Linux test tools/testing/selftests/x86/ldt_gdt.c, ++ more specifically in do_multicpu_tests function. The main changes ++ are: ++ ++ - C11 atomics instead of plain access. ++ - Remove x86_64 support which simplifies the syscall handling ++ and fallbacks. ++ - Replicate only the test required to trigger the issue for the ++ BZ#21269. */ ++ ++#include ++ ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++ ++static int ++xset_thread_area (struct user_desc *u_info) ++{ ++ long ret =3D syscall (SYS_set_thread_area, u_info); ++ TEST_VERIFY_EXIT (ret =3D=3D 0); ++ return ret; ++} ++ ++static void ++xmodify_ldt (int func, const void *ptr, unsigned long bytecount) ++{ ++ TEST_VERIFY_EXIT (syscall (SYS_modify_ldt, 1, ptr, bytecount) =3D=3D 0); ++} ++ ++static int ++futex (int *uaddr, int futex_op, int val, void *timeout, int *uaddr2, ++ int val3) ++{ ++ return syscall (SYS_futex, uaddr, futex_op, val, timeout, uaddr2, val3); ++} ++ ++static void ++xsethandler (int sig, void (*handler)(int, siginfo_t *, void *), int flag= s) ++{ ++ struct sigaction sa =3D { 0 }; ++ sa.sa_sigaction =3D handler; ++ sa.sa_flags =3D SA_SIGINFO | flags; ++ TEST_VERIFY_EXIT (sigemptyset (&sa.sa_mask) =3D=3D 0); ++ TEST_VERIFY_EXIT (sigaction (sig, &sa, 0) =3D=3D 0); ++} ++ ++static jmp_buf jmpbuf; ++ ++static void ++sigsegv_handler (int sig, siginfo_t *info, void *ctx_void) ++{ ++ siglongjmp (jmpbuf, 1); ++} ++ ++/* Points to an array of 1024 ints, each holding its own index. */ ++static const unsigned int *counter_page; ++static struct user_desc *low_user_desc; ++static struct user_desc *low_user_desc_clear; /* Used to delete GDT entry= . */ ++static int gdt_entry_num; ++ ++static void ++setup_counter_page (void) ++{ ++ long page_size =3D sysconf (_SC_PAGE_SIZE); ++ TEST_VERIFY_EXIT (page_size > 0); ++ unsigned int *page =3D xmmap (NULL, page_size, PROT_READ | PROT_WRITE, ++ MAP_ANONYMOUS | MAP_PRIVATE | MAP_32BIT, -1); ++ for (int i =3D 0; i < (page_size / sizeof (unsigned int)); i++) ++ page[i] =3D i; ++ counter_page =3D page; ++} ++ ++static void ++setup_low_user_desc (void) ++{ ++ low_user_desc =3D xmmap (NULL, 2 * sizeof (struct user_desc), ++ PROT_READ | PROT_WRITE, ++ MAP_ANONYMOUS | MAP_PRIVATE | MAP_32BIT, -1); ++ ++ low_user_desc->entry_number =3D -1; ++ low_user_desc->base_addr =3D (unsigned long) &counter_page[1]; ++ low_user_desc->limit =3D 0xffff; ++ low_user_desc->seg_32bit =3D 1; ++ low_user_desc->contents =3D 0; ++ low_user_desc->read_exec_only =3D 0; ++ low_user_desc->limit_in_pages =3D 1; ++ low_user_desc->seg_not_present =3D 0; ++ low_user_desc->useable =3D 0; ++ ++ xset_thread_area (low_user_desc); ++ ++ low_user_desc_clear =3D low_user_desc + 1; ++ low_user_desc_clear->entry_number =3D gdt_entry_num; ++ low_user_desc_clear->read_exec_only =3D 1; ++ low_user_desc_clear->seg_not_present =3D 1; ++} ++ ++/* Possible values of futex: ++ 0: thread is idle. ++ 1: thread armed. ++ 2: thread should clear LDT entry 0. ++ 3: thread should exit. */ ++static atomic_uint ftx; ++ ++static void * ++threadproc (void *ctx) ++{ ++ while (1) ++ { ++ futex ((int *) &ftx, FUTEX_WAIT, 1, NULL, NULL, 0); ++ while (atomic_load (&ftx) !=3D 2) ++ { ++ if (atomic_load (&ftx) >=3D 3) ++ return NULL; ++ } ++ ++ /* clear LDT entry 0. */ ++ const struct user_desc desc =3D { 0 }; ++ xmodify_ldt (1, &desc, sizeof (desc)); ++ ++ /* If ftx =3D=3D 2, set it to zero, If ftx =3D=3D 100, quit. */ ++ if (atomic_fetch_add (&ftx, -2) !=3D 2) ++ return NULL; ++ } ++} ++ ++ ++/* As described in testcase, for historical reasons x86_32 Linux (and com= pat ++ on x86_64) interprets SA_RESTORER clear with nonzero sa_restorer as a ++ request for stack switching if the SS segment is 'funny' (this is defa= ult ++ scenario for vDSO system). This means that anything that tries to mix ++ signal handling with segmentation should explicit clear the sa_restore= r. ++ ++ This testcase check if sigaction in fact does it by changing the local ++ descriptor table (LDT) through the modify_ldt syscall and triggering ++ a synchronous segfault on iret fault by trying to install an invalid ++ segment. With a correct zeroed sa_restorer it should not trigger an ++ 'real' SEGSEGV and allows the siglongjmp in signal handler. */ ++ ++static int ++do_test (void) ++{ ++ setup_counter_page (); ++ setup_low_user_desc (); ++ ++ pthread_t thread; ++ unsigned short orig_ss; ++ ++ xsethandler (SIGSEGV, sigsegv_handler, 0); ++ /* 32-bit kernels send SIGILL instead of SIGSEGV on IRET faults. */ ++ xsethandler (SIGILL, sigsegv_handler, 0); ++ ++ thread =3D xpthread_create (0, threadproc, 0); ++ ++ asm volatile ("mov %%ss, %0" : "=3Drm" (orig_ss)); ++ ++ for (int i =3D 0; i < 5; i++) ++ { ++ if (sigsetjmp (jmpbuf, 1) !=3D 0) ++ continue; ++ ++ /* Make sure the thread is ready after the last test. */ ++ while (atomic_load (&ftx) !=3D 0) ++ ; ++ ++ struct user_desc desc =3D { ++ .entry_number =3D 0, ++ .base_addr =3D 0, ++ .limit =3D 0xffff, ++ .seg_32bit =3D 1, ++ .contents =3D 0, ++ .read_exec_only =3D 0, ++ .limit_in_pages =3D 1, ++ .seg_not_present =3D 0, ++ .useable =3D 0 ++ }; ++ ++ xmodify_ldt (0x11, &desc, sizeof (desc)); ++ ++ /* Arm the thread. */ ++ ftx =3D 1; ++ futex ((int*) &ftx, FUTEX_WAKE, 0, NULL, NULL, 0); ++ ++ asm volatile ("mov %0, %%ss" : : "r" (0x7)); ++ ++ /* Fire up thread modify_ldt call. */ ++ atomic_store (&ftx, 2); ++ ++ while (atomic_load (&ftx) !=3D 0) ++ ; ++ ++ /* On success, modify_ldt will segfault us synchronously and we will ++ escape via siglongjmp. */ ++ support_record_failure (); ++ } ++ ++ atomic_store (&ftx, 100); ++ futex ((int*) &ftx, FUTEX_WAKE, 0, NULL, NULL, 0); ++ ++ xpthread_join (thread); ++ ++ return 0; ++} ++ ++#include diff --git a/gnu/packages/patches/glibc-hidden-visibility-ldconfig.patch b/= gnu/packages/patches/glibc-hidden-visibility-ldconfig.patch new file mode 100644 index 000000000..c796946d7 =2D-- /dev/null +++ b/gnu/packages/patches/glibc-hidden-visibility-ldconfig.patch @@ -0,0 +1,16 @@ +Fix a regression in glibc 2.27 when built without ldconfig. See + for details. + +diff --git a/include/libc-symbols.h b/include/libc-symbols.h +index 6137304b0b..7d630f36d8 100644 +--- a/include/libc-symbols.h ++++ b/include/libc-symbols.h +@@ -508,7 +508,7 @@ for linking") + # ifndef __ASSEMBLER__ + # if !defined SHARED && IS_IN (libc) && !defined LIBC_NONSHARED \ + && (!defined PIC || !defined NO_HIDDEN_EXTERN_FUNC_IN_PIE) \ +- && !defined NO_HIDDEN ++ && !defined NO_HIDDEN && defined USE_LDCONFIG + # define __hidden_proto_hiddenattr(attrs...) \ + __attribute__ ((visibility ("hidden"), ##attrs)) + # define hidden_proto(name, attrs...) \ =2D-=20 2.16.2 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAlqxPMwACgkQoqBt8qM6 VPolLQgAlfebdovG+Swfd/ALvhoYBIAWt2Jkl77PB7UvoPgnQKU4R5SZ3r2sqe7f DErLf82FMmnQ9BsLgLC7UQWlsZrXtFubo0Ug/VHVRHqMpK8zqEIv2nJdoE7ezg/x nKaUvYDqa2fUCvooQN4KiJ3/Svy4LwxL1/aYPliDqh+3OPeV1+EGtX7HiHvc03ix BAwPjTA7ixRiCX5bsruGTaWmHEr+fBtw2M3FxfJ/AJZTJljIysuEh4OzlqQa1efP gFechABJ59BmzuTVH9g5P7Xh9iGPHFNNAXDozZ9LVKfQ3bIQjg/ALWeubWJcy2mY NUhNxAHeJOmaikH6d4yRepUgeYDCaw== =QHCr -----END PGP SIGNATURE----- --==-=-=--