From: Arjan van de Ven <arjan@infradead.org>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: Andrew Morton <akpm@osdl.org>,
Pekka J Enberg <penberg@cs.Helsinki.FI>,
linux-kernel@vger.kernel.org, pmarques@grupopie.com
Subject: Re: [PATCH] kernel: use kcalloc instead kmalloc/memset
Date: Fri, 05 Aug 2005 13:12:04 +0200 [thread overview]
Message-ID: <1123240325.3239.62.camel@laptopd505.fenrus.org> (raw)
In-Reply-To: <Pine.LNX.4.61.0508051254010.3743@scrub.home>
On Fri, 2005-08-05 at 12:56 +0200, Roman Zippel wrote:
> Hi,
>
> On Fri, 5 Aug 2005, Arjan van de Ven wrote:
>
> > > > we've had a non-negliable amount of security holes because of this
> > >
> > > So why don't we have a similiar kmalloc()?
> >
> > nope kmalloc is not an array allocator
> >
> > > > it makes it easy and safe. Of course you can and should check it in all
> > > > users. Just that using a safer API is generally better than forcing
> > > > everyone to do it themselves.
> > >
> > > How exactly does this make it a "safe API"? Even if it checks for this one
> > > case, it still makes the user suspectible for allocating big amounts of
> > > unswappable memory.
> >
> > 128Kb max.
>
> You completely missed the point and didn't answer my questions at all... :-(
I found it hard to understand your question.
Maybe it helps if I give the basic bug scenario first (pseudo C)
void some_ioctl_func(...)
{
int count, i;
struct foo *ptr;
copy_from_user(&count,...);
ptr = kmalloc(sizeof(struct foo) * count);
if (!ptr)
return -ENOMEM;
for (i=0; i<count; i++) {
initialize(ptr+i);
}
}
if the user picks count such that the multiplication overflows, the
kmalloc will actually *succeed* in getting a chunk between 0 and 128Kb.
The subsequent "fill the array up" will overwrite a LOT of kernel memory
though.
Fixing the hole of course involves checking "count" for too high a
value. Using kcalloc() will check for this same overflow inside kcalloc
and prevent it (eg return NULL) if one of these slips through.
next prev parent reply other threads:[~2005-08-05 11:12 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-05 5:29 Pekka Enberg
2005-08-05 5:38 ` Andrew Morton
2005-08-05 6:30 ` Pekka J Enberg
2005-08-05 6:36 ` Andrew Morton
2005-08-05 6:52 ` Pekka J Enberg
2005-08-06 15:09 ` Adrian Bunk
2005-08-08 10:11 ` Takashi Iwai
2005-08-08 21:05 ` Adrian Bunk
2005-08-09 10:09 ` Takashi Iwai
2005-08-05 9:37 ` Roman Zippel
2005-08-05 9:46 ` Arjan van de Ven
2005-08-05 9:59 ` Pekka J Enberg
2005-08-05 10:07 ` [PATCH] " Roman Zippel
2005-08-05 10:13 ` Arjan van de Ven
2005-08-05 10:32 ` Roman Zippel
2005-08-05 10:38 ` Arjan van de Ven
2005-08-05 10:56 ` Roman Zippel
2005-08-05 11:12 ` Arjan van de Ven [this message]
2005-08-06 0:40 ` Roman Zippel
2005-08-06 13:09 ` Pekka Enberg
2005-08-08 6:25 ` Jan Engelhardt
2005-08-05 17:49 ` Stephen Pollei
2005-08-05 18:16 ` Christoph Lameter
2005-08-05 18:39 ` Stephen Pollei
2005-08-05 10:15 ` Pekka J Enberg
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=1123240325.3239.62.camel@laptopd505.fenrus.org \
--to=arjan@infradead.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.Helsinki.FI \
--cc=pmarques@grupopie.com \
--cc=zippel@linux-m68k.org \
/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
all inboxes | Powered by JetHome®