Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2B38C04FF3 for ; Mon, 24 May 2021 18:59:26 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9B2D61360 for ; Mon, 24 May 2021 18:59:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9B2D61360 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 608C382D58; Mon, 24 May 2021 20:59:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 50F6B82E96; Mon, 24 May 2021 20:59:22 +0200 (CEST) Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 76E1182D61 for ; Mon, 24 May 2021 20:59:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tom.rini@gmail.com Received: by mail-qt1-f181.google.com with SMTP id f8so21384975qth.6 for ; Mon, 24 May 2021 11:59:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=pFvPH41Z89FlMv8pKC+yF6RDNfO0uyugAH+GgnGobyU=; b=WRtt/aTSKHiQ6Yn9+r1XFyMr94H1EJcDb1KhYA6cBedQP3hBJwUBWIIVtW0b5t1NkJ N3ll+0itZdgpRGokMYse245W96JnzEEP8PZBrM55B+8nvvawqMjt9jEV4DTniLhnPXZp pNC+Pzh2i3THR0dQljSbHTiQW4wrIkss246HMQk/xmirytblbRgUzuevFLdwW7oPMOSt SPZ2sbUE72oS4AKEmSoYz3sW/KG08FCP3ke6Cyw4KmwNX0xBDLgMJ8ZwHcyeVmrP0UIR CviLt516dXn/eMpnZuD2eG3y5/9iNw5Rrbm5YN1NkRG+yQzhmcupiyW6EHe8oN7BtVs0 4QRQ== X-Gm-Message-State: AOAM531sy4R06J0qLkB+6EAhHi85cGJZU2rC2kFvbMm4CJxLZ/M0vFK/ V7Wcr4FRHhemLH1yqhPksMaEe8Papw== X-Google-Smtp-Source: ABdhPJzQuhVyD5rdKdOcZZ9xSt4QlAsCJjeE9DuCtYa3M0qKHeOaFhIfkzUhYwp7fsGolrr1sgK+kA== X-Received: by 2002:a05:622a:170b:: with SMTP id h11mr29087429qtk.330.1621882757680; Mon, 24 May 2021 11:59:17 -0700 (PDT) Received: from bill-the-cat.lan (2603-6081-7b01-cbda-5ce8-9acb-4a3a-47a0.res6.spectrum.com. [2603:6081:7b01:cbda:5ce8:9acb:4a3a:47a0]) by smtp.gmail.com with ESMTPSA id z18sm11091691qki.55.2021.05.24.11.59.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 11:59:17 -0700 (PDT) From: Tom Rini To: u-boot@lists.denx.de Subject: [PATCH] stackprot: Make our test a bit more complex Date: Mon, 24 May 2021 14:59:13 -0400 Message-Id: <20210524185913.10422-1-trini@konsulko.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean With better compiler optimizations available, a compiler may see we do nothing with our buffer after calling memset and omit the call, thus causing us to not smash the stack. Add a comment to explain why we now also have a printf call, so that the test will pass as the memset will not be omitted. Reported-by: Marek BehĂșn Signed-off-by: Tom Rini --- cmd/stackprot_test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/stackprot_test.c b/cmd/stackprot_test.c index 36f5bac8d230..1e26193e88b0 100644 --- a/cmd/stackprot_test.c +++ b/cmd/stackprot_test.c @@ -9,9 +9,16 @@ static int do_test_stackprot_fail(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + /* + * In order to avoid having the compiler optimize away the stack smashing + * we need to do a little something here. + */ char a[128]; memset(a, 0xa5, 512); + + printf("We have smashed our stack as this should not exceed 128: sizeof(a) = %ld\n", strlen(a)); + return 0; } -- 2.17.1