From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Davi Arnaut <davi.arnaut@gmail.com>
Cc: kosaki.motohiro@jp.fujitsu.com,
Americo Wang <xiyou.wangcong@gmail.com>,
Li Zefan <lizf@cn.fujitsu.com>,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [RFC][PATCH] kmemdup_from_user(): introduce
Date: Fri, 6 Mar 2009 17:03:29 +0900 (JST) [thread overview]
Message-ID: <20090306164445.7BE4.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <20090306163600.3469.A69D9226@jp.fujitsu.com>
(cc to Davi Arnaut)
> > > /**
> > >+ * kmemdup_from_user - duplicate memory region from user space
> > >+ *
> > >+ * @src: source address in user space
> > >+ * @len: number of bytes to copy
> > >+ * @gfp: GFP mask to use
> > >+ */
> > >+void *kmemdup_from_user(const void __user *src, size_t len, gfp_t gfp)
> > >+{
> > >+ void *p;
> > >+
> > >+ p = kmalloc_track_caller(len, gfp);
> >
> >
> > Well, you use kmalloc_track_caller, instead of kmalloc as you showed
> > above. :) Why don't you mention this?
>
> kmalloc() wrapper function must use kmalloc_track_caller().
I find another kmalloc() usage in the same file.
Davi, Can you agree following patch?
==
Subject: [PATCH] Don't use kmalloc() in strndup_user(). instead, use kmalloc_track_caller().
kmalloc() wrapper function should use kmalloc_track_caller() instead
kmalloc().
slab.h talk about the reason.
/*
* kmalloc_track_caller is a special version of kmalloc that records the
* calling function of the routine calling it for slab leak tracking instead
* of just the calling function (confusing, eh?).
* It's useful when the call to kmalloc comes from a widely-used standard
* allocator where we care about the real place the memory allocation
* request comes from.
*/
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
mm/util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mm/util.c b/mm/util.c
index 37eaccd..202da19 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -167,7 +167,7 @@ char *strndup_user(const char __user *s, long n)
if (length > n)
return ERR_PTR(-EINVAL);
- p = kmalloc(length, GFP_KERNEL);
+ p = kmalloc_track_caller(length, GFP_KERNEL);
if (!p)
return ERR_PTR(-ENOMEM);
--
1.6.1.2
--
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>
next prev parent reply other threads:[~2009-03-06 8:03 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-06 7:04 Li Zefan
2009-03-06 7:23 ` Américo Wang
2009-03-06 7:37 ` KOSAKI Motohiro
2009-03-06 8:03 ` KOSAKI Motohiro [this message]
2009-03-06 7:39 ` Li Zefan
2009-03-06 8:20 ` Alexey Dobriyan
2009-03-06 8:27 ` Li Zefan
2009-03-06 8:39 ` Andrew Morton
2009-03-06 8:57 ` Alexey Dobriyan
2009-03-06 9:09 ` KOSAKI Motohiro
2009-03-06 9:01 ` Li Zefan
2009-03-06 9:15 ` Andrew Morton
2009-03-06 9:49 ` [PATCH -v2] memdup_user(): introduce Li Zefan
2009-03-06 23:03 ` Andrew Morton
2009-03-07 16:48 ` Arjan van de Ven
2009-03-07 16:54 ` Roland Dreier
2009-03-07 18:27 ` Andrew Morton
2009-03-09 2:22 ` Li Zefan
2009-03-09 3:00 ` Andrew Morton
2009-03-09 3:30 ` Li Zefan
2009-03-09 3:45 ` Andrew Morton
2009-03-06 9:03 ` [RFC][PATCH] kmemdup_from_user(): introduce Alexey Dobriyan
2009-03-06 9:02 ` Li Zefan
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=20090306164445.7BE4.A69D9226@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=davi.arnaut@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.com \
--cc=xiyou.wangcong@gmail.com \
/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