From jakub@redhat.com Tue May 5 19:13:00 2009 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 05 May 2009 19:13:00 -0000 Subject: [PATCH] fstatat64 fixes Message-ID: <20090505192413.GE16681@sunsite.ms.mff.cuni.cz> Hi! With -Wsystem-headers I've noticed that gcc complains about fstatat64 declaring struct stat64 in the prototype. Seems unlike all the other *64 functions it wasn't protected with __USE_LARGEFILE64. Also, the inline wrapper uses different guard than the prototype (__USE_GNU vs. __USE_ATFILE). 2009-05-05 Jakub Jelinek * io/sys/stat.h (fstatat64): Guard prototype with __USE_LARGEFILE64, guard __extern_inline wrapper with __USE_ATFILE instead of __USE_GNU. --- libc/io/sys/stat.h.jj 2009-03-02 16:43:58.000000000 +0100 +++ libc/io/sys/stat.h 2009-05-05 21:05:36.000000000 +0200 @@ -249,9 +249,11 @@ extern int __REDIRECT_NTH (fstatat, (int # endif # endif +# ifdef __USE_LARGEFILE64 extern int fstatat64 (int __fd, __const char *__restrict __file, struct stat64 *__restrict __buf, int __flag) __THROW __nonnull ((2, 3)); +# endif #endif #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K @@ -516,7 +518,7 @@ __NTH (fstat64 (int __fd, struct stat64 return __fxstat64 (_STAT_VER, __fd, __statbuf); } -# ifdef __USE_GNU +# ifdef __USE_ATFILE __extern_inline int __NTH (fstatat64 (int __fd, __const char *__filename, struct stat64 *__statbuf, int __flag)) Jakub From jakub@redhat.com Sat May 9 08:13:00 2009 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 09 May 2009 08:13:00 -0000 Subject: [PATCH] Test in stratcliff for zero length at the end of the cliff Message-ID: <20090509082505.GG16681@sunsite.ms.mff.cuni.cz> Hi! With this patch we'd know that memchr on x86_64 has a problem, better test it on all functions where we don't test it ATM and which have a length argument and shouldn't dereference the pointer at all in that case. 2009-05-09 Jakub Jelinek * string/stratcliff.c (do_test): Test for zero length STRNLEN, MEMCHR, STRNCPY, STPNCPY, MEMCPY, MEMPCPY and memccpy at the end of the page. --- libc/string/stratcliff.c.jj 2009-04-08 21:32:54.000000000 +0200 +++ libc/string/stratcliff.c 2009-05-09 10:06:22.000000000 +0200 @@ -129,10 +129,10 @@ do_test (void) } for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) { - for (inner = MAX (outer, nchars - 64); inner < nchars; ++inner) + for (inner = MAX (outer, nchars - 64); inner <= nchars; ++inner) { - if (STRNLEN (&adr[outer], inner - outer + 1) - != (size_t) (inner - outer + 1)) + if (STRNLEN (&adr[outer], inner - outer) + != (size_t) (inner - outer)) { printf ("%s flunked bounded for outer = %d, inner = %d\n", STRINGIFY (STRNLEN), outer, inner); @@ -225,7 +225,7 @@ do_test (void) adr[middle] = L('T'); } } - for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) + for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) { CHAR *cp = MEMCHR (&adr[outer], L('V'), nchars - outer); @@ -279,9 +279,9 @@ do_test (void) } } - /* strncpy tests */ + /* strncpy/wcsncpy tests */ adr[nchars - 1] = L('T'); - for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) + for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) { size_t len; @@ -355,6 +355,24 @@ do_test (void) } /* stpncpy/wcpncpy test */ + adr[nchars - 1] = L('T'); + for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) + { + size_t len; + + for (len = 0; len < nchars - outer; ++len) + { + if (STPNCPY (dest, &adr[outer], len) != dest + len + || MEMCMP (dest, &adr[outer], len) != 0) + { + printf ("outer %s flunked for outer = %d, len = %Zd\n", + STRINGIFY (STPNCPY), outer, len); + result = 1; + } + } + } + adr[nchars - 1] = L('\0'); + for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) { for (middle = MAX (outer, nchars - 64); middle < nchars; ++middle) @@ -378,7 +396,7 @@ do_test (void) } /* memcpy/wmemcpy test */ - for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) + for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) for (inner = 0; inner < nchars - outer; ++inner) if (MEMCPY (dest, &adr[outer], inner) != dest) { @@ -388,7 +406,7 @@ do_test (void) } /* mempcpy/wmempcpy test */ - for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) + for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) for (inner = 0; inner < nchars - outer; ++inner) if (MEMPCPY (dest, &adr[outer], inner) != dest + inner) { @@ -401,7 +419,7 @@ do_test (void) #ifndef WCSTEST /* memccpy test */ memset (adr, '\0', nchars); - for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) + for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) for (inner = 0; inner < nchars - outer; ++inner) if (memccpy (dest, &adr[outer], L('\1'), inner) != NULL) { Jakub From jakub@redhat.com Tue May 12 08:08:00 2009 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 12 May 2009 08:08:00 -0000 Subject: [PATCH] Small include/atomic.h cleanup Message-ID: <20090512081925.GJ16681@sunsite.ms.mff.cuni.cz> Hi! While looking at catomic_* definitions I've noticed that even if bits/atomic.h defined catomic_compare_and_exchange_val_acq, include/atomic.h would override it anyway. 2009-05-12 Jakub Jelinek * include/atomic.h: Formatting. (catomic_compare_and_exchange_val_acq): Don't define if already defined by bits/atomic.h. --- libc/include/atomic.h.jj 2009-02-16 14:47:25.000000000 +0100 +++ libc/include/atomic.h 2009-05-12 09:58:22.000000000 +0200 @@ -95,14 +95,15 @@ #endif -#if !defined catomic_compare_and_exchange_val_acq \ - && defined __arch_c_compare_and_exchange_val_32_acq -# define catomic_compare_and_exchange_val_acq(mem, newval, oldval) \ +#ifndef catomic_compare_and_exchange_val_acq +# ifdef __arch_c_compare_and_exchange_val_32_acq +# define catomic_compare_and_exchange_val_acq(mem, newval, oldval) \ __atomic_val_bysize (__arch_c_compare_and_exchange_val,acq, \ mem, newval, oldval) -#else -# define catomic_compare_and_exchange_val_acq(mem, newval, oldval) \ +# else +# define catomic_compare_and_exchange_val_acq(mem, newval, oldval) \ atomic_compare_and_exchange_val_acq (mem, newval, oldval) +# endif #endif @@ -125,8 +126,8 @@ # define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ __atomic_bool_bysize (__arch_compare_and_exchange_bool,acq, \ mem, newval, oldval) -# else -# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ +# else +# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ ({ /* Cannot use __oldval here, because macros later in this file might \ call this macro with __oldval argument. */ \ __typeof (oldval) __atg3_old = (oldval); \ @@ -142,8 +143,8 @@ # define catomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ __atomic_bool_bysize (__arch_c_compare_and_exchange_bool,acq, \ mem, newval, oldval) -# else -# define catomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ +# else +# define catomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ ({ /* Cannot use __oldval here, because macros later in this file might \ call this macro with __oldval argument. */ \ __typeof (oldval) __atg4_old = (oldval); \ Jakub From jakub@redhat.com Wed May 13 23:19:00 2009 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 13 May 2009 23:19:00 -0000 Subject: [PATCH] Fix fallocate64 on 32-bit arches Message-ID: <20090513233135.GL16681@sunsite.ms.mff.cuni.cz> Hi! Due to a pasto only 64-bit glibc exports fallocate64@@GLIBC_2.10, 32-bit glibc does not (therefore programs using fallocate compiled with -D_FILE_OFFSET_BITS=64 fail to link). The following patch attempts to fix it by fixing the 2 pastos and exporting the function @@GLIBC_2.11 for 32-bit libc.so (and keeping it at @@GLIBC_2.10 for 64-bit). 2009-05-14 Jakub Jelinek * Versions.def (libc): Add GLIBC_2.11. * sysdeps/unix/sysv/linux/i386/fallocate64.c (__fallocate64_l64): Rename ... (fallocate64): ... to this. * sysdeps/unix/sysv/linux/fallocate64.c (__fallocate64_l64): Rename ... (fallocate64): ... to this. * sysdeps/unix/sysv/linux/Versions (libc): Remove fallocate64. * sysdeps/unix/sysv/linux/wordsize-64/Versions (libc): Add fallocate64@@GLIBC_2.10. * sysdeps/unix/sysv/linux/i386/Versions (libc): Add fallocate64@@GLIBC_2.11. * sysdeps/unix/sysv/linux/s390/s390-32/Versions (libc): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/Versions (libc): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/Versions (libc): Likewise. * sysdeps/unix/sysv/linux/sh/Versions (libc): Likewise. --- libc/Versions.def.jj 2008-12-09 10:58:34.000000000 +0100 +++ libc/Versions.def 2009-05-14 00:50:12.000000000 +0200 @@ -27,6 +27,7 @@ libc { GLIBC_2.8 GLIBC_2.9 GLIBC_2.10 + GLIBC_2.11 %ifdef USE_IN_LIBIO HURD_CTHREADS_0.3 %endif --- libc/sysdeps/unix/sysv/linux/i386/fallocate64.c.jj 2009-03-02 17:10:29.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/i386/fallocate64.c 2009-05-14 00:46:30.000000000 +0200 @@ -26,7 +26,7 @@ extern int __call_fallocate (int fd, int /* Reserve storage for the data of the file associated with FD. */ int -__fallocate64_l64 (int fd, int mode, __off64_t offset, __off64_t len) +fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) { return __call_fallocate (fd, mode, offset, len); } --- libc/sysdeps/unix/sysv/linux/i386/Versions.jj 2004-02-09 22:46:35.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/i386/Versions 2009-05-14 01:06:58.000000000 +0200 @@ -41,6 +41,10 @@ libc { # v* vm86; } + GLIBC_2.11 { + # f* + fallocate64; + } GLIBC_PRIVATE { __modify_ldt; } --- libc/sysdeps/unix/sysv/linux/s390/s390-32/Versions.jj 2008-08-13 14:03:30.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/s390/s390-32/Versions 2009-05-14 01:07:52.000000000 +0200 @@ -43,6 +43,9 @@ libc { getutmp; getutmpx; } + GLIBC_2.11 { + fallocate64; + } } libutil { --- libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/Versions.jj 2004-01-16 05:45:46.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/Versions 2009-05-14 01:07:25.000000000 +0200 @@ -27,4 +27,7 @@ libc { GLIBC_2.3.4 { setcontext; getcontext; swapcontext; makecontext; } + GLIBC_2.11 { + fallocate64; + } } --- libc/sysdeps/unix/sysv/linux/fallocate64.c.jj 2009-04-22 15:07:19.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/fallocate64.c 2009-05-14 00:45:40.000000000 +0200 @@ -23,7 +23,7 @@ /* Reserve storage for the data of the file associated with FD. */ int -__fallocate64_l64 (int fd, int mode, __off64_t offset, __off64_t len) +fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) { #ifdef __NR_fallocate return INLINE_SYSCALL (fallocate, 6, fd, mode, --- libc/sysdeps/unix/sysv/linux/Versions.jj 2009-05-14 01:05:17.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/Versions 2009-05-14 01:05:31.000000000 +0200 @@ -139,7 +139,7 @@ libc { epoll_create1; inotify_init1; } GLIBC_2.10 { - fallocate; fallocate64; + fallocate; } GLIBC_PRIVATE { # functions used in other libraries --- libc/sysdeps/unix/sysv/linux/wordsize-64/Versions.jj 2009-05-14 01:05:50.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/wordsize-64/Versions 2009-05-14 01:06:09.000000000 +0200 @@ -0,0 +1,5 @@ +libc { + GLIBC_2.10 { + fallocate64; + } +} --- libc/sysdeps/unix/sysv/linux/sparc/sparc32/Versions.jj 2006-01-14 13:29:20.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/Versions 2009-05-14 01:08:48.000000000 +0200 @@ -20,4 +20,7 @@ libc { GLIBC_2.3.3 { posix_fadvise64; posix_fallocate64; } + GLIBC_2.11 { + fallocate64; + } } --- libc/sysdeps/unix/sysv/linux/sh/Versions.jj 2003-09-01 06:05:09.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/sh/Versions 2009-05-14 01:08:35.000000000 +0200 @@ -24,4 +24,7 @@ libc { GLIBC_2.3.3 { posix_fadvise64; posix_fallocate64; } + GLIBC_2.11 { + fallocate64; + } } Jakub From jakub@redhat.com Wed May 13 23:22:00 2009 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 13 May 2009 23:22:00 -0000 Subject: [PATCH] Fix nscd -K Message-ID: <20090513233319.GM16681@sunsite.ms.mff.cuni.cz> Hi! When nscd runs with SELinux enabled, running nscd -K might segfault the daemon before exit, because avc_destroy is called in the thread calling termination_handler, but other threads might be busy doing other stuff and possibly calling something that expects the avc not to be destroyed yet. 2009-05-14 Jakub Jelinek * nscd/selinux.c (nscd_avc_destroy): Removed. * nscd/selinux.h (nscd_avc_destroy): Likewise. * nscd/nscd.c (termination_handler): Don't call nscd_avc_destroy. --- libc/nscd/nscd.c.jj 2009-02-16 14:47:30.000000000 +0100 +++ libc/nscd/nscd.c 2009-05-14 01:13:59.000000000 +0200 @@ -488,10 +488,6 @@ termination_handler (int signum) msync (dbs[cnt].head, dbs[cnt].memsize, MS_ASYNC); } - /* Shutdown the SELinux AVC. */ - if (selinux_enabled) - nscd_avc_destroy (); - _exit (EXIT_SUCCESS); } --- libc/nscd/selinux.c.jj 2007-12-10 09:05:34.000000000 +0100 +++ libc/nscd/selinux.c 2009-05-14 01:15:02.000000000 +0200 @@ -1,5 +1,5 @@ /* SELinux access controls for nscd. - Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Matthew Rickard , 2004. @@ -418,15 +418,4 @@ nscd_avc_print_stats (struct avc_cache_s cstats->cav_probes, cstats->cav_misses); } - -/* Clean up the AVC before exiting. */ -void -nscd_avc_destroy (void) -{ - avc_destroy (); -#ifdef HAVE_LIBAUDIT - audit_close (audit_fd); -#endif -} - #endif /* HAVE_SELINUX */ --- libc/nscd/selinux.h.jj 2007-04-23 10:54:02.000000000 +0200 +++ libc/nscd/selinux.h 2009-05-14 01:14:40.000000000 +0200 @@ -1,5 +1,5 @@ /* Header for nscd SELinux access controls. - Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Matthew Rickard , 2004. @@ -35,8 +35,6 @@ struct avc_cache_stats; /* Initialize the userspace AVC. */ extern void nscd_avc_init (void); -/* Destroy the userspace AVC. */ -extern void nscd_avc_destroy (void); /* Determine if we are running on an SELinux kernel. */ extern void nscd_selinux_enabled (int *selinux_enabled); /* Check if the client has permission for the request type. */ @@ -55,7 +53,6 @@ extern void install_real_capabilities (c #else # define selinux_enabled 0 # define nscd_avc_init() (void) 0 -# define nscd_avc_destroy() (void) 0 # define nscd_selinux_enabled(selinux_enabled) (void) 0 # define nscd_request_avc_has_perm(fd, req) 0 # define nscd_avc_cache_stats(cstats) (void) 0 Jakub From roland@redhat.com Thu May 14 00:40:00 2009 From: roland@redhat.com (Roland McGrath) Date: Thu, 14 May 2009 00:40:00 -0000 Subject: git repository conventions Message-ID: <20090514004039.E8339FC35D@magilla.sf.frob.com> The final format conversion is still being hashed out and we do not yet have a git repository that receives any git commits. But it's time now to start working out the conventions for using the git repository in the future. Once the git repository is ready technically, we'll start with the only real status quo convention we have: the only active branch is 'master', and the only pushes to it will by those who did CVS trunk commits in the old practice. The new rules for future practice will be hashed out by our discussion here, nothing much is decided yet. The historical branches and tags from CVS have their CVS names prefixed with 'cvs/' in the git repository. After the final format conversion, these will stick around forever as history, but never be changed again. If any of those old branches get used in the future, we'll start that by copying the cvs/branch tip's commit id to a new branch name based on the new conventions we work out. We'll make back-dated, signed git tags for all the past released versions. Here are my proposals for naming and access conventions for future work. Commence debate. The cardinal rule of the glibc repository is that all commits must be covered by proper copyright assignment paperwork already on file with the FSF. If you cannot attest that the changes' authors have all their paperwork in order, then do not make the commit. Do not pull/merge someone else's git tree unless you are sure they are following these rules. Someone who says they intend to submit paperwork does not count. If the paperwork is not in and verified already, don't use the code. If you have done any pulls/merges from other people, you are responsible for being absolutely sure all the commit history you pulled in was properly covered before you do any git push or ask another libc maintainer to do a pull from your outside server. These rules apply to the entire glibc repository, all branches, including any private branches, and including all commit history, everything that is in the sourceware glibc.git in any way, shape, or form. This is the one rule that is nonnegotiable and is not open for debate. If you don't like it, don't ever expect to push to this repository or have one of its maintainers pull from yours. First point: private branches and tags. Everyone with repository write access is free to have private branches and tags, subject to the cardinal rule about copyright status. The branch names 'yourname/*' and the tag names 'yourname/*' are free to use however you like, where 'yourname' is your username on sourceware. We expect some sensible discretion in not using our repository for things that don't make a lot of sense. We expect folks to clean out their old private branches (e.g. delete a useless old one with "git push origin :roland/foobar") when they are no longer useful. (We will eventually do some "git gc" operations on the repository, so the old history of removed branches will be unrecoverably lost if you don't save them yourself.) Don't make a lot of stupid private branch names that just track another branch, because they all show up in gitweb. GIT makes it easy to fork a repository from the glibc one and publish your own entwined repository with your own branches on your own servers. People without permissions on sourceware can do this and have libc maintainers pull from their trees. Private branches in the canonical glibc repository on sourceware are provided to make it easier for the whole glibc community to notice and follow your work, or if it's a pain to publish elsewhere. Second point: "official" tags. The only purpose I see off hand for top-level tag names is for our official releases. These will have names like "glibc-2.10.1", and be signed tags (git tag -s). As I mentioned, we'll retroactively make back-dated tags like this for all the old official release versions. Third point: shared community/distro branches and tags. Like each user's private branches and tags, there can be 'prefix/*' branches and tags shared by those working on the 'prefix' project. These prefixes will be approved by consensus here, and the active set documented on the wiki. The only one we already know will be actively used is 'fedora/*'; Jakub owns that name space, though I expect to work out some specific conventions with him. Last point: release branches. There has not been any actual procedure for release branches operating in recent memory. Perhaps we'll get it together for a real one of these days. If we had one, then the naming convention I'd think we want is this: 'release/x.y/*' prefix, with the "main" release branch being 'release/x.y/master', e.g. 'release/2.10/master'. This leaves the way open for 'release/x.y/blahblah' branches, which will likely be useful for collaborative work on stable branch releases (if that ever happens). The nature of GIT makes it easy to add, change, and rename branches later. The branches and their names are not really part of the commit history. So, aside from signed tags, this is a bit more fungible in the future than were CVS conventions. Nonetheless, I think we should give a little though to agreeing to GIT naming conventions that will serve us in the future. Thanks, Roland From roland@redhat.com Fri May 15 20:17:00 2009 From: roland@redhat.com (Roland McGrath) Date: Fri, 15 May 2009 20:17:00 -0000 Subject: git cvs/ tags Message-ID: <20090515201722.2DBF9FC35D@magilla.sf.frob.com> So now we have the git repository. All hail the git repository. Thanks, Jim! But we have a couple of lingering issues from the CVS conversion. There was no cvs/ head that corresponded to the last CVS commit. I made one by hand, called cvs/master. The head master-UNNAMED-BRANCH existed for some reason, not under cvs/. It was 7ce88cbdc45a8fb68c5cd1b69d95dee9b11913ee. I removed it. Is this some abandoned wrong-converted history? Its log entry matches that for d585b66fa4d11059948f466c9080a6826932358d. 'git describe' can find nothing for either of these commits, which is odd. d585b66fa4d11059948f466c9080a6826932358d is in the history of cvs/fedora-2_3-branch. We have no git tags at all. What happened to our cvs/* migrated tags? That is a bunch of lost information, including the exact points in history of various past releases, Fedora builds, etc. What gives? Thanks, Roland From roland@redhat.com Fri May 15 22:02:00 2009 From: roland@redhat.com (Roland McGrath) Date: Fri, 15 May 2009 22:02:00 -0000 Subject: git cvs/ tags In-Reply-To: Jim Meyering's message of Friday, 15 May 2009 23:54:55 +0200 <874ovm6ngw.fsf@meyering.net> References: <20090515201722.2DBF9FC35D@magilla.sf.frob.com> <874ovm6ngw.fsf@meyering.net> Message-ID: <20090515220233.5C77CFC35D@magilla.sf.frob.com> > Blush. I forgot to push those. It's a separate step. Great! Thanks, Roland From jakub@redhat.com Mon May 18 06:48:00 2009 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 18 May 2009 06:48:00 -0000 Subject: [PATCH] Fix nscd_helper.c Message-ID: <20090518070057.GO16681@sunsite.ms.mff.cuni.cz> Hi! Adding datalen in __nscd_cache_search is IMHO not correct, some databases contain mixed type of entries (group contains grp and initgr, hosts hst and ai responses, which have different datalen). Additionally some databases share one datahead with up to two hashentries and in __nscd_cache_search we want a safe upper bound for number of hash entries. So, IMHO the right computation is one hashentry and half of a datahead, without any payload (or with minimum of payloads, but that doesn't make a very big difference). Additionally, using sizeof (struct hashentry) in nscd client looks wrong to me. What if a 64-bit program using nscd client is run against 32-bit nscd? The last union in struct hashentry contains a pointer, if mempool_alloc allocates the hashentry at the very end of memory, the 64-bit client would consider it to be out of range. 2009-05-18 Jakub Jelinek * nscd/nscd_helper.c (__nscd_cache_search): Assume each entry in the hash chain needs one hashentry and half of datahead. Use offseof instead of sizeof for struct hashentry. diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index c09f008..bddf3d2 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -481,10 +481,12 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, ref_t trail = mapped->head->array[hash]; trail = atomic_forced_read (trail); ref_t work = trail; - size_t loop_cnt = datasize / (offsetof (struct datahead, data) + datalen); + size_t loop_cnt = datasize / (offsetof (struct hashentry, dellist) + + offsetof (struct datahead, data) / 2); int tick = 0; - while (work != ENDREF && work + sizeof (struct hashentry) <= datasize) + while (work != ENDREF + && work + offsetof (struct hashentry, dellist) <= datasize) { struct hashentry *here = (struct hashentry *) (mapped->data + work); ref_t here_key, here_packet; @@ -541,7 +543,7 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, return NULL; #endif - if (trail + sizeof (struct hashentry) > datasize) + if (trail + offsetof (struct hashentry, dellist) > datasize) return NULL; trail = atomic_forced_read (trailelem->next); Jakub From kkojima@rr.iij4u.or.jp Mon May 18 21:56:00 2009 From: kkojima@rr.iij4u.or.jp (Kaz Kojima) Date: Mon, 18 May 2009 21:56:00 -0000 Subject: [PATCH] SH: Add ____longjmp_chk Message-ID: <20090519.065516.185940009.kkojima@rr.iij4u.or.jp> Hi, The attached patch is to add an SH version of ____longjmp_chk which was done for x86 and x86_64 recently. Regards, kaz -- 2009-05-18 Kaz Kojima * sysdeps/sh/____longjmp_chk.S: New file. * sysdeps/sh/sh3/__longjmp.S: If CHECK_SP is defined, use it. * sysdeps/sh/sh4/__longjmp.S: Likewise. diff --git a/sysdeps/sh/____longjmp_chk.S b/sysdeps/sh/____longjmp_chk.S new file mode 100644 index 0000000..e17c1c2 --- /dev/null +++ b/sysdeps/sh/____longjmp_chk.S @@ -0,0 +1,70 @@ +/* Copyright (C) 2009 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + + .section .rodata.str1.1,"aMS",@progbits,1 + .type longjmp_msg,@object +longjmp_msg: + .string "longjmp causes uninitialized stack frame" + .size longjmp_msg, .-longjmp_msg + .text + +#define __longjmp ____longjmp_chk + +#ifdef PIC +# define CALL_FAIL \ + mov.l .Lfail, r1; \ + mov.l .Lstr, r4; \ + mova .Lgot, r0; \ + mov.l .Lgot, r12; \ + add r0, r12; \ + bsrf r1; \ + add r12, r4; \ +.Lfail0: \ + bra 0f; \ + nop; \ + .align 2; \ +.Lgot: \ + .long _GLOBAL_OFFSET_TABLE_; \ +.Lstr: \ + .long longjmp_msg@GOTOFF; \ +.Lfail: \ + .long __GI___fortify_fail@PLT-(.Lfail0-.); \ +0: +#else +# define CALL_FAIL \ + mov.l .Lfail, r1; \ + mov.l .Lstr, r4; \ + jsr @r1; \ + nop; \ + bra 0f; \ + nop; \ + .align 2; \ +.Lstr: \ + .long longjmp_msg; \ +.Lfail: \ + .long __fortify_fail; \ +0: +#endif + +#define CHECK_SP(reg) \ + cmp/hs r15, reg; \ + bt .Lok; \ + CALL_FAIL \ +.Lok: + +#include "__longjmp.S" diff --git a/sysdeps/sh/sh3/__longjmp.S b/sysdeps/sh/sh3/__longjmp.S index c6d8a32..8c84aff 100644 --- a/sysdeps/sh/sh3/__longjmp.S +++ b/sysdeps/sh/sh3/__longjmp.S @@ -1,5 +1,5 @@ /* longjmp for SH. - Copyright (C) 1999, 2000, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2005, 2006, 2009 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 @@ -42,6 +42,9 @@ ENTRY (__longjmp) mov r2, r14 mov.l @r4+, r2 PTR_DEMANGLE2 (r2, r1) +# ifdef CHECK_SP + CHECK_SP (r2) +# endif mov r2, r15 mov.l @r4+, r2 PTR_DEMANGLE2 (r2, r1) @@ -49,6 +52,10 @@ ENTRY (__longjmp) mov #0, r1 #else mov.l @r4+, r14 +# ifdef CHECK_SP + mov.l @r4, r2 + CHECK_SP (r2) +# endif mov.l @r4+, r15 lds.l @r4+, pr #endif diff --git a/sysdeps/sh/sh4/__longjmp.S b/sysdeps/sh/sh4/__longjmp.S index 2fd137b..f2e4b75 100644 --- a/sysdeps/sh/sh4/__longjmp.S +++ b/sysdeps/sh/sh4/__longjmp.S @@ -42,6 +42,9 @@ ENTRY (__longjmp) mov r2, r14 mov.l @r4+, r2 PTR_DEMANGLE2 (r2, r1) +# ifdef CHECK_SP + CHECK_SP (r2) +# endif mov r2, r15 mov.l @r4+, r2 PTR_DEMANGLE2 (r2, r1) @@ -49,6 +52,10 @@ ENTRY (__longjmp) mov #0, r1 #else mov.l @r4+, r14 +# ifdef CHECK_SP + mov.l @r4, r2 + CHECK_SP (r2) +# endif mov.l @r4+, r15 lds.l @r4+, pr #endif From drepper@redhat.com Mon May 18 22:46:00 2009 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 18 May 2009 22:46:00 -0000 Subject: [PATCH] SH: Add ____longjmp_chk In-Reply-To: <20090519.065516.185940009.kkojima@rr.iij4u.or.jp> References: <20090519.065516.185940009.kkojima@rr.iij4u.or.jp> Message-ID: <4A11E542.9020608@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Applied with on little change: you want #include <...> not "...". - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkoR5UIACgkQ2ijCOnn/RHTJagCdG1R16a8wno7V2e0RrXxbuJP7 wlYAn0OlOrYTW/zoloLIs9Qk3H4G1h1S =0QAd -----END PGP SIGNATURE----- From kkojima@rr.iij4u.or.jp Mon May 18 23:45:00 2009 From: kkojima@rr.iij4u.or.jp (Kaz Kojima) Date: Mon, 18 May 2009 23:45:00 -0000 Subject: [PATCH] SH: Add ____longjmp_chk In-Reply-To: <4A11E542.9020608@redhat.com> References: <20090519.065516.185940009.kkojima@rr.iij4u.or.jp> <4A11E542.9020608@redhat.com> Message-ID: <20090519.084435.143020238.kkojima@rr.iij4u.or.jp> Ulrich Drepper wrote: > Applied with on little change: you want #include <...> not "...". Thanks! Regards, kaz From jakub@redhat.com Fri May 22 09:15:00 2009 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 22 May 2009 09:15:00 -0000 Subject: [PATCH] Add accept4 on most architectures Message-ID: <20090522091356.GA30565@sunsite.ms.mff.cuni.cz> Hi! This patch adds accept4 support for powerpc{32,64}, s390{,x}, sh, etc. Tested on powerpc, with --enable-kernel=2.6.9 as well as --enable-kernel=2.6.28 build and for the former also running on 2.6.18 kernel. 2009-05-22 Jakub Jelinek * sysdeps/unix/sysv/linux/accept4.c: Include kernel-features.h. (accept4): If __NR_accept4 is not defined, but __NR_socketcall is, either do nothing at all if __ASSUME_ACCEPT4, or call __internal_accept4 and handle EINVAL -> ENOSYS translation. * sysdeps/unix/sysv/linux/internal_accept4.S: New file. * sysdeps/unix/sysv/linux/i386/accept4.S (SOCKOP_accept4): Don't define. * sysdeps/unix/sysv/linux/i386/internal_accept4.S: New file. * sysdeps/unix/sysv/linux/Makefile (sysdep-routines): Add internal_accept4 in socket directory. --- libc/sysdeps/unix/sysv/linux/internal_accept4.S.jj 2009-05-22 09:01:54.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/internal_accept4.S 2009-05-22 09:05:31.000000000 +0200 @@ -0,0 +1,14 @@ +#include +#include +#if !defined __NR_accept4 && defined __NR_socketcall +# define socket accept4 +# ifdef __ASSUME_ACCEPT4 +# define __socket accept4 +# else +# define __socket __internal_accept4 +# endif +# define NARGS 4 +# define NEED_CANCELLATION +# define NO_WEAK_ALIAS +# include +#endif --- libc/sysdeps/unix/sysv/linux/i386/accept4.S.jj 2009-05-16 19:23:44.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/i386/accept4.S 2009-05-22 09:11:04.000000000 +0200 @@ -24,10 +24,6 @@ #define EINVAL 22 #define ENOSYS 38 -#ifndef SOCKOP_accept4 -# define SOCKOP_accept4 18 -#endif - #ifdef __ASSUME_ACCEPT4 # define errlabel SYSCALL_ERROR_LABEL #else --- libc/sysdeps/unix/sysv/linux/i386/internal_accept4.S.jj 2009-05-22 09:10:30.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/i386/internal_accept4.S 2009-05-22 09:10:24.000000000 +0200 @@ -0,0 +1 @@ +/* Not needed, accept4.S has everything. */ --- libc/sysdeps/unix/sysv/linux/Makefile.jj 2009-05-16 19:23:44.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/Makefile 2009-05-22 09:07:05.000000000 +0200 @@ -11,6 +11,10 @@ ifeq ($(subdir),malloc) CFLAGS-malloc.c += -DMORECORE_CLEARS=2 endif +ifeq ($(subdir),socket) +sysdep_routines += internal_accept4 +endif + ifeq ($(subdir),misc) sysdep_routines += sysctl clone llseek umount umount2 readahead \ setfsuid setfsgid makedev epoll_pwait signalfd \ --- libc/sysdeps/unix/sysv/linux/accept4.c.jj 2009-05-22 08:47:29.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/accept4.c 2009-05-22 09:24:48.000000000 +0200 @@ -23,6 +23,7 @@ #include #include +#include #ifdef __NR_accept4 @@ -41,6 +42,50 @@ accept4 (int fd, __SOCKADDR_ARG addr, so return result; } +#elif defined __NR_socketcall +# ifndef __ASSUME_ACCEPT4 +extern int __internal_accept4 (int fd, __SOCKADDR_ARG addr, + socklen_t *addr_len, int flags) + attribute_hidden; + +static int have_accept4; + +int +accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) +{ + if (__builtin_expect (have_accept4 >= 0, 1)) + { + int ret = __internal_accept4 (fd, addr, addr_len, flags); + /* The kernel returns -EINVAL for unknown socket operations. + We need to convert that error to an ENOSYS error. */ + if (__builtin_expect (ret < 0, 0) + && have_accept4 == 0 + && errno == EINVAL) + { + /* Try another call, this time with the FLAGS parameter + cleared and an invalid file descriptor. This call will not + cause any harm and it will return immediately. */ + ret = __internal_accept4 (-1, addr, addr_len, 0); + if (errno == EINVAL) + { + have_accept4 = -1; + __set_errno (ENOSYS); + } + else + { + have_accept4 = 1; + __set_errno (EINVAL); + } + return -1; + } + return ret; + } + __set_errno (ENOSYS); + return -1; +} +# else +/* When __ASSUME_ACCEPT4 accept4 is defined in internal_accept4.S. */ +# endif #else int accept4 (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags) From drepper@redhat.com Fri May 22 15:34:00 2009 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 22 May 2009 15:34:00 -0000 Subject: [PATCH] Add accept4 on most architectures In-Reply-To: <20090522091356.GA30565@sunsite.ms.mff.cuni.cz> References: <20090522091356.GA30565@sunsite.ms.mff.cuni.cz> Message-ID: <4A16C5F8.2020709@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Applied. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkoWxfgACgkQ2ijCOnn/RHS0gACgynUROcizKNhdMCxMm//WDUof WikAoKc1mGrEnhu1axX804E99ZP3TfSh =VQ2f -----END PGP SIGNATURE----- From jakub@redhat.com Fri May 29 17:11:00 2009 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 29 May 2009 17:11:00 -0000 Subject: [PATCH] Fix math/test-{ldouble,ildoubl} failures on s390{,x}, sparc{,64} and alpha Message-ID: <20090529171130.GB3101@sunsite.ms.mff.cuni.cz> Hi! Similar patch to what Andreas posted for ppc long double, this time for IEEE quad. Tested on s390{,x}-linux. 2009-05-29 Jakub Jelinek * sysdeps/ieee754/ldbl-128/s_expm1l.c: Include . (__expm1l): Set errno to ERANGE on overflow. * sysdeps/ieee754/ldbl-128/s_tanl.c: Include . (__tanl): Set errno to EDOM for ????Inf. * sysdeps/ieee754/ldbl-128/s_cosl.c: Include . (__cosl): Set errno to EDOM for ????Inf. * sysdeps/ieee754/ldbl-128/s_sinl.c: Include . (__sinl): Set errno to EDOM for ????Inf. --- libc/sysdeps/ieee754/ldbl-128/s_expm1l.c.jj 2009-05-16 13:23:38.000000000 -0400 +++ libc/sysdeps/ieee754/ldbl-128/s_expm1l.c 2009-05-29 12:09:10.000000000 -0400 @@ -53,6 +53,7 @@ +#include #include "math.h" #include "math_private.h" @@ -121,7 +122,10 @@ __expm1l (long double x) /* Overflow. */ if (x > maxlog) - return (big * big); + { + __set_errno (ERANGE); + return (big * big); + } /* Minimum value. */ if (x < minarg) --- libc/sysdeps/ieee754/ldbl-128/s_tanl.c.jj 2009-05-16 13:23:38.000000000 -0400 +++ libc/sysdeps/ieee754/ldbl-128/s_tanl.c 2009-05-29 12:28:12.000000000 -0400 @@ -44,6 +44,7 @@ * TRIG(x) returns trig(x) nearly rounded */ +#include #include "math.h" #include "math_private.h" @@ -65,7 +66,14 @@ if(ix <= 0x3ffe921fb54442d1LL) return __kernel_tanl(x,z,1); /* tanl(Inf or NaN) is NaN */ - else if (ix>=0x7fff000000000000LL) return x-x; /* NaN */ + else if (ix>=0x7fff000000000000LL) { + if (ix == 0x7fff000000000000LL) { + GET_LDOUBLE_LSW64(n,x); + if (n == 0) + __set_errno (EDOM); + } + return x-x; /* NaN */ + } /* argument reduction needed */ else { --- libc/sysdeps/ieee754/ldbl-128/s_cosl.c.jj 2009-05-16 13:23:38.000000000 -0400 +++ libc/sysdeps/ieee754/ldbl-128/s_cosl.c 2009-05-29 12:27:45.000000000 -0400 @@ -44,6 +44,7 @@ * TRIG(x) returns trig(x) nearly rounded */ +#include #include "math.h" #include "math_private.h" @@ -66,7 +67,14 @@ return __kernel_cosl(x,z); /* cos(Inf or NaN) is NaN */ - else if (ix>=0x7fff000000000000LL) return x-x; + else if (ix>=0x7fff000000000000LL) { + if (ix == 0x7fff000000000000LL) { + GET_LDOUBLE_LSW64(n,x); + if (n == 0) + __set_errno (EDOM); + } + return x-x; + } /* argument reduction needed */ else { --- libc/sysdeps/ieee754/ldbl-128/s_sinl.c.jj 2009-05-16 13:23:38.000000000 -0400 +++ libc/sysdeps/ieee754/ldbl-128/s_sinl.c 2009-05-29 12:27:27.000000000 -0400 @@ -44,6 +44,7 @@ * TRIG(x) returns trig(x) nearly rounded */ +#include #include "math.h" #include "math_private.h" @@ -66,7 +67,14 @@ return __kernel_sinl(x,z,0); /* sin(Inf or NaN) is NaN */ - else if (ix>=0x7fff000000000000LL) return x-x; + else if (ix>=0x7fff000000000000LL) { + if (ix == 0x7fff000000000000LL) { + GET_LDOUBLE_LSW64(n,x); + if (n == 0) + __set_errno (EDOM); + } + return x-x; + } /* argument reduction needed */ else { Jakub From jakub@redhat.com Fri May 29 17:11:00 2009 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 29 May 2009 17:11:00 -0000 Subject: [PATCH] Fix s390{,x} build Message-ID: <20090529171010.GA3101@sunsite.ms.mff.cuni.cz> Hi! This patch makes s390{,x} glibc compile again by defining ____longjmp_chk. Tested on s390{,x}-linux. 2009-05-29 Jakub Jelinek * sysdeps/s390/s390-32/__longjmp.c (__longjmp): If CHECK_SP is defined, use it. * sysdeps/s390/s390-64/__longjmp.c (__longjmp): Likewise. * sysdeps/s390/s390-32/____longjmp_chk.c: New file. * sysdeps/s390/s390-64/____longjmp_chk.c: New file. --- libc/sysdeps/s390/s390-32/__longjmp.c.jj 2009-05-16 13:23:42.000000000 -0400 +++ libc/sysdeps/s390/s390-32/__longjmp.c 2009-05-29 10:37:56.000000000 -0400 @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2001, 2005, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). @@ -33,6 +33,11 @@ __longjmp (__jmp_buf env, int val) #ifdef PTR_DEMANGLE register uintptr_t r3 __asm ("%r3") = THREAD_GET_POINTER_GUARD (); register void *r1 __asm ("%r1") = (void *) env; +# ifdef CHECK_SP + CHECK_SP (env, r3); +# endif +#elif defined CHECK_SP + CHECK_SP (env, 0); #endif /* Restore registers and jump back. */ asm volatile ("ld %%f6,48(%1)\n\t" --- libc/sysdeps/s390/s390-32/____longjmp_chk.c.jj 2009-05-29 10:16:59.000000000 -0400 +++ libc/sysdeps/s390/s390-32/____longjmp_chk.c 2009-05-29 10:39:08.000000000 -0400 @@ -0,0 +1,41 @@ +/* Copyright (C) 2009 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek . + + 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include +#include + +#define __longjmp ____longjmp_chk + +#define CHECK_SP(env, guard) \ + do \ + { \ + uintptr_t cur_sp; \ + uintptr_t new_sp = env->__gregs[9]; \ + __asm ("lr %0, %%r15" : "=r" (cur_sp)); \ + new_sp ^= guard; \ + if (new_sp < cur_sp) \ + __fortify_fail ("longjmp causes uninitialized stack frame"); \ + } while (0) + +#include "__longjmp.c" --- libc/sysdeps/s390/s390-64/__longjmp.c.jj 2009-05-16 13:23:42.000000000 -0400 +++ libc/sysdeps/s390/s390-64/__longjmp.c 2009-05-29 10:38:08.000000000 -0400 @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2005, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). @@ -33,6 +33,11 @@ __longjmp (__jmp_buf env, int val) #ifdef PTR_DEMANGLE register uintptr_t r3 __asm ("%r3") = THREAD_GET_POINTER_GUARD (); register void *r1 __asm ("%r1") = (void *) env; +# ifdef CHECK_SP + CHECK_SP (env, r3); +# endif +#elif defined CHECK_SP + CHECK_SP (env, 0); #endif /* Restore registers and jump back. */ asm volatile ("ld %%f7,104(%1)\n\t" --- libc/sysdeps/s390/s390-64/____longjmp_chk.c.jj 2009-05-29 10:16:59.000000000 -0400 +++ libc/sysdeps/s390/s390-64/____longjmp_chk.c 2009-05-29 10:38:52.000000000 -0400 @@ -0,0 +1,41 @@ +/* Copyright (C) 2009 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek . + + 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include +#include + +#define __longjmp ____longjmp_chk + +#define CHECK_SP(env, guard) \ + do \ + { \ + uintptr_t cur_sp; \ + uintptr_t new_sp = env->__gregs[9]; \ + __asm ("lgr %0, %%r15" : "=r" (cur_sp)); \ + new_sp ^= guard; \ + if (new_sp < cur_sp) \ + __fortify_fail ("longjmp causes uninitialized stack frame"); \ + } while (0) + +#include "__longjmp.c" Jakub