Re: [PATCH v2] printk: Add kernel parameter to disable writes to /dev/kmsg

From: Steven Rostedt
Date: Mon Apr 25 2016 - 15:35:33 EST


On Mon, 25 Apr 2016 12:28:30 -0700
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> On Mon, Apr 25, 2016 at 12:06 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> >
> > Again, please default enable and use an easier name to toggle this.
> > Userspace flooding this with junk is really insane.
>
> I think it should be a tristate with "yes/no/ratelimit", and let's
> default to ratelimit.

Hmm, as this is currently decided on opening, it would be an
interesting task, and more complex. But I could look into it.

>
> And I also suspect that we would be better off not returning an error
> (which could make user space decide to break, either intentionally or
> just because some people think that "error handling is important"
> means that you should abort on all errors you don't recognize), but
> just silently drop the write. IOW, the "no" would just be a rather
> extreme form of rate-limiting, while "yes" would just be the other
> extreme.
>

Actually, systemd currently does the right thing when this errors on
opening. It finds another way to do logging. At least on my boxes that
I tested (Debian testing and Fedora 18). If it doesn't error out,
systemd may decided to continue to use this as its means for general
purpose logging, and now I lose out on the logging of userspace, as
everything that systemd does is silently dropped.

-- Steve