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

From: Sergey Senozhatsky
Date: Wed Feb 01 2017 - 23:50:25 EST


Hello,

sorry, catching up with the emails.

there seems to be two independent patches. I'll just comment in one
thread.



On (01/31/17 14:55), Petr Mladek wrote:
[..]
> From 0ce6125caf314270cb48202390d8a0938fdf316e Mon Sep 17 00:00:00 2001
> From: Petr Mladek <pmladek@xxxxxxxx>
> Date: Tue, 31 Jan 2017 12:00:13 +0100
> Subject: [PATCH] printk: Fix printk.devkmsg sysctl
>
> The code handling write into /proc/sys/kernel/printk_devkmsg expects
> a new line at the end of the string but does not check it. As a result
> it allows:
>
> # echo -n offX > /proc/sys/kernel/printk_devkmsg
> #
>
> while at the same time it rejects legitimate uses:
>
> # echo -n off > /proc/sys/kernel/printk_devkmsg
> -sh: echo: write error: Invalid argument
>

for these cases (echo/echo -n/echo -e/etc. etc.) I usually use
sysfs_streq() from lib/string.c

wouldn't sysfs_streq() do the trick here?

-ss