From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753599AbbINBSN (ORCPT ); Sun, 13 Sep 2015 21:18:13 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:35092 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753134AbbINBSM (ORCPT ); Sun, 13 Sep 2015 21:18:12 -0400 Message-ID: <55F62037.30506@huawei.com> Date: Mon, 14 Sep 2015 09:17:43 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Andrew Morton CC: Andrey Konovalov , Rusty Russell , Michal Marek , "long.wanglong" , Linux MM , LKML , Andrey Ryabinin Subject: Re: [PATCH] kasan: use IS_ALIGNED in memory_is_poisoned_8() References: <55F23635.1010109@huawei.com> <20150911154730.3a2151a0b111fed01acdaaa1@linux-foundation.org> In-Reply-To: <20150911154730.3a2151a0b111fed01acdaaa1@linux-foundation.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.55F6204F.0013,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f59a4918e55e1ebf50c2d061ea575b34 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015/9/12 6:47, Andrew Morton wrote: > On Fri, 11 Sep 2015 10:02:29 +0800 Xishi Qiu wrote: > >> Use IS_ALIGNED() to determine whether the shadow span two bytes. >> It generates less code and more readable. >> > > Please cc Andrey Ryabinin on kasan patches. Sorry, my mistake. > >> --- a/mm/kasan/kasan.c >> +++ b/mm/kasan/kasan.c >> @@ -120,7 +120,7 @@ static __always_inline bool memory_is_poisoned_8(unsigned long addr) >> if (memory_is_poisoned_1(addr + 7)) >> return true; >> >> - if (likely(((addr + 7) & KASAN_SHADOW_MASK) >= 7)) >> + if (likely(IS_ALIGNED(addr, 8))) >> return false; > > Wouldn't IS_ALIGNED(addr, KASAN_SHADOW_SCALE_SIZE) be more appropriate? > OK, I'll send V2. > But I'm not really sure what the original code is trying to do. > > if ((addr + 7) & 7) >= 7) > > can only evaluate true if ((addr + 7) & 7) equals 7, so the ">=" could > be "==". > I think it should be "==", the value will not "> 7" > I think. The code looks a bit weird. A code comment would help. > > And how come memory_is_poisoned_16() does IS_ALIGNED(addr, 8)? Should > it be 16? No, it is to determine whether the shadow span two bytes(8 bytes, not 16). Thanks, Xishi Qiu > > > . >