Re: [PATCH] usb: use memdup_user()

From: Andrew Morton
Date: Tue May 05 2009 - 02:15:59 EST


On Mon, 4 May 2009 16:01:51 +0200 Oliver Neukum <oliver@xxxxxxxxxx> wrote:

> Am Montag, 4. Mai 2009 09:02:38 schrieb David Brownell:
> > On Sunday 03 May 2009, Oliver Neukum wrote:
> > > No. To make it plain. To me any use of memdup_user() in USB code
> > > is a bad idea. I don't want to have to think about a new primitive.
> >
> > Unless it's incorrect to use that, I have to say that it
> > makes more sense to use that utility than recreate it by
> > open-coding...
>
> I want people to be forced to think about memory allocations.
> We had endless trouble during 2.4 with storage deadlocking.
> We simply need full control of this.
>

thou-shalt-use-GFP_NOFS is a very common pattern in many filesystems.
And thou-shalt-use-GFP_NOIO is a very common pattern in block drivers.

I wonder how hard it would be to add runtime debugging checks? If
there are clearly identified transition points where (say) GFP_NOIO
becomes required and unrequired then we could do something along the
lines of

current->disallowed_gfp_flags |= __GFP_IO;
....
current->disallowed_gfp_flags &= ~__GFP_IO;

and check (gfp_flags & current->disallowed_gfp_flags) in the various
memory-allocation functions, and perhaps in the uaccess functions.

Or possibly teach lockdep about it, although that seems inappropriate.

Anyway. A little project for someone, perhaps.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/