linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: chengang@emindsoft.com.cn
To: akpm@linux-foundation.org, aryabinin@virtuozzo.com,
	glider@google.com, dvyukov@google.com
Cc: kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Chen Gang <chengang@emindsoft.com.cn>,
	Chen Gang <gang.chen.5i5j@gmail.com>
Subject: [PATCH] include/linux/kasan.h: Notice about 0 for kasan_[dis/en]able_current()
Date: Mon,  2 May 2016 13:35:48 +0800	[thread overview]
Message-ID: <1462167348-6280-1-git-send-email-chengang@emindsoft.com.cn> (raw)

From: Chen Gang <chengang@emindsoft.com.cn>

According to their comments and the kasan_depth's initialization, if
kasan_depth is zero, it means disable. So kasan_depth need consider
about the 0 overflow.

Also remove useless comments for dummy kasan_slab_free().

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 include/linux/kasan.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index 645c280..37fab04 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -32,13 +32,15 @@ static inline void *kasan_mem_to_shadow(const void *addr)
 /* Enable reporting bugs after kasan_disable_current() */
 static inline void kasan_enable_current(void)
 {
-	current->kasan_depth++;
+	if (current->kasan_depth + 1)
+		current->kasan_depth++;
 }
 
 /* Disable reporting bugs for current task */
 static inline void kasan_disable_current(void)
 {
-	current->kasan_depth--;
+	if (current->kasan_depth)
+		current->kasan_depth--;
 }
 
 void kasan_unpoison_shadow(const void *address, size_t size);
@@ -113,8 +115,6 @@ static inline void kasan_krealloc(const void *object, size_t new_size,
 
 static inline void kasan_slab_alloc(struct kmem_cache *s, void *object,
 				   gfp_t flags) {}
-/* kasan_slab_free() returns true if the object has been put into quarantine.
- */
 static inline bool kasan_slab_free(struct kmem_cache *s, void *object)
 {
 	return false;
-- 
1.9.3

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2016-05-02  5:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-02  5:35 chengang [this message]
2016-05-02 10:49 ` Alexander Potapenko
2016-05-02 11:20   ` Chen Gang
2016-05-02 11:23     ` Alexander Potapenko
2016-05-02 12:40       ` Chen Gang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462167348-6280-1-git-send-email-chengang@emindsoft.com.cn \
    --to=chengang@emindsoft.com.cn \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=dvyukov@google.com \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox