Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c7642969 authored by Jiri Olsa's avatar Jiri Olsa Committed by Sami Tolvanen
Browse files

UPSTREAM: fs/proc/kcore.c: Add bounce buffer for ktext data



We hit hardened usercopy feature check for kernel text access by reading
kcore file:

  usercopy: kernel memory exposure attempt detected from ffffffff8179a01f (<kernel text>) (4065 bytes)
  kernel BUG at mm/usercopy.c:75!

Bypassing this check for kcore by adding bounce buffer for ktext data.

Reported-by: default avatarSteve Best <sbest@redhat.com>
Fixes: f5509cc18daa ("mm: Hardened usercopy")
Suggested-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>

Bug: 31374226
Change-Id: Ic93e6041b67d804a994518bf4950811f828b406e
(cherry picked from commit df04abfd181acc276ba6762c8206891ae10ae00d)
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
parent 762a327d
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -509,7 +509,12 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
			if (kern_addr_valid(start)) {
				unsigned long n;

				n = copy_to_user(buffer, (char *)start, tsz);
				/*
				 * Using bounce buffer to bypass the
				 * hardened user copy kernel text checks.
				 */
				memcpy(buf, (char *) start, tsz);
				n = copy_to_user(buffer, buf, tsz);
				/*
				 * We cannot distinguish between fault on source
				 * and fault on destination. When this happens