From: "Américo Wang" <xiyou.wangcong@gmail.com>
To: Dan Carpenter <error27@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Simon Kagstrom <simon.kagstrom@netinsight.net>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] kexec: return -EFAULT on copy_to_user() failures
Date: Thu, 29 Jul 2010 15:58:15 +0800 [thread overview]
Message-ID: <20100729075815.GA5555@cr0.nay.redhat.com> (raw)
In-Reply-To: <20100729073609.GR26313@bicker>
On Thu, Jul 29, 2010 at 09:36:10AM +0200, Dan Carpenter wrote:
>copy_to/from_user() returns the number of bytes remaining to be copied.
>It never returns a negative value. The correct return code is -EFAULT
>and not -EIO.
>
>All the callers check for non-zero returns so that's Ok, but the return
>code is passed to the user so we should fix this.
>
>Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: WANG Cong <xiyou.wangcong@gmail.com>
>
>diff --git a/kernel/kexec.c b/kernel/kexec.c
>index 474a847..ab2258b 100644
>--- a/kernel/kexec.c
>+++ b/kernel/kexec.c
>@@ -151,8 +151,10 @@ static int do_kimage_alloc(struct kimage **rimage, unsigned long entry,
> image->nr_segments = nr_segments;
> segment_bytes = nr_segments * sizeof(*segments);
> result = copy_from_user(image->segment, segments, segment_bytes);
>- if (result)
>+ if (result) {
>+ result = -EFAULT;
> goto out;
>+ }
>
> /*
> * Verify we have good destination addresses. The caller is
>@@ -827,7 +829,7 @@ static int kimage_load_normal_segment(struct kimage *image,
> result = copy_from_user(ptr, buf, uchunk);
> kunmap(page);
> if (result) {
>- result = (result < 0) ? result : -EIO;
>+ result = -EFAULT;
> goto out;
> }
> ubytes -= uchunk;
>@@ -882,7 +884,7 @@ static int kimage_load_crash_segment(struct kimage *image,
> kexec_flush_icache_page(page);
> kunmap(page);
> if (result) {
>- result = (result < 0) ? result : -EIO;
>+ result = -EFAULT;
> goto out;
> }
> ubytes -= uchunk;
>--
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/
prev parent reply other threads:[~2010-07-29 7:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-29 7:36 Dan Carpenter
2010-07-29 7:58 ` Américo Wang [this message]
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=20100729075815.GA5555@cr0.nay.redhat.com \
--to=xiyou.wangcong@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=error27@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=seto.hidetoshi@jp.fujitsu.com \
--cc=simon.kagstrom@netinsight.net \
/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®