Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1097391rwd; Thu, 18 May 2023 07:58:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UPm1tNSLfLTE/L8PU5FFzbCBdgmSTav5yoIlYbABid+oG9a3Svi19x9tlnVeRPsHE9pS7 X-Received: by 2002:a17:90a:cb81:b0:24c:df8:8efa with SMTP id a1-20020a17090acb8100b0024c0df88efamr2682016pju.39.1684421926621; Thu, 18 May 2023 07:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684421926; cv=none; d=google.com; s=arc-20160816; b=q5xWwel3B55GpE70PcDrelcp0pVKnqZ/6cShiVeUfqtxm829ABOIkqVvB/TjIvP4P1 5SNoNmTv3Y47oPmtR3qHuKv2NH0OCLraDeIi9GkdBSFiJ418kBTaJXmQOhWCBdX5w4lD IDu/3wNUzpk+oszOFG1p5/4VAzqUE3cgcbdwu2GKK3xvvGlhQwxw8UR8zBMQstuSq0sB cheZQ0hyDNc6Kx1BtN8mTsv9xwt1Fmu5uUKV4td+K3YXU/ywHO2E3S5rJRw3emfcCc8t 6bks7plaOR1/ua0ILSf02327Hf2QAZK8RQ6uPj4THjs8Bz1mGoVAH6yHrvYahvScmHz4 1s3w== 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 :dkim-signature; bh=MmpPXr1RwOA0FjpGc1hNuQMgpq9idDkjFV9mSTYrDD0=; b=0pW1viZ/GCaTrRs3BXojzdCN6FDJSw/DK0NMMjD63bWr2wk+532VfBBTTx6/tLnikB KTBi63c00/YpuDQunfhPAmSbJgpH13AJlOWAlbywuRL01QVZNr2FnzBkh88r0xzJCOD+ Gy8d8GcnRw3xJRnGnVMIeDjG3ksSy0XduaTHGUEM6Zr702rFO6qFJM7yC+OXKKzhQeos SU7ucJVDNL8KXpeWJKwQOGffbyPkRkVnpqKBnJDZeESpZgvIPeK26Jkaara8i5hmJERS jHDuMc2f+NPXQ0isvxXTGQzmkUfdnXMEvJTJwZyZjpeRxHioaoymaDYszS9J/3W292eX IjtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oIsBFX1N; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gp4-20020a17090adf0400b00233f3034302si4287454pjb.46.2023.05.18.07.58.34; Thu, 18 May 2023 07:58:46 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oIsBFX1N; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231759AbjEROza (ORCPT + 99 others); Thu, 18 May 2023 10:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231657AbjEROz0 (ORCPT ); Thu, 18 May 2023 10:55:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E91E122 for ; Thu, 18 May 2023 07:55:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F130C60A52 for ; Thu, 18 May 2023 14:55:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E0D2C433EF; Thu, 18 May 2023 14:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421723; bh=zEjOj9DdUomfDLsrKXBstSrS7dzFFqc89ym3/GOXT1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oIsBFX1Ny4utAyZupY3cQkO1912mk5kGP8McWNn0wWQ5MZfhMjlqqWp9cbSjb/b9X ZGddSdguSWXri82msb/vYmIN41QT+rUWkpzXSeh39cEtlzyqsvGFPtvNTkob6D1Ffh GksLBct27kof6Z4L3OuODpwv8qTQBZ7cw4F5HwRZWLuQhuVcUkLfP8T0UsUJDk/8MM lZ1ieYteZKYcysCtVUol/xdkyWAp3+jpDxq4VmjnqDMh47HkMllMZO8XuSP2GFcfzC aKzsp9k8XWx2JwODedpezVzeYhntrLUyjOhZCqhE30SfGCDGcUpruk+01gQqX+g2BT d5lboSAWpLuBQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 12F7ECE0CC3; Thu, 18 May 2023 07:55:23 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Alexey Dobriyan , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 01/15] tools/nolibc: tests: use volatile to force stack smashing Date: Thu, 18 May 2023 07:55:07 -0700 Message-Id: <20230518145521.3806117-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 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 Signed-off-by: Paul E. McKenney --- 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.40.1