From: Andrew Morton <akpm@linux-foundation.org>
To: Vasiliy Kulikov <segoon@openwall.com>
Cc: kernel-janitors@vger.kernel.org, Dave Airlie <airlied@redhat.com>,
Tiago Vignatti <tiago.vignatti@nokia.com>,
Mike Travis <travis@sgi.com>, "H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] gpu: vga: limit kmalloc'ed memory size
Date: Mon, 22 Nov 2010 18:09:15 +0000 [thread overview]
Message-ID: <20101122100915.5bf966fe.akpm@linux-foundation.org> (raw)
In-Reply-To: <1290445864-13657-1-git-send-email-segoon@openwall.com>
On Mon, 22 Nov 2010 20:11:03 +0300 Vasiliy Kulikov <segoon@openwall.com> wrote:
> count is not checked before kmalloc() call. Too big value would
> generate stack dump. To prevent this limit 'count' maximum value.
> 1024 looks OK - the data should be the string of tens of bytes.
>
> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
> ---
> Compile tested only.
>
> v1 had incorrect comment text, as Dan Rosenberg noticed.
>
> drivers/gpu/vga/vgaarb.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
> index c380c65..09e3090 100644
> --- a/drivers/gpu/vga/vgaarb.c
> +++ b/drivers/gpu/vga/vgaarb.c
> @@ -836,6 +836,8 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf,
> int ret_val;
> int i;
>
> + if (count > 1024)
> + count = 1024;
>
> kbuf = kmalloc(count + 1, GFP_KERNEL);
> if (!kbuf)
Bit ugly, that.
Arguably we should just let the allocation attempt pass through to
kmalloc() and let kmalloc() return an error if it was too large. Possibly
we need a __GFP_NOWARN in there somewhere. Please send us that stack
dump?
The code should be using strndup_user() anyway. And perhaps
strndup_user() needs __GFP_NOWARN treatment.
next prev parent reply other threads:[~2010-11-22 18:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-22 17:11 [PATCH v2] gpu: vga: limit kmalloc'ed memory size Vasiliy Kulikov
2010-11-22 18:09 ` Andrew Morton [this message]
2010-11-23 19:08 ` Vasiliy Kulikov
2010-11-23 20:46 ` Andrew Morton
2010-11-24 18:33 ` Vasiliy Kulikov
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=20101122100915.5bf966fe.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=airlied@redhat.com \
--cc=hpa@zytor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=segoon@openwall.com \
--cc=tiago.vignatti@nokia.com \
--cc=travis@sgi.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