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 254B6C33CB1 for ; Thu, 16 Jan 2020 08:07:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DB439207FF for ; Thu, 16 Jan 2020 08:07:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qfoDxmeh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB439207FF 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 7A69F8E004F; Thu, 16 Jan 2020 03:07:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7579B8E003F; Thu, 16 Jan 2020 03:07:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 695A08E004F; Thu, 16 Jan 2020 03:07:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 51FCF8E003F for ; Thu, 16 Jan 2020 03:07:45 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id ECB3B8248047 for ; Thu, 16 Jan 2020 08:07:44 +0000 (UTC) X-FDA: 76382768448.08.pail73_967c792db304 X-HE-Tag: pail73_967c792db304 X-Filterd-Recvd-Size: 4663 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jan 2020 08:07:44 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id i13so18194875qtr.3 for ; Thu, 16 Jan 2020 00:07:44 -0800 (PST) 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=7IBdjvFRag9yZE/BKc5brHAQDARDtIXaGhkF8uJXRlQ=; b=qfoDxmehHt9zSJPjWabWfKApmNG47N0Q2/pjIts+XRh7UWc4ym2jspVC7dOFfypjnv qnIVrd6DHS4ExoKZLCfn7EiaWjc0VJ+thpAfGN13cJj50S+8ZZzG+BJuvVxj4+JMY4+Z R2R3sRy25/3S2Joee0sQyYVPnaXfnDYs0aGfjD1YGJjSt+TL0rdiQTLtodpF5kf/j6Pw othExYiiQoemDJnBkRX0X7T10o0baCnxfWlv3KwtSYdf0iHOwTBM8pggRIyGf5JBaiRK YBZSQa8lfcCAuhH2hwTvIHBU2LeyizZrqo97LUh1gq17vixbEJpIajFMOXrsvxxStmsS +BEA== 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=7IBdjvFRag9yZE/BKc5brHAQDARDtIXaGhkF8uJXRlQ=; b=uZ4+iqqo3MqTbnO2p+L3+FLgVre6zXtHD+7H9yj9ZQQqoK9AkukH4tr+BbDq7IuV6b 9YCLgdogokqPl/L2AV0YVq9jU5fIvRMY0/4lejzE2XQl5K3gNl6Z5MPpYK3chav0hGYB JV5fVT8AkpFdOb481diKQqgHzl/rMjeIMU0PWmw2qpAs0dtSvfY6qzMy7Wv+aB6Z5eRQ moZi+Bh+VEgCqbS7WD/jBYmS78y4MBbWrtbONhJW/YfOKKeUI3dkSJjlySDsfCvogtLr aatQixiQ3w5AA7o5X39ktF8cmiJSX7PpIc8y8c1WXCOW8TXlIX0oytu/c9VjoEUIfYT5 yXhg== X-Gm-Message-State: APjAAAWvOyHgtY8lzWThkSAOApTAebbLiz7er62lF1CnT92i5caDebv0 u3uqwHF/Zg4Bk5guETqCyC8SuX0Rp+QZCxkw8fF3rA== X-Google-Smtp-Source: APXvYqzAhF+/72Zrdu85/2jD42Zoi8Td02RrL0uBou/vlg73GMNKwc0ffgSpLNGBhaZsCL3tktCpzfELeo9cOZYU61U= X-Received: by 2002:ac8:30f7:: with SMTP id w52mr1194993qta.380.1579162063680; Thu, 16 Jan 2020 00:07:43 -0800 (PST) MIME-Version: 1.0 References: <20200116062625.32692-1-dja@axtens.net> <20200116062625.32692-4-dja@axtens.net> In-Reply-To: <20200116062625.32692-4-dja@axtens.net> From: Dmitry Vyukov Date: Thu, 16 Jan 2020 09:07:32 +0100 Message-ID: Subject: Re: [PATCH v2 3/3] kasan: initialise array in kasan_memcmp test To: Daniel Axtens Cc: LKML , Linux-MM , kasan-dev , linuxppc-dev , Linux ARM , linux-s390 , linux-xtensa@linux-xtensa.org, "the arch/x86 maintainers" , 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, Jan 16, 2020 at 7:26 AM 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 a130d75b9385..519b0f259e97 100644 > --- a/lib/test_kasan.c > +++ b/lib/test_kasan.c > @@ -619,7 +619,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); > -- > 2.20.1 > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20200116062625.32692-4-dja%40axtens.net.