lkml.org 
[lkml]   [2005]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kernel: use kcalloc instead kmalloc/memset
On 8/5/05, Roman Zippel <zippel@linux-m68k.org> wrote:
> On Fri, 5 Aug 2005, Arjan van de Ven wrote:
> > > This would imply a similiar kmalloc() would be useful as well.
> > > Second, how relevant is it for the kernel?

> > we've had a non-negliable amount of security holes because of this

> So why don't we have a similiar kmalloc()?

You mean something like:

static void __bad_kmalloc_safe_nonconstant_size(void);
static void __bad_kmalloc_safe_zero_size(void);
static void __bad_kmalloc_safe_too_large_size(void);
static void __bad_kmalloc_safe_too_large(void);
static inline void *kmalloc_safe(size_t nmemb, size_t size,int flags) {
if (!__builtin_constant_p(size))
__bad_kmalloc_safe_nonconstant_size();
if ( !size )
__bad_kmalloc_safe_zero_size();
if ( size > 0x10000)
__bad_kmalloc_safe_too_large_size();
if (__builtin_constant_p(nmemb) && nmemb > 0x20000/size)
__bad_kmalloc_safe_too_large();
if (nmemb <= 0x20000/size)
return kmalloc(nmemb*size,flags);
else return 0; }


--
http://dmoz.org/profiles/pollei.html
http://sourceforge.net/users/stephen_pollei/
http://www.orkut.com/Profile.aspx?uid=2455954990164098214
http://stephen_pollei.home.comcast.net/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-08-05 19:54    [W:0.083 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site