From patchwork Thu Aug 3 20:48:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 73586 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1F488385DC1D for ; Thu, 3 Aug 2023 20:49:07 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id B1F4D38582B7 for ; Thu, 3 Aug 2023 20:48:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1F4D38582B7 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 90DBF200FB; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D0SutlgEFqDv; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from begin (lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr [92.158.138.184]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 249BE200E8; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1qRfFE-0050OK-24; Thu, 03 Aug 2023 22:48:28 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited 1/4] tst-*glob*: Do not check d_name size Date: Thu, 3 Aug 2023 22:48:24 +0200 Message-Id: <20230803204827.1193126-2-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> References: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Posix says that d_name is of unspecified size, and sizeof(d_name) should not be used. It is indeed only 1-byte long in bits/dirent.h. We can instead explictly provide the actual allocated size to __strcpy_chk. --- posix/tst-glob_lstat_compat.c | 2 +- posix/tst-gnuglob-skeleton.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/posix/tst-glob_lstat_compat.c b/posix/tst-glob_lstat_compat.c index 937ad77da3..6559954247 100644 --- a/posix/tst-glob_lstat_compat.c +++ b/posix/tst-glob_lstat_compat.c @@ -173,7 +173,7 @@ my_readdir (void *gdir) dir->d.d_type = filesystem[dir->idx].type; - strcpy (dir->d.d_name, filesystem[dir->idx].name); + __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX); ++dir->idx; diff --git a/posix/tst-gnuglob-skeleton.c b/posix/tst-gnuglob-skeleton.c index 557cfcbd2a..998fc2d94d 100644 --- a/posix/tst-gnuglob-skeleton.c +++ b/posix/tst-gnuglob-skeleton.c @@ -222,7 +222,7 @@ my_readdir (void *gdir) dir->d.d_type = filesystem[dir->idx].type; - strcpy (dir->d.d_name, filesystem[dir->idx].name); + __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX); if (test_verbose > 0) printf ("info: my_readdir ({ level: %d, idx: %ld })" From patchwork Thu Aug 3 20:48:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 73584 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 661C13857727 for ; Thu, 3 Aug 2023 20:48:45 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 9F1F33858408 for ; Thu, 3 Aug 2023 20:48:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F1F33858408 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 7303520116; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id akZu3wcNbLao; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from begin (lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr [92.158.138.184]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 3CBFB200FB; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1qRfFE-0050ON-28; Thu, 03 Aug 2023 22:48:28 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited 2/4] Subject: hurd: Make __realpath return EINVAL on NULL buf Date: Thu, 3 Aug 2023 22:48:25 +0200 Message-Id: <20230803204827.1193126-3-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> References: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" As Posix and stdlib/test-canon.c expects it, and rather than letting pathconf crash. --- debug/realpath_chk.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/debug/realpath_chk.c b/debug/realpath_chk.c index adfc09237c..8e734b534e 100644 --- a/debug/realpath_chk.c +++ b/debug/realpath_chk.c @@ -19,6 +19,7 @@ #include #include #include +#include char * @@ -30,7 +31,15 @@ __realpath_chk (const char *buf, char *resolved, size_t resolvedlen) return __realpath (buf, resolved); #else - long int pathmax =__pathconf (buf, _PC_PATH_MAX); + long int pathmax; + + if (buf == NULL) + { + __set_errno (EINVAL); + return NULL; + } + + pathmax = __pathconf (buf, _PC_PATH_MAX); if (pathmax != -1) { /* We do have a fixed limit. */ From patchwork Thu Aug 3 20:48:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 73585 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6862385C6F2 for ; Thu, 3 Aug 2023 20:48:50 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 0F1C93858033 for ; Thu, 3 Aug 2023 20:48:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F1C93858033 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 1A8CD2010E; Thu, 3 Aug 2023 22:48:30 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3fk9VxTvetVy; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from begin (lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr [92.158.138.184]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 492C520108; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1qRfFE-0050OQ-2C; Thu, 03 Aug 2023 22:48:28 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited 3/4] tst-realpath-toolong: return "unsupported" when PATH_MAX is undefined Date: Thu, 3 Aug 2023 22:48:26 +0200 Message-Id: <20230803204827.1193126-4-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> References: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" When PATH_MAX is undefined, realpath cannot ever ENAMETOOLONG, so this test is unsupported. --- stdlib/tst-realpath-toolong.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stdlib/tst-realpath-toolong.c b/stdlib/tst-realpath-toolong.c index 4388890294..a071fe7544 100644 --- a/stdlib/tst-realpath-toolong.c +++ b/stdlib/tst-realpath-toolong.c @@ -24,18 +24,18 @@ #include #include #include +#include #include #include #define BASENAME "tst-realpath-toolong." -#ifndef PATH_MAX -# define PATH_MAX 1024 -#endif - int do_test (void) { +#ifndef PATH_MAX + return EXIT_UNSUPPORTED; +#else char *base = support_create_and_chdir_toolong_temp_directory (BASENAME); char buf[PATH_MAX + 1]; @@ -48,6 +48,7 @@ do_test (void) free (base); return 0; +#endif } #include From patchwork Thu Aug 3 20:48:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 73587 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F66D385C426 for ; Thu, 3 Aug 2023 20:49:12 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id EF200385802F for ; Thu, 3 Aug 2023 20:48:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF200385802F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 048DA2010B; Thu, 3 Aug 2023 22:48:30 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jAQgHZNeTmKb; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from begin (lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr [92.158.138.184]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 5009D2010E; Thu, 3 Aug 2023 22:48:29 +0200 (CEST) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1qRfFE-0050OT-2G; Thu, 03 Aug 2023 22:48:28 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited 4/4] chk: Add and fix hidden builtin definitions for *_chk Date: Thu, 3 Aug 2023 22:48:27 +0200 Message-Id: <20230803204827.1193126-5-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> References: <20230803204827.1193126-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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(+) 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