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.5 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 C0E11C33CB1 for ; Thu, 16 Jan 2020 08:09:51 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6EBB22077B for ; Thu, 16 Jan 2020 08:09:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="qfoDxmeh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EBB22077B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47yxgc6PnVzDqYt for ; Thu, 16 Jan 2020 19:09:48 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=google.com (client-ip=2607:f8b0:4864:20::844; helo=mail-qt1-x844.google.com; envelope-from=dvyukov@google.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=qfoDxmeh; dkim-atps=neutral Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47yxdK0M7SzDqXd for ; Thu, 16 Jan 2020 19:07:46 +1100 (AEDT) Received: by mail-qt1-x844.google.com with SMTP id 5so18199365qtz.1 for ; Thu, 16 Jan 2020 00:07:46 -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=ubJLtgCk0YeQDX+nsyQhEtcXDIRR7aSIVUNrc4lNMUXFM9XxCShKOvVpW/bqCc28bz 3/mwaSCuwTwC5EmmPgqA3ImjLr55u16EdcD7Vy2yGgPoBdP3ZUHiAHeZDaVzvZnz6D61 yhoriJyL4FvIo/idnjRJWCJeDagrhk22bvioKL9ScgeMnICr2WC+erar/8WHbFXUmvaz iNuPyGGOujpnpEPXmqUN0S9E3tXkx8h/OKRVg3FGiNuPo62vbQK7sK8Dpom5fk6TAX/Q 1OVPwQfT3PHK9CwWSVNuk4bPlIqXUyvTIEf4UTKlSNLZD6V+HyrCKcrsrIByHkl8jpAu ZCVg== X-Gm-Message-State: APjAAAXupDtVUjNzp3pNVJeR6O8fnfdrZ69XGJv686uZPEsCPhIXpzly K6VvwCcAqIxUrkeJ/TtlGV6zBzdLTyvCYRD1kyuVIQ== 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 Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-s390 , linux-xtensa@linux-xtensa.org, the arch/x86 maintainers , LKML , kasan-dev , Linux-MM , Alexander Potapenko , Andrey Ryabinin , linuxppc-dev , Linux ARM Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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.