From patchwork Wed Mar 11 13:42:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Wu X-Patchwork-Id: 11431793 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 8408B921 for ; Wed, 11 Mar 2020 13:43:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 507C222527 for ; Wed, 11 Mar 2020 13:43:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="idwf/PwL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 507C222527 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 557836B0003; Wed, 11 Mar 2020 09:43:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 508CE6B0006; Wed, 11 Mar 2020 09:43:19 -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 3F68E6B0007; Wed, 11 Mar 2020 09:43:19 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0054.hostedemail.com [216.40.44.54]) by kanga.kvack.org (Postfix) with ESMTP id 2473C6B0003 for ; Wed, 11 Mar 2020 09:43:19 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EF8E2942A for ; Wed, 11 Mar 2020 13:43:18 +0000 (UTC) X-FDA: 76583198118.05.apple40_1cd18fa233244 X-Spam-Summary: 2,0,0,e1c0593b5a51ab33,d41d8cd98f00b204,walter-zh.wu@mediatek.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1185:1260:1277:1311:1313:1314:1345:1431:1437:1514:1515:1516:1518:1534:1541:1585:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3867:3870:3872:3874:4321:4385:5007:6119:6261:6653:8603:10004:10400:11026:11658:11914:12043:12048:12295:12296:12297:12438:12521:12555:12895:12986:13069:13221:13229:13311:13357:14181:14394:14721:21080:21451:21627:21660:21796:30034:30036:30054,0,RBL:210.61.82.183:@mediatek.com:.lbl8.mailshell.net-64.100.201.201 62.2.12.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:102,LUA_SUMMARY:none X-HE-Tag: apple40_1cd18fa233244 X-Filterd-Recvd-Size: 4190 Received: from mailgw01.mediatek.com (unknown [210.61.82.183]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Mar 2020 13:43:17 +0000 (UTC) X-UUID: 4ccf4a7c67bc4639b58278874f1ba63b-20200311 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=A72jYG29ZYGID3peLueFYfZ09ab4hxkJOXi8FenC89M=; b=idwf/PwLyaHjJ6WkHCzFSRrOGds9HsrQmOGkGMZxxq6CFiZw/hm7kM7+1lAtuH6+dq8ZTRamOg7hmUjiyLGXV39n2PzKUMw+qvy4jb67Q5amB7tiad1MJy1LsN87/ATiVCovU0dkiRaQrAUq04nZY7pGvyMgqdsqLollN6h5IHw=; X-UUID: 4ccf4a7c67bc4639b58278874f1ba63b-20200311 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1806468321; Wed, 11 Mar 2020 21:43:12 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 11 Mar 2020 21:42:13 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 11 Mar 2020 21:43:18 +0800 From: Walter Wu To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Qian Cai , Andrew Morton , Stephen Rothwell CC: , , , , wsd_upstream , Walter Wu Subject: [PATCH -next] kasan: fix -Wstringop-overflow warning Date: Wed, 11 Mar 2020 21:42:44 +0800 Message-ID: <20200311134244.13016-1-walter-zh.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N 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: Compiling with gcc-9.2.1 points out below warnings. In function 'memmove', inlined from 'kmalloc_memmove_invalid_size' at lib/test_kasan.c:301:2: include/linux/string.h:441:9: warning: '__builtin_memmove' specified bound 18446744073709551614 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=] Why generate this warnings? Because our test function deliberately pass a negative number in memmove(), so we need to make it "volatile" so that compiler doesn't see it. Reported-by: Stephen Rothwell Cc: Dmitry Vyukov Cc: Andrey Ryabinin Cc: Qian Cai Cc: Andrew Morton Signed-off-by: Walter Wu --- lib/test_kasan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index f123b4b8aadf..e3087d90e00d 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -289,6 +289,7 @@ static noinline void __init kmalloc_memmove_invalid_size(void) { char *ptr; size_t size = 64; + volatile size_t invalid_size = -2; pr_info("invalid size in memmove\n"); ptr = kmalloc(size, GFP_KERNEL); @@ -298,7 +299,7 @@ static noinline void __init kmalloc_memmove_invalid_size(void) } memset((char *)ptr, 0, 64); - memmove((char *)ptr, (char *)ptr + 4, -2); + memmove((char *)ptr, (char *)ptr + 4, invalid_size); kfree(ptr); }