[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110305162508.GA11120@thunk.org>
Date: Sat, 5 Mar 2011 11:25:08 -0500
From: Ted Ts'o <tytso@....edu>
To: Matt Mackall <mpm@...enic.com>
Cc: Pekka Enberg <penberg@...nel.org>,
Dan Rosenberg <drosenberg@...curity.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Dave Hansen <dave@...ux.vnet.ibm.com>, cl@...ux-foundation.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Ingo Molnar <mingo@...e.hu>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] Make /proc/slabinfo 0400
On Fri, Mar 04, 2011 at 05:02:36PM -0600, Matt Mackall wrote:
> copies too many bytes from userspace. Every piece of code writes its own
> bound checks on copy_from_user, for instance, and gets it wrong by
> hitting signed/unsigned issues, alignment issues, etc. that are on the
> very edge of the average C coder's awareness.
Agreed. Maybe something that would help is to have helper routines
which handle the most common patterns that driver writers need. Some
of the most common that I've seen from doing a quick survey are:
1) kmalloc() followed by copy_from_user()
2) kmem_cache_alloc() followed by copy_from_user()
3) copy_from_user() to a buffer allocated on the stack, where the length
is passed in from userspace, and the maximum expected input size is
declared by the driver. (Used by debugfs, proc, and sysfs handlers)
4) copy_from_user() to a structure allocated on the stack
If we had wrappers for the most common cases, then any cases that were
left that used copy_from_user() explicitly could be flagged and
checked by hand, since they would be exception, and not the rule.
- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists