From patchwork Thu Apr 23 15:45:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 11505965 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FD6E912 for ; Thu, 23 Apr 2020 15:45:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1C8F020776 for ; Thu, 23 Apr 2020 15:45:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=axtens.net header.i=@axtens.net header.b="IqBvaW2G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C8F020776 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 10C448E0008; Thu, 23 Apr 2020 11:45:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 093C28E0003; Thu, 23 Apr 2020 11:45:24 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEB6E8E0008; Thu, 23 Apr 2020 11:45:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CEC4F8E0003 for ; Thu, 23 Apr 2020 11:45:23 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 913FF181AC9C6 for ; Thu, 23 Apr 2020 15:45:23 +0000 (UTC) X-FDA: 76739544126.08.book93_693fccf178b60 X-Spam-Summary: 2,0,0,96ed7bd097e90c9c,d41d8cd98f00b204,dja@axtens.net,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1534:1541:1711:1730:1747:1777:1792:2380:2393:2553:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3870:3871:4321:5007:6119:6261:6653:8603:10004:11658:11914:12048:12297:12517:12519:12555:12895:12986:13069:13311:13357:13894:14181:14384:14394:14721:21080:21444:21451:21627:30012:30054:30090,0,RBL:209.85.215.195:@axtens.net:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: book93_693fccf178b60 X-Filterd-Recvd-Size: 4051 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Thu, 23 Apr 2020 15:45:23 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id d17so3096836pgo.0 for ; Thu, 23 Apr 2020 08:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+SloOzgks90oP9C6mvgapac7rntE6LuQE/iY+UvGdqE=; b=IqBvaW2GJu0QG+ZWgBIXE1KXL1ya6B4MBW23tQvRqVMiJqNihLu7ElQNpdOWuKXf2D e7fOcA8oeZHNM3l4zTGseuDdu7cySBLdVZCmqMt5FT1XF4o5RIHje5hfbbfRfuuQIF9l wlt0YjK5vcwOmbln9gLApxVOyBNzdy/PZ8FPk= 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+SloOzgks90oP9C6mvgapac7rntE6LuQE/iY+UvGdqE=; b=SKqaK39zuMzMD6Qb4cgmbS3XQvP9XwHpYr0RdicMT5KZfb+uqnoTKJtEffa7U2RhWE Pqh0lOnNs70BRRrLTpMCTl4wxFyh2HXnbXunvBDsmJ+/qlO9+fr93Xftuvd0/nwiVo/8 a5OaX+KXTQnWDaSYwTlNgwEjdO8vXl9/IlzEdjXpHW+iqAUCEziwwLz2YucSDfHC/4sm r7RvghdliagWmVSJZxFyA0fxooUKPcbM5sG05R8m5LWEcmMKqH4htIL1J5hS8Q61L0dn 4s66EqXv/1GTMUKkEYVAZRvyAzbRz3pNtf6wg849ZzADmPndi5yLAh+Az6AIO+DQWUWP kBeQ== X-Gm-Message-State: AGi0PuZqDr0MyL4cYNHXIGhdJT2sm9cJUnQfqttqRrjLNjKjyg/UzyWp OnWZONmcKj3lfJFj5KfH5B3cEg== X-Google-Smtp-Source: APiQypI9GuOWUlHBu6sSOoBDP8OTkF209Ci68BXqNi3aY+8I1lm6ymh949tU0rIRJW1ZfPbwVMB3sQ== X-Received: by 2002:aa7:9f0a:: with SMTP id g10mr4217244pfr.109.1587656722363; Thu, 23 Apr 2020 08:45:22 -0700 (PDT) Received: from localhost (2001-44b8-111e-5c00-7979-720a-9390-aec6.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:7979:720a:9390:aec6]) by smtp.gmail.com with ESMTPSA id z6sm2200624pgg.39.2020.04.23.08.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 08:45:21 -0700 (PDT) From: Daniel Axtens To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, kasan-dev@googlegroups.com Cc: dvyukov@google.com, christophe.leroy@c-s.fr, Daniel Axtens , Andrey Ryabinin , Alexander Potapenko Subject: [PATCH v3 3/3] kasan: initialise array in kasan_memcmp test Date: Fri, 24 Apr 2020 01:45:03 +1000 Message-Id: <20200423154503.5103-4-dja@axtens.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200423154503.5103-1-dja@axtens.net> References: <20200423154503.5103-1-dja@axtens.net> MIME-Version: 1.0 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: 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);