Skip to content

Commit

Permalink
kexec: return -EFAULT on copy_to_user() failures
Browse files Browse the repository at this point in the history
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>
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: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
error27 authored and torvalds committed Aug 11, 2010
1 parent 832ccf6 commit f65a03f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kernel/kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f65a03f

Please sign in to comment.