public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: John Belmonte <john-wanGne27zNesTnJN9+BGXg@public.gmane.org>
To: Sergey Vlasov <vsu-u2l5PoMzF/Uox3rIn2DAYQ@public.gmane.org>
Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: Re: toshiba_acpi 0.18
Date: Thu, 25 Mar 2004 10:48:28 -0500	[thread overview]
Message-ID: <4062FF4C.4000102@neggie.net> (raw)
In-Reply-To: <20040325173453.77fed4e9.vsu-u2l5PoMzF/Uox3rIn2DAYQ@public.gmane.org>

Sergey Vlasov wrote:
> On Sun, 14 Mar 2004 01:02:58 -0500 John Belmonte wrote:
> 
>> static int
>>-dispatch_write(struct file* file, const char* buffer, unsigned long count,
>>-	ProcItem* item)
>>+dispatch_write(struct file* file, __user const char* buffer,
>>+	unsigned long count, ProcItem* item)
>> {
>>-	return item->write_func(buffer, count);
>>+	int result;
>>+	char* tmp_buffer;
>>+
>>+	/* Arg buffer points to userspace memory, which can't be accessed
>>+	 * directly.  Since we're making a copy, zero-terminate the
>>+	 * destination so that sscanf can be used on it safely.
>>+	 */
>>+	tmp_buffer = kmalloc(count + 1, GFP_KERNEL);
>>+	if (copy_from_user(tmp_buffer, buffer, count)) {
>>+		result = -EFAULT;
>>+	}
>>+	else {
>>+		tmp_buffer[count] = 0;
>>+		result = item->write_func(tmp_buffer, count);
>>+	}
>>+	kfree(tmp_buffer);
>>+	return result;
>> }
> 
> 
> This is still not enough.  count comes from userspace and can be
> arbitrarily large, and this function does not even check the return
> value from kmalloc()...

The "count" arg is passed by value, so there is no issue.

You are right about not checking the kmalloc result for an error.  I'll 
fix that, but it's not enough to warrant a new release on its own.  The 
code before the patch had the same problem, so this is not a newly 
created bug, and not related to the problem being addressed.

-John


-- 
http:// if  ile.org/


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

  parent reply	other threads:[~2004-03-25 15:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-14  2:35 [PATCH] toshiba_acpi 0.18 John Belmonte
     [not found] ` <4053C4D5.8000703-wanGne27zNesTnJN9+BGXg@public.gmane.org>
2004-03-14  5:38   ` Len Brown
     [not found]     ` <1079242701.2168.121.camel-D2Zvc0uNKG8@public.gmane.org>
2004-03-14  6:02       ` John Belmonte
     [not found]         ` <4053F592.80001-wanGne27zNesTnJN9+BGXg@public.gmane.org>
2004-03-23  7:01           ` Len Brown
2004-03-25 14:34         ` Sergey Vlasov
     [not found]           ` <20040325173453.77fed4e9.vsu-u2l5PoMzF/Uox3rIn2DAYQ@public.gmane.org>
2004-03-25 15:48             ` John Belmonte [this message]
2004-03-14 13:07   ` [PATCH] " Karol Kozimor
     [not found]     ` <20040314130724.GA1994-DETuoxkZsSqrDJvtcaxF/A@public.gmane.org>
2004-03-23 23:24       ` Karol Kozimor
     [not found]         ` <20040323232438.GA9223-DETuoxkZsSqrDJvtcaxF/A@public.gmane.org>
2004-03-24  4:09           ` John Belmonte
     [not found]             ` <40610A01.9070904-wanGne27zNesTnJN9+BGXg@public.gmane.org>
2004-03-24 11:17               ` Karol Kozimor

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=4062FF4C.4000102@neggie.net \
    --to=john-wangne27znestnjn9+bgxg@public.gmane.org \
    --cc=acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=vsu-u2l5PoMzF/Uox3rIn2DAYQ@public.gmane.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