diff options
Diffstat (limited to 'fs/proc/kcore.c')
-rw-r--r-- | fs/proc/kcore.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 4bc85cb8be6a..e8a93bc8285d 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c | |||
@@ -512,23 +512,15 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) | |||
512 | return -EFAULT; | 512 | return -EFAULT; |
513 | } else { | 513 | } else { |
514 | if (kern_addr_valid(start)) { | 514 | if (kern_addr_valid(start)) { |
515 | unsigned long n; | ||
516 | |||
517 | /* | 515 | /* |
518 | * Using bounce buffer to bypass the | 516 | * Using bounce buffer to bypass the |
519 | * hardened user copy kernel text checks. | 517 | * hardened user copy kernel text checks. |
520 | */ | 518 | */ |
521 | memcpy(buf, (char *) start, tsz); | 519 | if (probe_kernel_read(buf, (void *) start, tsz)) { |
522 | n = copy_to_user(buffer, buf, tsz); | 520 | if (clear_user(buffer, tsz)) |
523 | /* | 521 | return -EFAULT; |
524 | * We cannot distinguish between fault on source | 522 | } else { |
525 | * and fault on destination. When this happens | 523 | if (copy_to_user(buffer, buf, tsz)) |
526 | * we clear too and hope it will trigger the | ||
527 | * EFAULT again. | ||
528 | */ | ||
529 | if (n) { | ||
530 | if (clear_user(buffer + tsz - n, | ||
531 | n)) | ||
532 | return -EFAULT; | 524 | return -EFAULT; |
533 | } | 525 | } |
534 | } else { | 526 | } else { |