summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@redhat.com>2014-07-23 09:13:08 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2014-07-28 20:51:14 +1000
commitbc865121a81da3a8e72fc71a0a188499d134a4e2 (patch)
tree45a40adf018d337dcd7cf2f8be7959ae53d74813 /kernel
parent514179cf569b9bd4a4d808d7299a8baae8baa4a8 (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>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kexec.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 32fd3d48bc8c..99558a3cb08d 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -331,7 +331,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;
@@ -375,6 +375,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);