From patchwork Thu Jan 16 06:26:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 11336201 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 B174F138D for ; Thu, 16 Jan 2020 06:26:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F18F2087E for ; Thu, 16 Jan 2020 06:26:46 +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="GfTRpKom" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F18F2087E 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 7F24B8E003A; Thu, 16 Jan 2020 01:26:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 77B488E0026; Thu, 16 Jan 2020 01:26:45 -0500 (EST) 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 669A58E003A; Thu, 16 Jan 2020 01:26:45 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id 4A2D78E0026 for ; Thu, 16 Jan 2020 01:26:45 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 179AD180AD807 for ; Thu, 16 Jan 2020 06:26:45 +0000 (UTC) X-FDA: 76382513970.20.music64_ade928d1d11 X-Spam-Summary: 2,0,0,5d4bec54754c8ae8,d41d8cd98f00b204,dja@axtens.net,:linux-kernel@vger.kernel.org::kasan-dev@googlegroups.com:linuxppc-dev@lists.ozlabs.org:linux-arm-kernel@lists.infradead.org:linux-s390@vger.kernel.org:linux-xtensa@linux-xtensa.org:x86@kernel.org:dvyukov@google.com:christophe.leroy@c-s.fr:dja@axtens.net:aryabinin@virtuozzo.com:glider@google.com,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:2393:2553:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3870:3871:4321:5007:6119:6261:6653:8603:10004:11658:11914:12297:12517:12519:12555:12895:13069:13311:13357:13894:14181:14384:14394:14721:21080:21444:21451:21627:30012:30054:30090,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: music64_ade928d1d11 X-Filterd-Recvd-Size: 4132 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jan 2020 06:26:44 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id bg7so1077487pjb.5 for ; Wed, 15 Jan 2020 22:26:44 -0800 (PST) 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=SI5glm9tTBFJlI56hJYs/doyA7zUbu5YUKwxBp+hpYY=; b=GfTRpKom0tPQq8D4aXQyI2foQczp9UuJXSAyw66CT6hkWQrJmpym0PT6cvNRyGY8Uk 0VvHyXu1/QQxb3+Jjk5FQ//6OW1fSF4+GEXglW8TGLZKjd4szY+kf1EU0mFv2H1ywD7M VbwSiZQaQuyCsyymCLbnA4sRvShcMEGUaENZ4= 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=SI5glm9tTBFJlI56hJYs/doyA7zUbu5YUKwxBp+hpYY=; b=DBAweJycPyh+nt84/rzq7KE4Y+UhPW5yL+wU9F2jpAF2DJ23Zzrs3+xS825L7WQ7eY QKFnoGr8S4GeqI2eUAT06LohIQRHq8ZqD9sfDENVyMmnj8owIV5bhmY3hFylnlIQXpwq Diyxas/EQEtnkmI4isId5r6D1iXhpMbwuu1aXzB6SuB/CEUUMUESB6DTx19WK2uDD/Xc /ohaB0p/GUyoc1w2OllMp9F10uQ8WbxYdjVxgUUvFmmtWyZ8G2/RtW9Y5JyDyC71Pnz1 0nMis9uRUR2nCfVXi8ZgncLNjSdquFesSU5d3t6WoFfb2VxB2jppGnVpGb68IYe7ZywM qm9Q== X-Gm-Message-State: APjAAAW89VObAtrJKg8DQhG2cFsrBOUSN6KlLeDulU7/7J+JhWfiy4mh 8ha2y4ZoPhNNuSZR9vNFMGHH3Q== X-Google-Smtp-Source: APXvYqyt2Oz5lp6I4QYJC6msD4qYWnWAGuSCIA+DMfGiAHr8tDPwjSQJBDVs1A0BbM5XvepejAB4uQ== X-Received: by 2002:a17:902:6b8c:: with SMTP id p12mr29998912plk.290.1579156003508; Wed, 15 Jan 2020 22:26:43 -0800 (PST) Received: from localhost (2001-44b8-1113-6700-097c-7eed-afd4-cd15.static.ipv6.internode.on.net. [2001:44b8:1113:6700:97c:7eed:afd4:cd15]) by smtp.gmail.com with ESMTPSA id r3sm24681158pfg.145.2020.01.15.22.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2020 22:26:42 -0800 (PST) From: Daniel Axtens To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com Cc: linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-xtensa@linux-xtensa.org, x86@kernel.org, dvyukov@google.com, christophe.leroy@c-s.fr, Daniel Axtens , Andrey Ryabinin , Alexander Potapenko Subject: [PATCH v2 3/3] kasan: initialise array in kasan_memcmp test Date: Thu, 16 Jan 2020 17:26:25 +1100 Message-Id: <20200116062625.32692-4-dja@axtens.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200116062625.32692-1-dja@axtens.net> References: <20200116062625.32692-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 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);