• Dmitry Safonov's avatar
    sysctl/sysrq: Remove __sysrq_enabled copy · eaee4172
    Dmitry Safonov authored
    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 732dbf3a ("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 sysrq_mask() to check sysrq_key_op enabled status.
    
    Cc: Iurii Zaikin <yzaikin@google.com>
    Cc: Jiri Slaby <jslaby@suse.com>
    Cc: Luis Chamberlain <mcgrof@kernel.org>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: linux-fsdevel@vger.kernel.org
    Signed-off-by: default avatarDmitry Safonov <dima@arista.com>
    Link: https://lore.kernel.org/r/20200302175135.269397-2-dima@arista.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    eaee4172
sysrq.c 26.4 KB