[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200115123601.GA3461986@kroah.com>
Date: Wed, 15 Jan 2020 13:36:01 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Dmitry Safonov <dima@...sta.com>
Cc: linux-kernel@...r.kernel.org,
Dmitry Safonov <0x7f454c46@...il.com>,
Iurii Zaikin <yzaikin@...gle.com>,
Jiri Slaby <jslaby@...e.com>, Joe Perches <joe@...ches.com>,
Randy Dunlap <rdunlap@...radead.org>,
Vasiliy Khoruzhick <vasilykh@...sta.com>,
linux-serial@...r.kernel.org, Luis Chamberlain <mcgrof@...nel.org>,
Kees Cook <keescook@...omium.org>,
linux-fsdevel@...r.kernel.org
Subject: Re: [PATCHv2-next 1/3] sysctl/sysrq: Remove __sysrq_enabled copy
On Tue, Jan 14, 2020 at 05:19:10PM +0000, Dmitry Safonov wrote:
> Many embedded boards have a disconnected TTL level serial which can
> generate some garbage that can lead to spurious false sysrq detects.
>
> Currently, sysrq can be either completely disabled for serial console
> or always disabled (with CONFIG_MAGIC_SYSRQ_SERIAL), since
> commit 732dbf3a6104 ("serial: do not accept sysrq characters via serial port")
>
> At Arista, we have such boards that can generate BREAK and random
> garbage. While disabling sysrq for serial console would solve
> the problem with spurious false sysrq triggers, it's also desirable
> to have a way to enable sysrq back.
>
> Having the way to enable sysrq was beneficial to debug lockups with
> a manual investigation in field and on the other side preventing false
> sysrq detections.
>
> As a preparation to add sysrq_toggle_support() call into uart,
> remove a private copy of sysrq_enabled from sysctl - it should reflect
> the actual status of sysrq.
>
> Furthermore, the private copy isn't correct already in case
> sysrq_always_enabled is true. So, remove __sysrq_enabled and use a
> getter-helper for sysrq enabled status.
>
> Cc: Iurii Zaikin <yzaikin@...gle.com>
> Cc: Jiri Slaby <jslaby@...e.com>
> Cc: Luis Chamberlain <mcgrof@...nel.org>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: linux-fsdevel@...r.kernel.org
> Signed-off-by: Dmitry Safonov <dima@...sta.com>
> ---
> drivers/tty/sysrq.c | 7 +++++++
> include/linux/sysrq.h | 7 +++++++
> kernel/sysctl.c | 41 ++++++++++++++++++++++-------------------
> 3 files changed, 36 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
> index f724962a5906..ef3e78967146 100644
> --- a/drivers/tty/sysrq.c
> +++ b/drivers/tty/sysrq.c
> @@ -73,6 +73,13 @@ static bool sysrq_on_mask(int mask)
> (sysrq_enabled & mask);
> }
>
> +int sysrq_get_mask(void)
> +{
> + if (sysrq_always_enabled)
> + return 1;
> + return sysrq_enabled;
> +}
Naming is hard. And this name is really hard to understand.
Traditionally get/put are used for incrementing reference counts. You
don't have a sysrq_put_mask() call, right? :)
I think what you want this function to do is, "is sysrq enabled right
now" (hint, it's a global function, add kernel-doc to it so we know what
it does...). If so, it should maybe be something like:
bool sysrq_is_enabled(void);
which to me makes more sense.
thoughts?
thanks,
greg k-h
Powered by blists - more mailing lists