diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2014-07-31 09:38:02 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2014-08-06 16:44:49 +1000 |
commit | efd4cd09380ecefaffeefdf499fc9f4e5e7ab3e5 (patch) | |
tree | e61d79c2c6eec044de8828753f96553c158565ee | |
parent | 3aba15f3d027be44165cba753a16e4279a181dbb (diff) |
kexec: return error if file bytes are less then file size
If number of bytes read from file are not same as file size, return error.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | kernel/kexec.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/kernel/kexec.c b/kernel/kexec.c index b4a014c58cff..9b46219254dd 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -332,7 +332,7 @@ out_free_image: static int copy_file_from_fd(int fd, void **buf, unsigned long *buf_len) { struct fd f = fdget(fd); - int ret = 0; + int ret; struct kstat stat; loff_t pos; ssize_t bytes = 0; @@ -376,6 +376,12 @@ static int copy_file_from_fd(int fd, void **buf, unsigned long *buf_len) pos += bytes; } + if (pos != stat.size) { + ret = -EBADF; + vfree(*buf); + goto out; + } + *buf_len = pos; out: fdput(f); |