From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id CDA226B007E for ; Mon, 2 May 2016 08:04:58 -0400 (EDT) Received: by mail-ob0-f197.google.com with SMTP id rd14so218400437obb.3 for ; Mon, 02 May 2016 05:04:58 -0700 (PDT) Received: from out4435.biz.mail.alibaba.com (out4435.biz.mail.alibaba.com. [47.88.44.35]) by mx.google.com with ESMTP id oo7si13153256igb.67.2016.05.02.05.04.56 for ; Mon, 02 May 2016 05:04:58 -0700 (PDT) Message-ID: <5727438A.1040409@emindsoft.com.cn> Date: Mon, 02 May 2016 20:09:46 +0800 From: Chen Gang MIME-Version: 1.0 Subject: Re: [PATCH] mm/kasan/kasan.h: Fix boolean checking issue for kasan_report_enabled() References: <1462167374-6321-1-git-send-email-chengang@emindsoft.com.cn> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: owner-linux-mm@kvack.org List-ID: To: Alexander Potapenko Cc: Andrew Morton , Andrey Ryabinin , Dmitriy Vyukov , kasan-dev , LKML , Linux Memory Management List , Chen Gang On 5/2/16 19:34, Alexander Potapenko wrote: > On Mon, May 2, 2016 at 7:36 AM, wrote: >> From: Chen Gang >> >> According to kasan_[dis|en]able_current() comments and the kasan_depth' >> s initialization, if kasan_depth is zero, it means disable. > The comments for those functions are really poor, but there's nothing > there that says kasan_depth==0 disables KASAN. > Actually, kasan_report_enabled() is currently the only place that > denotes the semantics of kasan_depth, so it couldn't be wrong. > > init_task.kasan_depth is 1 during bootstrap and is then set to zero by > kasan_init() > For every other thread, current->kasan_depth is zero-initialized. > OK, what you said sound reasonable to me. and do you also mean: - kasan_depth == 0 means enable KASAN, others means disable KASAN. - If always let kasan_[en|dis]able_current() be pair, and notice about the overflow, it should be OK: "kasan_enable_current() can let kasan_depth++, and kasan_disable_current() will let kasan_depth--". - If we check the related overflow, "kasan_depth == 1" mean "the KASAN should be always in disable state". Thanks. -- Chen Gang (e??a??) Managing Natural Environments is the Duty of Human Beings. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753298AbcEBMFK (ORCPT ); Mon, 2 May 2016 08:05:10 -0400 Received: from out1134-201.mail.aliyun.com ([42.120.134.201]:38817 "EHLO out1134-201.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752459AbcEBMFF (ORCPT ); Mon, 2 May 2016 08:05:05 -0400 X-Greylist: delayed 3149 seconds by postgrey-1.27 at vger.kernel.org; Mon, 02 May 2016 08:05:05 EDT X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08455296|-1;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03296;MF=chengang@emindsoft.com.cn;NM=1;PH=DS;RN=8;RT=8;SR=0;TI=SMTPD_----4l9yTUe_1462190680; Message-ID: <5727438A.1040409@emindsoft.com.cn> Date: Mon, 02 May 2016 20:09:46 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Alexander Potapenko CC: Andrew Morton , Andrey Ryabinin , Dmitriy Vyukov , kasan-dev , LKML , Linux Memory Management List , Chen Gang Subject: Re: [PATCH] mm/kasan/kasan.h: Fix boolean checking issue for kasan_report_enabled() References: <1462167374-6321-1-git-send-email-chengang@emindsoft.com.cn> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/2/16 19:34, Alexander Potapenko wrote: > On Mon, May 2, 2016 at 7:36 AM, wrote: >> From: Chen Gang >> >> According to kasan_[dis|en]able_current() comments and the kasan_depth' >> s initialization, if kasan_depth is zero, it means disable. > The comments for those functions are really poor, but there's nothing > there that says kasan_depth==0 disables KASAN. > Actually, kasan_report_enabled() is currently the only place that > denotes the semantics of kasan_depth, so it couldn't be wrong. > > init_task.kasan_depth is 1 during bootstrap and is then set to zero by > kasan_init() > For every other thread, current->kasan_depth is zero-initialized. > OK, what you said sound reasonable to me. and do you also mean: - kasan_depth == 0 means enable KASAN, others means disable KASAN. - If always let kasan_[en|dis]able_current() be pair, and notice about the overflow, it should be OK: "kasan_enable_current() can let kasan_depth++, and kasan_disable_current() will let kasan_depth--". - If we check the related overflow, "kasan_depth == 1" mean "the KASAN should be always in disable state". Thanks. -- Chen Gang (陈刚) Managing Natural Environments is the Duty of Human Beings.