From: Dave Hansen Date: Sat, 16 Apr 2005 22:25:49 +0000 (-0700) Subject: [PATCH] undo do_readv_writev() behavior change X-Git-Tag: v2.6.12-rc3~110 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f08ad02379530e1c970d3d104343b9907b4d1b4;p=linux-2.6 [PATCH] undo do_readv_writev() behavior change Bugme bug 4326: http://bugme.osdl.org/show_bug.cgi?id=4326 reports: executing the systemcall readv with Bad argument ->len == -1) it gives out error EFAULT instead of EINVAL Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/read_write.c b/fs/read_write.c index 6be4b1a195..c4c2bee373 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -467,10 +467,10 @@ static ssize_t do_readv_writev(int type, struct file *file, 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;