Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4662602rwl; Tue, 28 Mar 2023 09:35:07 -0700 (PDT) X-Google-Smtp-Source: AKy350Z1hEyhepxtE6N39mP1TDNXi1qBLk1q5x7IgSYIPHXS03YlCk1G2V7a+gZS1J2oUW/XaAvV X-Received: by 2002:a05:6402:184f:b0:4fc:494a:98f5 with SMTP id v15-20020a056402184f00b004fc494a98f5mr18574319edy.29.1680021307299; Tue, 28 Mar 2023 09:35:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680021307; cv=none; d=google.com; s=arc-20160816; b=TVQPXWgjvLXYhmxO8ubvt5FXcVzRJ+81TmN/xh0mi4ouQzOZyNWN25wpgPBi4eM2gb TXeCW22jWyczgGFnsKKLn1c66/1tp5TfQWqgLQTIJuU+oH089q5s+oByB5FMVQBfPAe/ xUqkmS3lEnodCp4Jlw6xlGIaB4Z7Bzs+EG1Jtmz+63Czx7RmkCo1XP+bJvQdE37daRHi NSYW1MMd5iySghoeOzCAmrO9GFeZfKHVu79b4b4HNAf0VtHQxeAZRXdAd8n82eSh2dnI 70yy5f+fZNTUdJaz0fWtiGbpNDf82MxaqXv9fB6EjpIkA/oml5lArWhC84USUhXJYyXW iVKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=e0QgZLK4P3h1PKES26LrXnpai5ELYuF9E5Z/M9MMmPA=; b=puZshr9P0Zs2ELhj6E74AG+nMMn7CQehwg25lrxmylTgO2zAjQPjngpsRcrJhN0Nfl x7v4mQpRowF65s9FtgMnTbB/QHXplMGeOo/mEKDnJmiokzyFxMaMe/Kf596yLJ1cDRwP dvJMcUdLKX2XTsvkOSRKBqdF98+yC0ebdG1I0ewLylG8Nx8LA8Xbslms0S1yC1fIAmxC RGYFFufQPzKHgRZI724YmZBDoEuky/VFs1ju1U9mqj34ibG6VeVnA2IYWlZKQJOi9QuW 1FNaffEoDCLZUSGYlohLfyoEb8SRWGvxkiR/cDw8IyCJ1zoFEVr5EaVJvwWXSRHonLr5 QhwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb11-20020a170907960b00b00937d0d8f640si24936688ejc.128.2023.03.28.09.34.42; Tue, 28 Mar 2023 09:35:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233121AbjC1QTN (ORCPT + 99 others); Tue, 28 Mar 2023 12:19:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232732AbjC1QTI (ORCPT ); Tue, 28 Mar 2023 12:19:08 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7AE61D533 for ; Tue, 28 Mar 2023 09:19:06 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 32SGJ0Z4009628; Tue, 28 Mar 2023 18:19:00 +0200 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux@weissschuh.net, linux-kernel@vger.kernel.org, Alexey Dobriyan , Willy Tarreau Subject: [PATCH 1/1] tools/nolibc: tests: use volatile to force stack smashing Date: Tue, 28 Mar 2023 18:18:45 +0200 Message-Id: <20230328161845.9584-2-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230328161845.9584-1-w@1wt.eu> References: <20230328161845.9584-1-w@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Weißschuh Use a volatile pointer to write outside the buffer so the compiler can't optimize it away. Reported-by: Alexey Dobriyan Link: https://lore.kernel.org/lkml/c0584807-511c-4496-b062-1263ea38f349@p183/ Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau --- tools/testing/selftests/nolibc/nolibc-test.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 21bacc928bf7..47013b78972e 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -667,17 +667,13 @@ int run_stdlib(int min, int max) return ret; } -#if defined(__clang__) -__attribute__((optnone)) -#elif defined(__GNUC__) -__attribute__((optimize("O0"))) -#endif static int smash_stack(void) { char buf[100]; + volatile char *ptr = buf; for (size_t i = 0; i < 200; i++) - buf[i] = 'P'; + ptr[i] = 'P'; return 1; } -- 2.17.5