Skip to content

Commit

Permalink
printk: Don't allow userspace to write to /dev/kmsg
Browse files Browse the repository at this point in the history
There is extensive spam in dmesg because of userspace.
This kills all "init", "healthd", "logd" messages in kernel logs and makes them
more readable.

Extracted from kerneltoast/android_kernel_google_wahoo@59f163a.

Signed-off-by: idkwhoiam322 <[email protected]>
Signed-off-by: prorooter007 <[email protected]>
Signed-off-by: celtare21 <[email protected]>
  • Loading branch information
idkwhoiam322 authored and celtare21 committed Dec 16, 2022
1 parent 4c06752 commit 9078172
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel/printk/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,9 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
size_t len = iov_iter_count(from);
ssize_t ret = len;

/* Don't allow userspace to write to /dev/kmesg */
return len;

if (!user || len > LOG_LINE_MAX)
return -EINVAL;

Expand Down

0 comments on commit 9078172

Please sign in to comment.