Skip to content

Commit 351068f

Browse files
olsajiriAlex Shi
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: f5509cc18daa ("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> (cherry picked from commit df04abfd181acc276ba6762c8206891ae10ae00d) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent fd0b2a5 commit 351068f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fs/proc/kcore.c

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

519-
n = copy_to_user(buffer, (char *)start, tsz);
519+
/*
520+
* Using bounce buffer to bypass the
521+
* hardened user copy kernel text checks.
522+
*/
523+
memcpy(buf, (char *) start, tsz);
524+
n = copy_to_user(buffer, buf, tsz);
520525
/*
521526
* We cannot distinguish between fault on source
522527
* and fault on destination. When this happens

0 commit comments

Comments
 (0)