[hurd,commited,4/4] chk: Add and fix hidden builtin definitions for *_chk
Checks
Commit Message
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
---
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(+)
Comments
Samuel Thibault <samuel.thibault@ens-lyon.org> writes:
> 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
Can this one be backported or not because it somewhat affects ABI?
(Not sure if it falls within what we consider stable or not.)
(Will need 41d8c3bc33bcae1ebb8077b0442caef4917f763a too if we do backport.)
@@ -21,3 +21,4 @@
#define __libc_siglongjmp __longjmp_chk
#include <setjmp/longjmp.c>
+libc_hidden_def (__longjmp_chk)
@@ -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)
@@ -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'.
@@ -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
@@ -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
@@ -19,6 +19,8 @@
#include <setjmpP.h>
#include <signal.h>
+#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