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=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 4DCAEC54FCB for ; Fri, 24 Apr 2020 14:37:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F366520736 for ; Fri, 24 Apr 2020 14:37:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=axtens.net header.i=@axtens.net header.b="HDLuxwmJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F366520736 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=axtens.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9FDE78E0006; Fri, 24 Apr 2020 10:37:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D48C8E0003; Fri, 24 Apr 2020 10:37:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 911068E0006; Fri, 24 Apr 2020 10:37:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id 775128E0003 for ; Fri, 24 Apr 2020 10:37:10 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 45C242481 for ; Fri, 24 Apr 2020 14:37:10 +0000 (UTC) X-FDA: 76743001020.05.smash46_45a09b107c31 X-HE-Tag: smash46_45a09b107c31 X-Filterd-Recvd-Size: 4671 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Apr 2020 14:37:09 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id v2so3795320plp.9 for ; Fri, 24 Apr 2020 07:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=KAaTm0Hse3RKPU7ib8Tu6J/z1e4Og8KZuvKFi+it9Vo=; b=HDLuxwmJR50W3E49SGVN/oDlnnLAtNHvQyQ27E7eb5YXWVEV4pAvtnxiN5ry50pNwz Br5lHFZxTjO2q2DEornfTe3o0GF8g9Pt+pryH5EFlNeb7pctZLroFi9VoLp2x8ckMPH5 BD+T6J/+jQQ+++enfBOWxatDr7K+PkssrakbQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=KAaTm0Hse3RKPU7ib8Tu6J/z1e4Og8KZuvKFi+it9Vo=; b=E0FruaXC1VXOYf4Na0VYI5gvMWjn0iwu89ULnRI34phQkEINyTcUUfPfX2b/ayUsH6 Ba7Dwn/EbrtZEEJ3d5BzVb6hTuiz5kLtxOLykmJiXg7ngzL2ErKJJ1zi2gIrdopfwYs+ n/GeMcpxQ8P92bjQHrOLS2fLqjP3xHJD6qsJMBrqG1+BqhH1oiOaEdNa6eOtbmzGdLFy r1YUiWuuGgHBEiRACtV7lQytT/8NeWtejHGqVi5SSugq0qUanw20UgY8QjLtFDyRKFFP wzcaNfaCSmtb7CfExTEaFpn9rQsQjVXdxAF41Vvc+9Z8nczetsvc8NyKzMQSTQ85UPlA rB6w== X-Gm-Message-State: AGi0PuZVjCZePt2LlSJ36NQ++jgyhwTAcfJLWfpMehfgm9J2eapMFqS6 n7GpLndGW0/cjovnGLWnSWZyQg== X-Google-Smtp-Source: APiQypIBpqHawmogrqSBDaFcH0lKU8ACC1fhiCqtIrIxnhrMJkb/TPamldj/LttAAONccIxVA4xNxw== X-Received: by 2002:a17:90b:374f:: with SMTP id ne15mr6294987pjb.181.1587739028730; Fri, 24 Apr 2020 07:37:08 -0700 (PDT) Received: from localhost (2001-44b8-1113-6700-fd06-aa7b-7508-4b8b.static.ipv6.internode.on.net. [2001:44b8:1113:6700:fd06:aa7b:7508:4b8b]) by smtp.gmail.com with ESMTPSA id p190sm6182787pfp.207.2020.04.24.07.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 07:37:07 -0700 (PDT) From: Daniel Axtens To: Dmitry Vyukov Cc: LKML , Linux-MM , Andrew Morton , kasan-dev , Christophe Leroy , Andrey Ryabinin , Alexander Potapenko Subject: Re: [PATCH v3 3/3] kasan: initialise array in kasan_memcmp test In-Reply-To: References: <20200423154503.5103-1-dja@axtens.net> <20200423154503.5103-4-dja@axtens.net> Date: Sat, 25 Apr 2020 00:37:04 +1000 Message-ID: <877dy5t0fj.fsf@dja-thinkpad.axtens.net> MIME-Version: 1.0 Content-Type: text/plain 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: Dmitry Vyukov writes: > 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? Ah! It turns out I accidentally removed the memset in patch 1. No idea why I did that. I'll fix up patch 1 to not remove the memset and drop this patch. Daniel