From: Dave Hansen <haveblue@us.ibm.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
sharyathi@in.ibm.com
Subject: [PATCH] undo do_readv_writev() behavior change
Date: Thu, 31 Mar 2005 14:20:20 -0800 [thread overview]
Message-ID: <1112307620.20331.8.camel@localhost> (raw)
[-- Attachment #1: Type: text/plain, Size: 912 bytes --]
Bugme bug 4326: http://bugme.osdl.org/show_bug.cgi?id=4326 reports:
> Problem Description:
> On executing the systemcall readv with Bad argument
> (iovec->len == -1) it gives out error EFAULT instead of EINVAL
This is not a serious bug, but is a slight behavior change. This changeset:
http://linus.bkbits.net:8080/linux-2.5/cset@4202616998ECZp5x5NfCDbX9JcEG7g?nav=index.html|src/|src/fs|related/fs/read_write.c
does an access_ok() check before the 'len < 0' check, in
do_readv_writev() so it now does an EFAULT instead of EVINAL for the -1
length argument.
> for (seg = 0; seg < nr_segs; seg++) {
...
> + if (unlikely(!access_ok(vrfy_dir(type), buf, len)))
> + goto Efault;
> if (len < 0) /* size_t not fitting an ssize_t .. */
> goto out;
> tot_len += len;
The attached path moves the access check to after the len check, to make
it behave a little more like it did before.
-- Dave
[-- Attachment #2: do_readv_writev-bugno-4326.patch --]
[-- Type: text/x-patch, Size: 598 bytes --]
--- linux-2.6/fs/read_write.c.orig 2005-03-31 14:02:03.940333696 -0800
+++ linux-2.6/fs/read_write.c 2005-03-31 14:03:24.651063800 -0800
@@ -467,10 +467,10 @@ static ssize_t do_readv_writev(int type,
void __user *buf = iov[seg].iov_base;
ssize_t len = (ssize_t)iov[seg].iov_len;
- if (unlikely(!access_ok(vrfy_dir(type), buf, len)))
- goto Efault;
if (len < 0) /* size_t not fitting an ssize_t .. */
goto out;
+ if (unlikely(!access_ok(vrfy_dir(type), buf, len)))
+ goto Efault;
tot_len += len;
if ((ssize_t)tot_len < 0) /* maths overflow on the ssize_t */
goto out;
reply other threads:[~2005-03-31 22:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1112307620.20331.8.camel@localhost \
--to=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sharyathi@in.ibm.com \
--cc=torvalds@osdl.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.