Skip to content

Commit df04abf

Browse files
olsajiritorvalds
authored andcommitted
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: Steve Best <sbest@redhat.com> Fixes: f5509cc ("mm: Hardened usercopy") Suggested-by: Kees Cook <keescook@chromium.org> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f5beeb1 commit df04abf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/proc/kcore.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,12 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
509509
if (kern_addr_valid(start)) {
510510
unsigned long n;
511511

512-
n = copy_to_user(buffer, (char *)start, tsz);
512+
/*
513+
* Using bounce buffer to bypass the
514+
* hardened user copy kernel text checks.
515+
*/
516+
memcpy(buf, (char *) start, tsz);
517+
n = copy_to_user(buffer, buf, tsz);
513518
/*
514519
* We cannot distinguish between fault on source
515520
* and fault on destination. When this happens

0 commit comments

Comments
 (0)