Re: [PATCH] printk: fix printk.devkmsg sysctl

From: Rabin Vincent
Date: Fri Jan 27 2017 - 10:46:33 EST


On Fri, Jan 27, 2017 at 04:01:41PM +0100, Borislav Petkov wrote:
> On Fri, Jan 27, 2017 at 02:11:46PM +0100, Rabin Vincent wrote:
> > @@ -177,7 +177,7 @@ int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write,
> > * Do not accept an unknown string OR a known string with
> > * trailing crap...
> > */
> > - if (err < 0 || (err + 1 != *lenp)) {
>
> Grr, that's that damn '\n'
>
> echo off > /proc/sys/kernel/printk_devkmsg
>
> works, of course.
>
> Ok, I don't want to relax the strncmp() above and would still like to
> return the exact length compared.
>
> So please change the check above to allow the following inputs:
>
> <str>
>
> or
>
> <str>\n
>
> I.e., a trailing, *optional*, '\n' is allowed.

proc_dostring() eats the '\n' and stops after that so we never see it or
what comes after, so we need an strlen():

8<----