From: Petr Tesarik <ptesarik@suse.cz>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] /dev/mem: handle out-of-bounds read/write
Date: Thu, 30 Jan 2014 15:03:32 +0100 [thread overview]
Message-ID: <20140130150332.64419aee@hananiah.suse.cz> (raw)
In-Reply-To: <20140130132827.GA22557@kroah.com>
On Thu, 30 Jan 2014 05:28:27 -0800
Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> On Thu, Jan 30, 2014 at 09:48:02AM +0100, Petr Tesarik wrote:
> > The loff_t type may be wider than phys_addr_t (e.g. on 32-bit systems).
> > Consequently, the file offset may be truncated in the assignment.
> > Currently, /dev/mem wraps around, which may cause applications to read
> > or write incorrect regions of memory by accident.
>
> Does that really happen? If so, that's a userspace bug, right?
In my case, it was a userspace bug, indeed. But debugging would have
been much easier if I saw read() fail with an EOF condition, rather
than pretend that it actually read some bytes (from above 4G) on a
32-bit box.
> > Let's follow POSIX file semantics here and return 0 when reading from
> > and -EFBIG when writing to an offset that cannot be represented by a
> > phys_addr_t.
> >
> > Note that the conditional is optimized out by the compiler if loff_t
> > has the same size as phys_addr_t.
> >
> > Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
> > ---
> > drivers/char/mem.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
>
> What is going to break if we apply this patch? :)
Nothing, unless it was broken already. I mean, if anyone is trying to
play dirty tricks with 32-bit file offset overflow, I'd call such code
sick and broken.
And on 64-bit platforms, the patch does not even change the generated
code.
Petr T
next prev parent reply other threads:[~2014-01-30 14:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-30 8:48 Petr Tesarik
2014-01-30 13:28 ` Greg Kroah-Hartman
2014-01-30 14:03 ` Petr Tesarik [this message]
2014-01-30 15:04 ` Greg Kroah-Hartman
2014-04-01 9:29 ` Petr Tesarik
2014-04-01 15:44 ` Greg Kroah-Hartman
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=20140130150332.64419aee@hananiah.suse.cz \
--to=ptesarik@suse.cz \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--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 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®