From: BlaisorBlade <blaisorblade_spam@yahoo.it>
To: Marcelo Tosatti <marcelo.tosatti@cyclades.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH/2.4]: do_write_mem() return value check
Date: Fri, 26 Mar 2004 19:16:39 +0100 [thread overview]
Message-ID: <200403261916.39399.blaisorblade_spam@yahoo.it> (raw)
In-Reply-To: <20040326033339.GD1997@logos.cnet>
Alle 04:33, venerdì 26 marzo 2004, Marcelo Tosatti ha scritto:
> On Wed, Mar 24, 2004 at 07:59:01PM +0100, BlaisorBlade wrote:
> > From: Andrew Morton, and me (I did a first fix for 2.6 and sent to him,
> > he checked everything and committed it and I changed the trivial bits for
> > 2.4).
> Do you actually have any practical problem caused by the current broken
> "always return -EFAULT" ?
It is not only that, there can be also data corruption:
- The "always return -EFAULT" one is a little bug, so you can discard the
first and third hunk which fix that; anyway, it was Andrew Morton who noticed
that, so I've no idea (I agree with you but I'm a kernel newbie). Note I
posted a 2nd version of the patch which fixes a bug in the third hunk (see at
the end).
- BUT in the hunk below (the 2nd in the patch), without the patch, the var
"wrote" can be == -EFAULT and WE CAN DO
p += -EFAULT,
buf += -EFAULT;
so that we can read, afterwards, some bytes of junk from buf - EFAULT and put
them into p - EFAULT, *corrupting memory* !!!!
> > - Add checking for copy_from_user() failures in do_write_mem()
if (p < (unsigned long) high_memory) {
+ ssize_t written;
+
wrote = count;
if (count > (unsigned long) high_memory - p)
wrote = (unsigned long) high_memory - p;
- wrote = do_write_mem(file, (void*)p, p, buf, wrote, ppos);
+ written = do_write_mem((void*)p, p, buf, wrote, ppos);
+ if (written != wrote)
+ return written;
+ wrote = written;
p += wrote;
buf += -EFAULT;
Fix in the second version of the patch, for the 3rd hunk:
- Fix this line:
+ unwritten = copy_from_user(kbuf, buf, len);
+ if (unwritten != len) {
[... error handling]
to this:
+ unwritten = copy_from_user(kbuf, buf, len);
+ if (unwritten != 0) {
[...error handling]
--
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
next parent reply other threads:[~2004-03-27 4:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20040326033339.GD1997@logos.cnet>
2004-03-26 18:16 ` BlaisorBlade [this message]
[not found] <200403231707.14088.blaisorblade_work@yahoo.it>
2004-03-25 20:52 ` Marcelo Tosatti
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=200403261916.39399.blaisorblade_spam@yahoo.it \
--to=blaisorblade_spam@yahoo.it \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.tosatti@cyclades.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
all inboxes | Powered by JetHome®