From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1792) id 0A71A385783F; Thu, 3 Aug 2023 20:47:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A71A385783F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691095659; bh=znl0kZ7fcvDK34Hs4SFcQJi0wM6vW7vZFslZi4xTX8E=; h=From:To:Subject:Date:From; b=xBAp+em+xP9ZfIJyQdG3+p7KhzxDF9okpA/OUAeeaga8UGDgVLVUGAR2/WDzjtaRo QUjBzEqlOIFFmW23dYUmVptQgnB4G24gqrR2+IPthzwt/brwFDLKXTFGy9QK4MJHmT AfBl3C7ZgbHp6xxM7zqZXDz2eW+vCZj4vORDVEq4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Samuel Thibault To: glibc-cvs@sourceware.org Subject: [glibc] chk: Add and fix hidden builtin definitions for *_chk X-Act-Checkin: glibc X-Git-Author: Samuel Thibault X-Git-Refname: refs/heads/master X-Git-Oldrev: cbf4aa422c82b895ab56ef5e9acda37947ad4184 X-Git-Newrev: 04bf7d2d8a79bf8d06ca811518688ccda190b376 Message-Id: <20230803204739.0A71A385783F@sourceware.org> Date: Thu, 3 Aug 2023 20:47:39 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=04bf7d2d8a79bf8d06ca811518688ccda190b376 commit 04bf7d2d8a79bf8d06ca811518688ccda190b376 Author: Samuel Thibault Date: Thu Aug 3 21:16:41 2023 +0200 chk: Add and fix hidden builtin definitions for *_chk Otherwise on gnu-i686 there are unwanted PLT entries in libc.so when fortification is enabled. Tested for i686-gnu, x86_64-gnu, i686-linux-gnu and x86_64-linux-gnu Diff: --- debug/longjmp_chk.c | 1 + debug/strncpy_chk.c | 1 + include/setjmp.h | 8 ++++++++ include/stdlib.h | 2 ++ include/string.h | 1 + setjmp/longjmp.c | 2 ++ 6 files changed, 15 insertions(+) diff --git a/debug/longjmp_chk.c b/debug/longjmp_chk.c index 1bc33c5769..c527e22db6 100644 --- a/debug/longjmp_chk.c +++ b/debug/longjmp_chk.c @@ -21,3 +21,4 @@ #define __libc_siglongjmp __longjmp_chk #include +libc_hidden_def (__longjmp_chk) diff --git a/debug/strncpy_chk.c b/debug/strncpy_chk.c index cb142b820f..966df2739b 100644 --- a/debug/strncpy_chk.c +++ b/debug/strncpy_chk.c @@ -27,3 +27,4 @@ __strncpy_chk (char *s1, const char *s2, size_t n, size_t s1len) return strncpy (s1, s2, n); } +libc_hidden_builtin_def (__strncpy_chk) diff --git a/include/setjmp.h b/include/setjmp.h index 26c6775d08..d2353be71b 100644 --- a/include/setjmp.h +++ b/include/setjmp.h @@ -11,6 +11,14 @@ extern void __longjmp (__jmp_buf __env, int __val) extern void ____longjmp_chk (__jmp_buf __env, int __val) __attribute__ ((__noreturn__)) attribute_hidden; +extern void __longjmp_chk (sigjmp_buf env, int val) + __attribute__ ((noreturn)) attribute_hidden; +/* The redirection in the installed header does not work with + libc_hidden_proto. */ +#define longjmp __longjmp_chk +#define siglongjmp __longjmp_chk +libc_hidden_proto (__longjmp_chk) + /* Internal function to possibly save the current mask of blocked signals in ENV, and always set the flag saying whether or not it was saved. This is used by the machine-dependent definition of `__sigsetjmp'. diff --git a/include/stdlib.h b/include/stdlib.h index 7deb8193d7..d1d00c0f6f 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -59,6 +59,8 @@ libc_hidden_proto (__isoc23_strtoull_l) libc_hidden_proto. */ # undef strtol # define strtol __isoc23_strtol +# undef atoi +# define atoi(nptr) __isoc23_strtol(nptr, NULL, 10) # undef strtoul # define strtoul __isoc23_strtoul # undef strtoll diff --git a/include/string.h b/include/string.h index 659530d1aa..86d1fa4abe 100644 --- a/include/string.h +++ b/include/string.h @@ -214,6 +214,7 @@ libc_hidden_builtin_proto (__memmove_chk) libc_hidden_builtin_proto (__mempcpy_chk) libc_hidden_builtin_proto (__memset_chk) libc_hidden_builtin_proto (__stpcpy_chk) +libc_hidden_builtin_proto (__strncpy_chk) #endif diff --git a/setjmp/longjmp.c b/setjmp/longjmp.c index 69f540ea22..24795ecbb5 100644 --- a/setjmp/longjmp.c +++ b/setjmp/longjmp.c @@ -19,6 +19,8 @@ #include #include +#undef longjmp +#undef siglongjmp /* Set the signal mask to the one specified in ENV, and jump to the position specified in ENV, causing the setjmp