From patchwork Thu Dec 21 18:59:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 82677 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 C2BE638497B6 for ; Thu, 21 Dec 2023 19:00:22 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id E2CD03858413 for ; Thu, 21 Dec 2023 18:59:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E2CD03858413 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E2CD03858413 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::433 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703185188; cv=none; b=Ke50RKfCv8RoPTWHVAE9PtRqRaCmUGg3G7ZGMaSW8q9zlPQvldUx4HHyhIBIPsN3zs5P65tdaAXBLif2Dmxgkr0fM7kbLbO7fFNcoOA29spYTrsHsgBZELhkcqr4g7x4blYAN2JEKqHwyRncR0xk8Fguw6LicryuUS2/9rv5Xeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703185188; c=relaxed/simple; bh=2awUj00zJtPLF0dHzUtKM/MNLAvGOinbnLGAQV9r4rU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=FsOgxNq966RWqm82NZQzpnOC1J9z6MjOD4nkipZLXcAD8P85gRZbazDWCvMG0T7wfVgdA3LcQDJZYHeElW9BmrsUy6PLUGyXYBkYdbbbzJEPneJzbNLpvyFsdmczREaPMrLhltDwEt5mPus8frSixmpkZBN4gV7hALoVAfitHys= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6d47bb467a9so1643532b3a.1 for ; Thu, 21 Dec 2023 10:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703185184; x=1703789984; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=j4v+wLOSZ5jb+O3RNFp1x/EtvvMwvnAJYv0eByTvmec=; b=HZc93q5xWpnJK9IVZXozt6/GzxWD891FHaaODM2GeQ5NWTY88gyZtjOkF3nX4KMOPI Z5Pyj8mvSjp6o8ockHvabORHXulGYbIO91qZxz/4uDbDNKYLtsO0S3KNLlsOx2JRwtJ9 OKPZzCzj4vJ7AVCVxXTLccotCPOh/DAYOxIEpTjOZevXMDhYOexETZWMI8GCxp7BnN9R By7UksewRUNVNmy7bXNvSznU075vWGMeHKpordbYsrtR3jJlX9VuwtH6rSqi0X/DOi8Q ttesqWe7OU17s4ocWXhDe5F8yVltnzKaVT373F8QTggGpTXaxeRRAR0KvrJ3sL86t3za 7TLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185184; x=1703789984; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j4v+wLOSZ5jb+O3RNFp1x/EtvvMwvnAJYv0eByTvmec=; b=NnbgW5X9AIDSJrY6BALe96Xh1lq5B5m15f6tw4K2LbaSwEmtuE6m5fRpOnX0mw91FH Y4Iat4/7w60rbadhvcdrbcGjZuGpulejLvPkrrZ9SFz6jVxb9WpjrwCreovmSIHCz2LN O7gk0FgWEAsHnLUpHWVbziwWiO5JgbNJdpUXEDDyGZ8nJlFPkirf0BqDzNFbkVEZz7Ci JDK1ku9uvFYHTiaBF7gkPU+VucHS4WqLwptuf2P3zqHA+d/mBZf0BbVnS+b+oZPH+6Ef iTT77ZmdXz3EWaw1ocovvR38fRtSyRzR9IsM/qy3SP8nY/FkUNRkPmw+047Kam8N6rBR SkZg== X-Gm-Message-State: AOJu0YznwjbnfbCksRXc6wwvVr/r/wpL1tbLCR3QnHiikEp3R0P8i82w NtUaS2Xy8E6IadxqRTKOAuqVNRf8wyTpVoxR7C+UAAwL9yo= X-Google-Smtp-Source: AGHT+IHYWYOkmqGql8vikq/xMJDdJj3jo7g1rlT/0ImcRSvt0UjNT3EdPEODxNp2hVg4RzcO9zl/fA== X-Received: by 2002:a05:6a20:89a5:b0:194:eefc:370e with SMTP id h37-20020a056a2089a500b00194eefc370emr1292109pzg.52.1703185184107; Thu, 21 Dec 2023 10:59:44 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:8192:ecd7:d327:bea0:14dc]) by smtp.gmail.com with ESMTPSA id a9-20020a63e409000000b005cdbebd61d8sm1946165pgi.9.2023.12.21.10.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:59:43 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH 01/15] debug: Adapt fortify tests to libsupport Date: Thu, 21 Dec 2023 15:59:15 -0300 Message-Id: <20231221185929.1307116-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221185929.1307116-1-adhemerval.zanella@linaro.org> References: <20231221185929.1307116-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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.30 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 Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Siddhesh Poyarekar --- debug/test-stpcpy_chk.c | 2 +- debug/test-strcpy_chk.c | 2 +- debug/tst-fortify.c | 55 +++++++++++++++++++++------------------- debug/tst-longjmp_chk.c | 8 +++--- debug/tst-longjmp_chk2.c | 6 ++--- debug/tst-longjmp_chk3.c | 6 ++--- 6 files changed, 39 insertions(+), 40 deletions(-) diff --git a/debug/test-stpcpy_chk.c b/debug/test-stpcpy_chk.c index 938f3c0ceb..0b9fed49cc 100644 --- a/debug/test-stpcpy_chk.c +++ b/debug/test-stpcpy_chk.c @@ -19,7 +19,7 @@ #define STRCPY_RESULT(dst, len) ((dst) + (len)) #define TEST_MAIN #define TEST_NAME "stpcpy_chk" -#include "../string/test-string.h" +#include extern void __attribute__ ((noreturn)) __chk_fail (void); char *simple_stpcpy_chk (char *, const char *, size_t); diff --git a/debug/test-strcpy_chk.c b/debug/test-strcpy_chk.c index 792e789e1e..684e0bdd9b 100644 --- a/debug/test-strcpy_chk.c +++ b/debug/test-strcpy_chk.c @@ -20,7 +20,7 @@ # define STRCPY_RESULT(dst, len) dst # define TEST_MAIN # define TEST_NAME "strcpy_chk" -# include "../string/test-string.h" +# include /* This test case implicitly tests the availability of the __chk_fail symbol, which is part of the public ABI and may be used diff --git a/debug/tst-fortify.c b/debug/tst-fortify.c index 3744aadad4..20e926751a 100644 --- a/debug/tst-fortify.c +++ b/debug/tst-fortify.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -36,6 +37,10 @@ #include #include #include +#include + +#include +#include #ifndef _GNU_SOURCE # define MEMPCPY memcpy @@ -52,15 +57,10 @@ #define obstack_chunk_alloc malloc #define obstack_chunk_free free -char *temp_filename; -static void do_prepare (void); -static int do_test (void); -#define PREPARE(argc, argv) do_prepare () -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +static char *temp_filename; static void -do_prepare (void) +do_prepare (int argc, char *argv[]) { int temp_fd = create_temp_file ("tst-chk1.", &temp_filename); if (temp_fd == -1) @@ -77,10 +77,11 @@ do_prepare (void) exit (1); } } +#define PREPARE do_prepare -volatile int chk_fail_ok; -volatile int ret; -jmp_buf chk_fail_buf; +static volatile int chk_fail_ok; +static volatile int ret; +static jmp_buf chk_fail_buf; static void handler (int sig) @@ -102,22 +103,22 @@ wchar_t wbuf[10]; #define buf_size sizeof (buf) #endif -volatile size_t l0; -volatile char *p; -volatile wchar_t *wp; -const char *str1 = "JIHGFEDCBA"; -const char *str2 = "F"; -const char *str3 = "%s%n%s%n"; -const char *str4 = "Hello, "; -const char *str5 = "World!\n"; -const wchar_t *wstr1 = L"JIHGFEDCBA"; -const wchar_t *wstr2 = L"F"; -const wchar_t *wstr3 = L"%s%n%s%n"; -const wchar_t *wstr4 = L"Hello, "; -const wchar_t *wstr5 = L"World!\n"; -char buf2[10] = "%s"; -int num1 = 67; -int num2 = 987654; +static volatile size_t l0; +static volatile char *p; +static volatile wchar_t *wp; +static const char *str1 = "JIHGFEDCBA"; +static const char *str2 = "F"; +static const char *str3 = "%s%n%s%n"; +static const char *str4 = "Hello, "; +static const char *str5 = "World!\n"; +static const wchar_t *wstr1 = L"JIHGFEDCBA"; +static const wchar_t *wstr2 = L"F"; +static const wchar_t *wstr3 = L"%s%n%s%n"; +static const wchar_t *wstr4 = L"Hello, "; +static const wchar_t *wstr5 = L"World!\n"; +static char buf2[10] = "%s"; +static int num1 = 67; +static int num2 = 987654; #define FAIL() \ do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0) @@ -1815,3 +1816,5 @@ do_test (void) return ret; } + +#include diff --git a/debug/tst-longjmp_chk.c b/debug/tst-longjmp_chk.c index e4e93d2a36..37f858606b 100644 --- a/debug/tst-longjmp_chk.c +++ b/debug/tst-longjmp_chk.c @@ -10,11 +10,7 @@ #include #include - -static int do_test(void); -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" - +#include static jmp_buf b; @@ -76,3 +72,5 @@ do_test (void) puts ("second longjmp returned"); return 1; } + +#include diff --git a/debug/tst-longjmp_chk2.c b/debug/tst-longjmp_chk2.c index 1810ab44d7..7e1ee3edc5 100644 --- a/debug/tst-longjmp_chk2.c +++ b/debug/tst-longjmp_chk2.c @@ -10,9 +10,7 @@ #include #include -static int do_test (void); -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include static jmp_buf mainloop; static sigset_t mainsigset; @@ -126,3 +124,5 @@ do_test (void) return 0; } + +#include diff --git a/debug/tst-longjmp_chk3.c b/debug/tst-longjmp_chk3.c index f1e576ad5b..3050806c44 100644 --- a/debug/tst-longjmp_chk3.c +++ b/debug/tst-longjmp_chk3.c @@ -20,10 +20,6 @@ #include #include -static int do_test (void); -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" - static char buf[SIGSTKSZ * 4]; static jmp_buf jb; @@ -83,3 +79,5 @@ do_test (void) puts ("longjmp returned and shouldn't"); return 1; } + +#include