Commit 5f834dd2 authored by Kees Cook's avatar Kees Cook Committed by Greg Kroah-Hartman

/dev/mem: Avoid overwriting "err" in read_mem()

commit b5b38200 upstream.

Successes in probe_kernel_read() would mask failures in copy_to_user()
during read_mem().
Reported-by: default avatarBrad Spengler <>
Fixes: 22ec1a2a ("/dev/mem: Add bounce buffer for copy-out")
Signed-off-by: default avatarKees Cook <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 66a65ca5
......@@ -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);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment