linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: 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 12:03:13 +0300	[thread overview]
Message-ID: <20090306090313.GB4225@x200.localdomain> (raw)
In-Reply-To: <49B0DE89.9000401@cn.fujitsu.com>

On Fri, Mar 06, 2009 at 04:27:53PM +0800, Li Zefan wrote:
> Alexey Dobriyan wrote:
> > On Fri, Mar 06, 2009 at 03:04:12PM +0800, Li Zefan wrote:
> >> I notice there are many places doing copy_from_user() which follows
> >> kmalloc():
> >>
> >>         dst = kmalloc(len, GFP_KERNEL);
> >>         if (!dst)
> >>                 return -ENOMEM;
> >>         if (copy_from_user(dst, src, len)) {
> >> 		kfree(dst);
> >> 		return -EFAULT
> >> 	}
> >>
> >> kmemdup_from_user() is a wrapper of the above code. With this new
> >> function, we don't have to write 'len' twice, which can lead to
> >> typos/mistakes. It also produces smaller code.
> > 
> > Name totally sucks, it mixes kernel idiom of allocation with purely
> > userspace function.
> > 
> 
> I'm not good at English, and I don't know why "kernel memory duplicated
> from user space" is so bad...
> 
> or memdup_user() ?
> 
> >> A qucik grep shows 250+ places where kmemdup_from_user() *may* be
> >> used. I'll prepare a patchset to do this conversion.
> > 
> > 250?
> > 
> 
> I just found out how many copy_from_user() following km/zalloc(), so
> not all of them are replace-able.
> 
> > Let's not add wrapper for every two lines that happen to be used
> > together.
> > 
> 
> Why not if we have good reasons? And I don't think we can call this
> "happen to" if there are 250+ of them?

Please, read through them. This "250+" number suddenly will become
like 20, because wrapper is not good enough.

--
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>

  parent reply	other threads:[~2009-03-06  8:56 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
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     ` Alexey Dobriyan [this message]
2009-03-06  9:02       ` [RFC][PATCH] kmemdup_from_user(): introduce 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=20090306090313.GB4225@x200.localdomain \
    --to=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizf@cn.fujitsu.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