From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 7517AC54FCB for ; Thu, 23 Apr 2020 17:26:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 369A920728 for ; Thu, 23 Apr 2020 17:26:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AjNZAuK8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 369A920728 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BE3388E0005; Thu, 23 Apr 2020 13:26:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B93388E0003; Thu, 23 Apr 2020 13:26:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACFDF8E0005; Thu, 23 Apr 2020 13:26:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 966A98E0003 for ; Thu, 23 Apr 2020 13:26:07 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 40D24824805A for ; Thu, 23 Apr 2020 17:26:07 +0000 (UTC) X-FDA: 76739797974.11.dogs13_6f92f780d4556 X-HE-Tag: dogs13_6f92f780d4556 X-Filterd-Recvd-Size: 4224 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 23 Apr 2020 17:26:06 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id b62so7225902qkf.6 for ; Thu, 23 Apr 2020 10:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=i0wqst2mhEuWLnZwDqC3VBRcH3//gDPmWLfGb4vS/m0=; b=AjNZAuK8LPgGHclTuG/kCSLmZJEP7FWoBVmhH+w1pehgUAmXCyqVy7qQA2fwm7qUiR k9Lmfh5VKJVTWMV2C6ZeurvmxIhxSJpBM7xqje4n3oBUNHk1H6MGfT6lCmjJ8lapiu/k ne3GwMMr67DYY0ZAIClkZ+EwoiPD0WuOIgkAOmBiAKNtX0IbrBFh0unMoMktP7k9wCUo bNqfwY5729iY0AtVSrXjyFCvj2i8YSh2kSPH0Qx3vzRCnoVw5DBeGROYHNDwM+MA3P5Z 2BlNZA3XJYAho83LaVSB8dzdgpuWOCzuS7WObuRPhBAhn7NrpJcI7cUrUjXlVX5WL56Y toFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=i0wqst2mhEuWLnZwDqC3VBRcH3//gDPmWLfGb4vS/m0=; b=b8EbRGEEYvJVOUEMvN0+PZpqd3XWvZDlqFvbnV+P0YFOWS6SZoSwob4NUIvISKEfQt URBITuO9rgS34v/lOj0zSF6UPptL/KbD3Zf7sFloJ4kTtw0+FUl9JFF6DkV1u+QH3n4u FqVsn7aOBYYwpNX1v3wnjlpWqlxONmih17a4QJiles6URe22dmi34bBV9NOeqn2SI98L 5YESHdz6gWZUT7XaiznZHUaN/OscaZflRzPY/obSpgKLOKFRE+tlClzcICIT3sqCR49y jfQHM5++SHujH46CeGkC49rwa/aexIIlHhw8fQhXaJs/zq1zvg0j1SllAIt9MmZwcKda Uijg== X-Gm-Message-State: AGi0PuZcJvAZ8cEjQeyBAAiBWt8NZa9C92xYOkdtkjRnd1Ii3mv4H/ol AuHKjZFkz4ApEFwln1SgynS2N2WYrgSv5bSg3MVCpQ== X-Google-Smtp-Source: APiQypJCTcCvmXfupMphFqiB7ydFbx6n9jBBTNmyYJuiGke7N3DdxVWWIubnTmi/l/uhC37qYQSvTfge5RrZlH5ct6I= X-Received: by 2002:a05:620a:1362:: with SMTP id d2mr4610858qkl.256.1587662765591; Thu, 23 Apr 2020 10:26:05 -0700 (PDT) MIME-Version: 1.0 References: <20200423154503.5103-1-dja@axtens.net> <20200423154503.5103-4-dja@axtens.net> In-Reply-To: <20200423154503.5103-4-dja@axtens.net> From: Dmitry Vyukov Date: Thu, 23 Apr 2020 19:25:53 +0200 Message-ID: Subject: Re: [PATCH v3 3/3] kasan: initialise array in kasan_memcmp test To: Daniel Axtens Cc: LKML , Linux-MM , Andrew Morton , kasan-dev , Christophe Leroy , Andrey Ryabinin , Alexander Potapenko Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 23, 2020 at 5:45 PM Daniel Axtens wrote: > > memcmp may bail out before accessing all the memory if the buffers > contain differing bytes. kasan_memcmp calls memcmp with a stack array. > Stack variables are not necessarily initialised (in the absence of a > compiler plugin, at least). Sometimes this causes the memcpy to bail > early thus fail to trigger kasan. > > Make sure the array initialised to zero in the code. > > No other test is dependent on the contents of an array on the stack. > > Cc: Andrey Ryabinin > Cc: Alexander Potapenko > Cc: Dmitry Vyukov > Signed-off-by: Daniel Axtens > Reviewed-by: Dmitry Vyukov > --- > lib/test_kasan.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/test_kasan.c b/lib/test_kasan.c > index 939f395a5392..7700097842c8 100644 > --- a/lib/test_kasan.c > +++ b/lib/test_kasan.c > @@ -638,7 +638,7 @@ static noinline void __init kasan_memcmp(void) > { > char *ptr; > size_t size = 24; > - int arr[9]; > + int arr[9] = {}; > > pr_info("out-of-bounds in memcmp\n"); > ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); My version of this function contains the following below: memset(arr, 0, sizeof(arr)); What am I missing?