提交 f65a03f6 编写于 作者: D Dan Carpenter 提交者: Linus Torvalds

kexec: return -EFAULT on copy_to_user() failures

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: NDan Carpenter <error27@gmail.com>
Cc: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Simon Kagstrom <simon.kagstrom@netinsight.net>
Acked-by: NWANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 832ccf6f
...@@ -151,8 +151,10 @@ static int do_kimage_alloc(struct kimage **rimage, unsigned long entry, ...@@ -151,8 +151,10 @@ static int do_kimage_alloc(struct kimage **rimage, unsigned long entry,
image->nr_segments = nr_segments; image->nr_segments = nr_segments;
segment_bytes = nr_segments * sizeof(*segments); segment_bytes = nr_segments * sizeof(*segments);
result = copy_from_user(image->segment, segments, segment_bytes); result = copy_from_user(image->segment, segments, segment_bytes);
if (result) if (result) {
result = -EFAULT;
goto out; goto out;
}
/* /*
* Verify we have good destination addresses. The caller is * Verify we have good destination addresses. The caller is
...@@ -827,7 +829,7 @@ static int kimage_load_normal_segment(struct kimage *image, ...@@ -827,7 +829,7 @@ static int kimage_load_normal_segment(struct kimage *image,
result = copy_from_user(ptr, buf, uchunk); result = copy_from_user(ptr, buf, uchunk);
kunmap(page); kunmap(page);
if (result) { if (result) {
result = (result < 0) ? result : -EIO; result = -EFAULT;
goto out; goto out;
} }
ubytes -= uchunk; ubytes -= uchunk;
...@@ -882,7 +884,7 @@ static int kimage_load_crash_segment(struct kimage *image, ...@@ -882,7 +884,7 @@ static int kimage_load_crash_segment(struct kimage *image,
kexec_flush_icache_page(page); kexec_flush_icache_page(page);
kunmap(page); kunmap(page);
if (result) { if (result) {
result = (result < 0) ? result : -EIO; result = -EFAULT;
goto out; goto out;
} }
ubytes -= uchunk; ubytes -= uchunk;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册