From patchwork Sat Nov 20 00:43:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12629935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10FA8C433F5 for ; Sat, 20 Nov 2021 00:49:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDEBB6B0082; Fri, 19 Nov 2021 19:43:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D8BDE6B0083; Fri, 19 Nov 2021 19:43:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7BA16B0085; Fri, 19 Nov 2021 19:43:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id BA9B26B0082 for ; Fri, 19 Nov 2021 19:43:58 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 82FA2181B048C for ; Sat, 20 Nov 2021 00:43:48 +0000 (UTC) X-FDA: 78827460936.23.AAF377C Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf15.hostedemail.com (Postfix) with ESMTP id B2CCED0000A8 for ; Sat, 20 Nov 2021 00:43:45 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A4316137B; Sat, 20 Nov 2021 00:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1637369027; bh=YQCDfguLNjM5kMCoiYTU0Dw3Z+Q5SerasjidDCmpaHw=; h=Date:From:To:Subject:In-Reply-To:From; b=b6nAFp/FH9AS2/05mW1dyslYcxwW7CakBFOGfM7PERPO5AGhn1uwvjRVcSVKmP9AD KxjemqsaLyyfDCmD4xRoaaXz3GLycTrePy99ouOhfVb1a+ayC1z0Y+mOqr+gCl1wxa czM34+sVk9oTJKDhb7Fk15zNB35lXsRP2tU+NF1A= Date: Fri, 19 Nov 2021 16:43:46 -0800 From: Andrew Morton To: akpm@linux-foundation.org, andreyknvl@gmail.com, dvyukov@google.com, elver@google.com, glider@google.com, keescook@chromium.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, ryabinin.a.a@gmail.com, torvalds@linux-foundation.org Subject: [patch 11/15] kasan: test: silence intentional read overflow warnings Message-ID: <20211120004346.6GSSdDImN%akpm@linux-foundation.org> In-Reply-To: <20211119164248.50feee07c5d2cc6cc4addf97@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: B2CCED0000A8 X-Stat-Signature: f8ytnz3qub5yrth1xpmktp76nrchk8bs Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="b6nAFp/F"; dmarc=none; spf=pass (imf15.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam02 X-HE-Tag: 1637369025-986706 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: From: Kees Cook Subject: kasan: test: silence intentional read overflow warnings As done in commit d73dad4eb5ad ("kasan: test: bypass __alloc_size checks") for __write_overflow warnings, also silence some more cases that trip the __read_overflow warnings seen in 5.16-rc1[1]: In file included from /kisskb/src/include/linux/string.h:253, from /kisskb/src/include/linux/bitmap.h:10, from /kisskb/src/include/linux/cpumask.h:12, from /kisskb/src/include/linux/mm_types_task.h:14, from /kisskb/src/include/linux/mm_types.h:5, from /kisskb/src/include/linux/page-flags.h:13, from /kisskb/src/arch/arm64/include/asm/mte.h:14, from /kisskb/src/arch/arm64/include/asm/pgtable.h:12, from /kisskb/src/include/linux/pgtable.h:6, from /kisskb/src/include/linux/kasan.h:29, from /kisskb/src/lib/test_kasan.c:10: In function 'memcmp', inlined from 'kasan_memcmp' at /kisskb/src/lib/test_kasan.c:897:2: /kisskb/src/include/linux/fortify-string.h:263:25: error: call to '__read_overflow' declared with attribute error: detected read beyond size of object (1st parameter) 263 | __read_overflow(); | ^~~~~~~~~~~~~~~~~ In function 'memchr', inlined from 'kasan_memchr' at /kisskb/src/lib/test_kasan.c:872:2: /kisskb/src/include/linux/fortify-string.h:277:17: error: call to '__read_overflow' declared with attribute error: detected read beyond size of object (1st parameter) 277 | __read_overflow(); | ^~~~~~~~~~~~~~~~~ [1] http://kisskb.ellerman.id.au/kisskb/buildresult/14660585/log/ Link: https://lkml.kernel.org/r/20211116004111.3171781-1-keescook@chromium.org Fixes: d73dad4eb5ad ("kasan: test: bypass __alloc_size checks") Signed-off-by: Kees Cook Reviewed-by: Andrey Konovalov Acked-by: Marco Elver Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Dmitry Vyukov Signed-off-by: Andrew Morton --- lib/test_kasan.c | 2 ++ 1 file changed, 2 insertions(+) --- a/lib/test_kasan.c~kasan-test-silence-intentional-read-overflow-warnings +++ a/lib/test_kasan.c @@ -869,6 +869,7 @@ static void kasan_memchr(struct kunit *t ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); + OPTIMIZER_HIDE_VAR(size); KUNIT_EXPECT_KASAN_FAIL(test, kasan_ptr_result = memchr(ptr, '1', size + 1)); @@ -894,6 +895,7 @@ static void kasan_memcmp(struct kunit *t KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); memset(arr, 0, sizeof(arr)); + OPTIMIZER_HIDE_VAR(size); KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = memcmp(ptr, arr, size+1)); kfree(ptr);