summaryrefslogtreecommitdiff
path: root/drivers/char/mem.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2018-03-28 00:06:14 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-04-08 15:26:31 +0300
commit5f834dd24baec1f9926e8a06609e0906fd607b06 (patch)
treee64f64f6251c420150d82cc6387ab68c6b6e6b24 /drivers/char/mem.c
parent66a65ca5b8fda6f5c55a9cf83e0fcb8e613baaa9 (diff)
downloadlinux-5f834dd24baec1f9926e8a06609e0906fd607b06.tar.xz
/dev/mem: Avoid overwriting "err" in read_mem()
commit b5b38200ebe54879a7264cb6f33821f61c586a7e upstream. Successes in probe_kernel_read() would mask failures in copy_to_user() during read_mem(). Reported-by: Brad Spengler <spender@grsecurity.net> Fixes: 22ec1a2aea73 ("/dev/mem: Add bounce buffer for copy-out") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char/mem.c')
-rw-r--r--drivers/char/mem.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 3a70dba2c645..f11224a5dc5c 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -137,7 +137,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
while (count > 0) {
unsigned long remaining;
- int allowed;
+ int allowed, probe;
sz = size_inside_page(p, count);
@@ -160,9 +160,9 @@ static ssize_t read_mem(struct file *file, char __user *buf,
if (!ptr)
goto failed;
- err = probe_kernel_read(bounce, ptr, sz);
+ probe = probe_kernel_read(bounce, ptr, sz);
unxlate_dev_mem_ptr(p, ptr);
- if (err)
+ if (probe)
goto failed;
remaining = copy_to_user(buf, bounce, sz);