From patchwork Wed Jun 14 17:20:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nisha Poyarekar X-Patchwork-Id: 1795054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=FUP9y/MV; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QhBzf1Pz0z20Vx for ; Thu, 15 Jun 2023 03:21:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 618953858C20 for ; Wed, 14 Jun 2023 17:21:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 618953858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686763291; bh=7ZXVYAfA8c1hTzFMXTdVBxY6277779zuIjigxX9hXPQ=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=FUP9y/MVURdMnZLcMku4UqZgnNSg4U6VwaCMa5vn1UBL7r/NdWQ77dVBNAwNIh/wJ sVLiRamV8QROboTINuheXvvf0nrxnHdLVEspZ5rTQWPOM9Du0/3HCDIRYVsC4M9B48 NyWf7pts5kRswwj1AeV+K9PYb0wAKb5gAKnvsut4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by sourceware.org (Postfix) with ESMTPS id 9DC9A3858C53 for ; Wed, 14 Jun 2023 17:21:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9DC9A3858C53 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-3f9aa383527so21723241cf.1 for ; Wed, 14 Jun 2023 10:21:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686763274; x=1689355274; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7ZXVYAfA8c1hTzFMXTdVBxY6277779zuIjigxX9hXPQ=; b=Is9fUkC8+xkWkooHLuvjZYkA6A3D3t7+oTfO3L4Jg0o2Uh9ZtWr+jZGmKi/Fj4JwxU iVwTNtKDVpwUDzSE7h+rGldNoVSiP9pARiziRsw7uM9L9/viOhJuB/fIRRAH4QRnud6C EdLwPTTJNEN7eGXPt8Vaml7SrzH97f9x482ZoIcJSwHhAxtIhh0fR4aZOas6ga1cyeoN WPKJZEYVfmKe/GvR2NzBOigW0mbR3GWakIJfMfzgFUIzUHwcYgkhzdV95fv95qESj2BF 1taNc64hLbVdBX0sASH21CwZH6NFHu0LsYzOOyo1MTtppRBInfes5gYCoZnWEi/70Vza fZcQ== X-Gm-Message-State: AC+VfDxzCsgfBmmOvlEw0SKjGJhwrFqTdlS7djVe442iCtDG/aAqUDdh WYot+Ba8IhG+0TC1Mc9PzIo79ubPgZs= X-Google-Smtp-Source: ACHHUZ54/VZUTozPeV0flFpsHT8rS9VNztn3RIjclapmo22qpofdsEjR82izVfXq2mj72mQkkZ2WxQ== X-Received: by 2002:a05:622a:1345:b0:3f6:c5c7:fc4e with SMTP id w5-20020a05622a134500b003f6c5c7fc4emr2773248qtk.28.1686763274459; Wed, 14 Jun 2023 10:21:14 -0700 (PDT) Received: from Nisha-ThinkPad.. (bras-vprn-toroon4834w-lp130-02-142-113-138-85.dsl.bell.ca. [142.113.138.85]) by smtp.gmail.com with ESMTPSA id g16-20020ac84690000000b003f8e6071e43sm5234801qto.3.2023.06.14.10.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 10:20:51 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Nisha Poyarekar Subject: [PATCH v2] debug: Actually run tst-longjmp_chk3.c Date: Wed, 14 Jun 2023 13:20:23 -0400 Message-Id: <20230614172023.23621-1-nisha.s.menon@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Nisha Poyarekar via Libc-alpha From: Nisha Poyarekar Reply-To: Nisha Poyarekar Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" tst-longjmp_c.c test was not run at all because there was no entry for it in the Makefile. With this change, I have also included the new test-driver.c instead of test-skeleton.c. Signed-off-by: Nisha Poyarekar --- Made changes as per your suggestion and used xalloc_sigstack. debug/Makefile | 1 + debug/tst-longjmp_chk3.c | 35 ++++++++++++----------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/debug/Makefile b/debug/Makefile index 096df27aeb..e19aa1107a 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -279,6 +279,7 @@ tests = \ tst-backtrace6 \ tst-longjmp_chk \ tst-longjmp_chk2 \ + tst-longjmp_chk3 \ tst-realpath-chk \ tst-sprintf-fortify-unchecked \ # tests diff --git a/debug/tst-longjmp_chk3.c b/debug/tst-longjmp_chk3.c index f1e576ad5b..0fb4270bc1 100644 --- a/debug/tst-longjmp_chk3.c +++ b/debug/tst-longjmp_chk3.c @@ -18,13 +18,13 @@ #include #include +#include #include -static int do_test (void); -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include +#include +#include -static char buf[SIGSTKSZ * 4]; static jmp_buf jb; static void @@ -48,19 +48,10 @@ handler (int sig) static int do_test (void) { - stack_t ss; - set_fortify_handler (handler); /* Create a valid signal stack and enable it. */ - ss.ss_sp = buf; - ss.ss_size = sizeof (buf); - ss.ss_flags = 0; - if (sigaltstack (&ss, NULL) < 0) - { - printf ("first sigaltstack failed: %m\n"); - return 1; - } + void *sstk1 = xalloc_sigstack (SIGSTKSZ * 4); /* Trigger the signal handler which will create a jmpbuf that points to the end of the signal stack. */ @@ -69,17 +60,15 @@ do_test (void) /* Shrink the signal stack so the jmpbuf is now invalid. We adjust the start & end to handle stacks that grow up & down. */ - ss.ss_sp = buf + sizeof (buf) / 2; - ss.ss_size = sizeof (buf) / 4; - if (sigaltstack (&ss, NULL) < 0) - { - printf ("second sigaltstack failed: %m\n"); - return 1; - } + void *sstk2 = xalloc_sigstack (SIGSTKSZ); /* This should fail. */ longjmp (jb, 1); - puts ("longjmp returned and shouldn't"); - return 1; + xfree_sigstack(sstk1); + xfree_sigstack(sstk2); + + FAIL_RET ("longjmp returned and shouldn't"); } + +#include