From: Michael Buesch <mb@bu3sch.de>
To: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: ibm-acpi-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] thinkpad-acpi: Avoid heap buffer overrun
Date: Tue, 21 Jul 2009 12:17:47 +0200 [thread overview]
Message-ID: <200907211217.47484.mb@bu3sch.de> (raw)
In-Reply-To: <200907211216.18135.mb@bu3sch.de>
On Tuesday 21 July 2009 12:16:17 Michael Buesch wrote:
> Avoid a heap buffer overrun triggered by an integer overflow of the userspace
> controlled "count" variable.
> If userspace passes in a "count" of (size_t)-1l, the kmalloc size will overflow
> to ((size_t)-1l + 2) = 1, so only one byte will be allocated. However, copy_from_user()
> will attempt to copy 0xFFFFFFFF (or 0xFFFFFFFFFFFFFFFF on 64bit) bytes to the buffer.
>
> A possible testcase could look like this:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <fcntl.h>
>
> int main(int argc, char **argv)
> {
> int fd;
> char c;
>
> if (argc != 2) {
> printf("Usage: %s /proc/acpi/ibm/filename\n", argv[0]);
> return 1;
> }
> fd = open(argv[1], O_RDWR);
> if (fd < 0) {
> printf("Could not open proc file\n");
> return 1;
> }
> write(fd, &c, (size_t)-1l);
> }
>
> We avoid the integer overrun by putting an arbitrary limit on the count.
> PAGE_SIZE sounds like a sane limit.
>
> Signed-off-by: Michael Buesch <mb@bu3sch.de>
Whoops, forgot
Cc: stable@kernel.org
--
Greetings, Michael.
next prev parent reply other threads:[~2009-07-21 10:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-21 10:16 [PATCH] thinkpad-acpi: Avoid heap buffer overrun Michael Buesch
2009-07-21 10:17 ` Michael Buesch [this message]
2009-07-21 10:47 ` Michael Buesch
2009-07-21 15:50 ` Henrique de Moraes Holschuh
-- strict thread matches above, loose matches on Subject: below --
2009-07-21 16:51 Henrique de Moraes Holschuh
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=200907211217.47484.mb@bu3sch.de \
--to=mb@bu3sch.de \
--cc=hmh@hmh.eng.br \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.