Export a pointer to the sysrq_get_key_op(). This way we can cleanly unregister it, instead of the current solutions of modifuing it inplace.
Since __sysrq_get_key_op() is no longer used externally, let's make it a static function.
This patch will allow us to limit access to each and every sysrq op and constify the sysrq handling.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Richard Henderson rth@twiddle.net Cc: Ivan Kokshaysky ink@jurassic.park.msu.ru Cc: Matt Turner mattst88@gmail.com Cc: linux-alpha@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree. --- arch/alpha/kernel/setup.c | 13 +++++++++++-- drivers/tty/sysrq.c | 4 +++- include/linux/sysrq.h | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index f19aa577354b..dd7f770f23cf 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -430,6 +430,15 @@ register_cpus(void)
arch_initcall(register_cpus);
+#ifdef CONFIG_MAGIC_SYSRQ +static struct sysrq_key_op srm_sysrq_reboot_op = { + .handler = machine_halt, + .help_msg = "reboot(b)", + .action_msg = "Resetting", + .enable_mask = SYSRQ_ENABLE_BOOT, +}; +#endif + void __init setup_arch(char **cmdline_p) { @@ -550,8 +559,8 @@ setup_arch(char **cmdline_p) /* If we're using SRM, make sysrq-b halt back to the prom, not auto-reboot. */ if (alpha_using_srm) { - struct sysrq_key_op *op = __sysrq_get_key_op('b'); - op->handler = (void *) machine_halt; + unregister_sysrq_key('b', __sysrq_reboot_op); + register_sysrq_key('b', &srm_sysrq_reboot_op); } #endif
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 0dc3878794fd..1741134cabca 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -172,6 +172,8 @@ static struct sysrq_key_op sysrq_reboot_op = { .enable_mask = SYSRQ_ENABLE_BOOT, };
+struct sysrq_key_op *__sysrq_reboot_op = &sysrq_reboot_op; + static void sysrq_handle_sync(int key) { emergency_sync(); @@ -516,7 +518,7 @@ static int sysrq_key_table_key2index(int key) /* * get and put functions for the table, exposed to modules. */ -struct sysrq_key_op *__sysrq_get_key_op(int key) +static struct sysrq_key_op *__sysrq_get_key_op(int key) { struct sysrq_key_op *op_p = NULL; int i; diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h index 8e159e16850f..9b51f98e5f60 100644 --- a/include/linux/sysrq.h +++ b/include/linux/sysrq.h @@ -47,7 +47,7 @@ void handle_sysrq(int key); void __handle_sysrq(int key, bool check_mask); int register_sysrq_key(int key, struct sysrq_key_op *op); int unregister_sysrq_key(int key, struct sysrq_key_op *op); -struct sysrq_key_op *__sysrq_get_key_op(int key); +extern struct sysrq_key_op *__sysrq_reboot_op;
int sysrq_toggle_support(int enable_mask); int sysrq_mask(void);
The user is not supposed to thinker with the underlying sysrq_key_op. Make that explicit by adding a handful of const notations.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree. --- Documentation/admin-guide/sysrq.rst | 10 +++++----- drivers/tty/sysrq.c | 16 ++++++++-------- include/linux/sysrq.h | 16 ++++++++-------- 3 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/Documentation/admin-guide/sysrq.rst b/Documentation/admin-guide/sysrq.rst index a46209f4636c..e6424d8c5846 100644 --- a/Documentation/admin-guide/sysrq.rst +++ b/Documentation/admin-guide/sysrq.rst @@ -231,13 +231,13 @@ prints help, and C) an action_msg string, that will print right before your handler is called. Your handler must conform to the prototype in 'sysrq.h'.
After the ``sysrq_key_op`` is created, you can call the kernel function -``register_sysrq_key(int key, struct sysrq_key_op *op_p);`` this will +``register_sysrq_key(int key, const struct sysrq_key_op *op_p);`` this will register the operation pointed to by ``op_p`` at table key 'key', if that slot in the table is blank. At module unload time, you must call -the function ``unregister_sysrq_key(int key, struct sysrq_key_op *op_p)``, which -will remove the key op pointed to by 'op_p' from the key 'key', if and only if -it is currently registered in that slot. This is in case the slot has been -overwritten since you registered it. +the function ``unregister_sysrq_key(int key, const struct sysrq_key_op *op_p)``, +which will remove the key op pointed to by 'op_p' from the key 'key', if and +only if it is currently registered in that slot. This is in case the slot has +been overwritten since you registered it.
The Magic SysRQ system works by registering key operations against a key op lookup table, which is defined in 'drivers/tty/sysrq.c'. This key table has diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 1741134cabca..091c64a3cef0 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -518,9 +518,9 @@ static int sysrq_key_table_key2index(int key) /* * get and put functions for the table, exposed to modules. */ -static struct sysrq_key_op *__sysrq_get_key_op(int key) +static const struct sysrq_key_op *__sysrq_get_key_op(int key) { - struct sysrq_key_op *op_p = NULL; + const struct sysrq_key_op *op_p = NULL; int i;
i = sysrq_key_table_key2index(key); @@ -530,7 +530,7 @@ static struct sysrq_key_op *__sysrq_get_key_op(int key) return op_p; }
-static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p) +static void __sysrq_put_key_op(int key, const struct sysrq_key_op *op_p) { int i = sysrq_key_table_key2index(key);
@@ -540,7 +540,7 @@ static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p)
void __handle_sysrq(int key, bool check_mask) { - struct sysrq_key_op *op_p; + const struct sysrq_key_op *op_p; int orig_log_level; int orig_suppress_printk; int i; @@ -1063,8 +1063,8 @@ int sysrq_toggle_support(int enable_mask) } EXPORT_SYMBOL_GPL(sysrq_toggle_support);
-static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p, - struct sysrq_key_op *remove_op_p) +static int __sysrq_swap_key_ops(int key, const struct sysrq_key_op *insert_op_p, + const struct sysrq_key_op *remove_op_p) { int retval;
@@ -1087,13 +1087,13 @@ static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p, return retval; }
-int register_sysrq_key(int key, struct sysrq_key_op *op_p) +int register_sysrq_key(int key, const struct sysrq_key_op *op_p) { return __sysrq_swap_key_ops(key, op_p, NULL); } EXPORT_SYMBOL(register_sysrq_key);
-int unregister_sysrq_key(int key, struct sysrq_key_op *op_p) +int unregister_sysrq_key(int key, const struct sysrq_key_op *op_p) { return __sysrq_swap_key_ops(key, NULL, op_p); } diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h index 9b51f98e5f60..479028391c08 100644 --- a/include/linux/sysrq.h +++ b/include/linux/sysrq.h @@ -30,10 +30,10 @@ #define SYSRQ_ENABLE_RTNICE 0x0100
struct sysrq_key_op { - void (*handler)(int); - char *help_msg; - char *action_msg; - int enable_mask; + void (* const handler)(int); + const char * const help_msg; + const char * const action_msg; + const int enable_mask; };
#ifdef CONFIG_MAGIC_SYSRQ @@ -45,8 +45,8 @@ struct sysrq_key_op {
void handle_sysrq(int key); void __handle_sysrq(int key, bool check_mask); -int register_sysrq_key(int key, struct sysrq_key_op *op); -int unregister_sysrq_key(int key, struct sysrq_key_op *op); +int register_sysrq_key(int key, const struct sysrq_key_op *op); +int unregister_sysrq_key(int key, const struct sysrq_key_op *op); extern struct sysrq_key_op *__sysrq_reboot_op;
int sysrq_toggle_support(int enable_mask); @@ -62,12 +62,12 @@ static inline void __handle_sysrq(int key, bool check_mask) { }
-static inline int register_sysrq_key(int key, struct sysrq_key_op *op) +static inline int register_sysrq_key(int key, const struct sysrq_key_op *op) { return -EINVAL; }
-static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op) +static inline int unregister_sysrq_key(int key, const struct sysrq_key_op *op) { return -EINVAL; }
All the users threat them as immutable - annotate them as such.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree. --- drivers/tty/sysrq.c | 52 +++++++++++++++++++++---------------------- include/linux/sysrq.h | 2 +- 2 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 091c64a3cef0..477cdc1e9cf3 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -106,7 +106,7 @@ static void sysrq_handle_loglevel(int key) pr_info("Loglevel set to %d\n", i); console_loglevel = i; } -static struct sysrq_key_op sysrq_loglevel_op = { +static const struct sysrq_key_op sysrq_loglevel_op = { .handler = sysrq_handle_loglevel, .help_msg = "loglevel(0-9)", .action_msg = "Changing Loglevel", @@ -119,14 +119,14 @@ static void sysrq_handle_SAK(int key) struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work; schedule_work(SAK_work); } -static struct sysrq_key_op sysrq_SAK_op = { +static const struct sysrq_key_op sysrq_SAK_op = { .handler = sysrq_handle_SAK, .help_msg = "sak(k)", .action_msg = "SAK", .enable_mask = SYSRQ_ENABLE_KEYBOARD, }; #else -#define sysrq_SAK_op (*(struct sysrq_key_op *)NULL) +#define sysrq_SAK_op (*(const struct sysrq_key_op *)NULL) #endif
#ifdef CONFIG_VT @@ -135,14 +135,14 @@ static void sysrq_handle_unraw(int key) vt_reset_unicode(fg_console); }
-static struct sysrq_key_op sysrq_unraw_op = { +static const struct sysrq_key_op sysrq_unraw_op = { .handler = sysrq_handle_unraw, .help_msg = "unraw(r)", .action_msg = "Keyboard mode set to system default", .enable_mask = SYSRQ_ENABLE_KEYBOARD, }; #else -#define sysrq_unraw_op (*(struct sysrq_key_op *)NULL) +#define sysrq_unraw_op (*(const struct sysrq_key_op *)NULL) #endif /* CONFIG_VT */
static void sysrq_handle_crash(int key) @@ -152,7 +152,7 @@ static void sysrq_handle_crash(int key)
panic("sysrq triggered crash\n"); } -static struct sysrq_key_op sysrq_crash_op = { +static const struct sysrq_key_op sysrq_crash_op = { .handler = sysrq_handle_crash, .help_msg = "crash(c)", .action_msg = "Trigger a crash", @@ -165,20 +165,20 @@ static void sysrq_handle_reboot(int key) local_irq_enable(); emergency_restart(); } -static struct sysrq_key_op sysrq_reboot_op = { +static const struct sysrq_key_op sysrq_reboot_op = { .handler = sysrq_handle_reboot, .help_msg = "reboot(b)", .action_msg = "Resetting", .enable_mask = SYSRQ_ENABLE_BOOT, };
-struct sysrq_key_op *__sysrq_reboot_op = &sysrq_reboot_op; +const struct sysrq_key_op *__sysrq_reboot_op = &sysrq_reboot_op;
static void sysrq_handle_sync(int key) { emergency_sync(); } -static struct sysrq_key_op sysrq_sync_op = { +static const struct sysrq_key_op sysrq_sync_op = { .handler = sysrq_handle_sync, .help_msg = "sync(s)", .action_msg = "Emergency Sync", @@ -190,7 +190,7 @@ static void sysrq_handle_show_timers(int key) sysrq_timer_list_show(); }
-static struct sysrq_key_op sysrq_show_timers_op = { +static const struct sysrq_key_op sysrq_show_timers_op = { .handler = sysrq_handle_show_timers, .help_msg = "show-all-timers(q)", .action_msg = "Show clockevent devices & pending hrtimers (no others)", @@ -200,7 +200,7 @@ static void sysrq_handle_mountro(int key) { emergency_remount(); } -static struct sysrq_key_op sysrq_mountro_op = { +static const struct sysrq_key_op sysrq_mountro_op = { .handler = sysrq_handle_mountro, .help_msg = "unmount(u)", .action_msg = "Emergency Remount R/O", @@ -213,13 +213,13 @@ static void sysrq_handle_showlocks(int key) debug_show_all_locks(); }
-static struct sysrq_key_op sysrq_showlocks_op = { +static const struct sysrq_key_op sysrq_showlocks_op = { .handler = sysrq_handle_showlocks, .help_msg = "show-all-locks(d)", .action_msg = "Show Locks Held", }; #else -#define sysrq_showlocks_op (*(struct sysrq_key_op *)NULL) +#define sysrq_showlocks_op (*(const struct sysrq_key_op *)NULL) #endif
#ifdef CONFIG_SMP @@ -266,7 +266,7 @@ static void sysrq_handle_showallcpus(int key) } }
-static struct sysrq_key_op sysrq_showallcpus_op = { +static const struct sysrq_key_op sysrq_showallcpus_op = { .handler = sysrq_handle_showallcpus, .help_msg = "show-backtrace-all-active-cpus(l)", .action_msg = "Show backtrace of all active CPUs", @@ -284,7 +284,7 @@ static void sysrq_handle_showregs(int key) show_regs(regs); perf_event_print_debug(); } -static struct sysrq_key_op sysrq_showregs_op = { +static const struct sysrq_key_op sysrq_showregs_op = { .handler = sysrq_handle_showregs, .help_msg = "show-registers(p)", .action_msg = "Show Regs", @@ -296,7 +296,7 @@ static void sysrq_handle_showstate(int key) show_state(); show_workqueue_state(); } -static struct sysrq_key_op sysrq_showstate_op = { +static const struct sysrq_key_op sysrq_showstate_op = { .handler = sysrq_handle_showstate, .help_msg = "show-task-states(t)", .action_msg = "Show State", @@ -307,7 +307,7 @@ static void sysrq_handle_showstate_blocked(int key) { show_state_filter(TASK_UNINTERRUPTIBLE); } -static struct sysrq_key_op sysrq_showstate_blocked_op = { +static const struct sysrq_key_op sysrq_showstate_blocked_op = { .handler = sysrq_handle_showstate_blocked, .help_msg = "show-blocked-tasks(w)", .action_msg = "Show Blocked State", @@ -321,21 +321,21 @@ static void sysrq_ftrace_dump(int key) { ftrace_dump(DUMP_ALL); } -static struct sysrq_key_op sysrq_ftrace_dump_op = { +static const struct sysrq_key_op sysrq_ftrace_dump_op = { .handler = sysrq_ftrace_dump, .help_msg = "dump-ftrace-buffer(z)", .action_msg = "Dump ftrace buffer", .enable_mask = SYSRQ_ENABLE_DUMP, }; #else -#define sysrq_ftrace_dump_op (*(struct sysrq_key_op *)NULL) +#define sysrq_ftrace_dump_op (*(const struct sysrq_key_op *)NULL) #endif
static void sysrq_handle_showmem(int key) { show_mem(0, NULL); } -static struct sysrq_key_op sysrq_showmem_op = { +static const struct sysrq_key_op sysrq_showmem_op = { .handler = sysrq_handle_showmem, .help_msg = "show-memory-usage(m)", .action_msg = "Show Memory", @@ -366,7 +366,7 @@ static void sysrq_handle_term(int key) send_sig_all(SIGTERM); console_loglevel = CONSOLE_LOGLEVEL_DEBUG; } -static struct sysrq_key_op sysrq_term_op = { +static const struct sysrq_key_op sysrq_term_op = { .handler = sysrq_handle_term, .help_msg = "terminate-all-tasks(e)", .action_msg = "Terminate All Tasks", @@ -396,7 +396,7 @@ static void sysrq_handle_moom(int key) { schedule_work(&moom_work); } -static struct sysrq_key_op sysrq_moom_op = { +static const struct sysrq_key_op sysrq_moom_op = { .handler = sysrq_handle_moom, .help_msg = "memory-full-oom-kill(f)", .action_msg = "Manual OOM execution", @@ -408,7 +408,7 @@ static void sysrq_handle_thaw(int key) { emergency_thaw_all(); } -static struct sysrq_key_op sysrq_thaw_op = { +static const struct sysrq_key_op sysrq_thaw_op = { .handler = sysrq_handle_thaw, .help_msg = "thaw-filesystems(j)", .action_msg = "Emergency Thaw of all frozen filesystems", @@ -421,7 +421,7 @@ static void sysrq_handle_kill(int key) send_sig_all(SIGKILL); console_loglevel = CONSOLE_LOGLEVEL_DEBUG; } -static struct sysrq_key_op sysrq_kill_op = { +static const struct sysrq_key_op sysrq_kill_op = { .handler = sysrq_handle_kill, .help_msg = "kill-all-tasks(i)", .action_msg = "Kill All Tasks", @@ -432,7 +432,7 @@ static void sysrq_handle_unrt(int key) { normalize_rt_tasks(); } -static struct sysrq_key_op sysrq_unrt_op = { +static const struct sysrq_key_op sysrq_unrt_op = { .handler = sysrq_handle_unrt, .help_msg = "nice-all-RT-tasks(n)", .action_msg = "Nice All RT Tasks", @@ -442,7 +442,7 @@ static struct sysrq_key_op sysrq_unrt_op = { /* Key Operations table and lock */ static DEFINE_SPINLOCK(sysrq_key_table_lock);
-static struct sysrq_key_op *sysrq_key_table[36] = { +static const struct sysrq_key_op *sysrq_key_table[36] = { &sysrq_loglevel_op, /* 0 */ &sysrq_loglevel_op, /* 1 */ &sysrq_loglevel_op, /* 2 */ diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h index 479028391c08..3a582ec7a2f1 100644 --- a/include/linux/sysrq.h +++ b/include/linux/sysrq.h @@ -47,7 +47,7 @@ void handle_sysrq(int key); void __handle_sysrq(int key, bool check_mask); int register_sysrq_key(int key, const struct sysrq_key_op *op); int unregister_sysrq_key(int key, const struct sysrq_key_op *op); -extern struct sysrq_key_op *__sysrq_reboot_op; +extern const struct sysrq_key_op *__sysrq_reboot_op;
int sysrq_toggle_support(int enable_mask); int sysrq_mask(void);
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Richard Henderson rth@twiddle.net Cc: Ivan Kokshaysky ink@jurassic.park.msu.ru Cc: Matt Turner mattst88@gmail.com Cc: linux-alpha@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree. --- arch/alpha/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index dd7f770f23cf..6fa802c495b4 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -431,7 +431,7 @@ register_cpus(void) arch_initcall(register_cpus);
#ifdef CONFIG_MAGIC_SYSRQ -static struct sysrq_key_op srm_sysrq_reboot_op = { +static const struct sysrq_key_op srm_sysrq_reboot_op = { .handler = machine_halt, .help_msg = "reboot(b)", .action_msg = "Resetting",
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Thomas Bogendoerfer tsbogend@alpha.franken.de Cc: linux-mips@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better it this gets merged this via the tty tree. --- arch/mips/kernel/sysrq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/kernel/sysrq.c b/arch/mips/kernel/sysrq.c index e5a2a6ab71ac..9c1a2019113b 100644 --- a/arch/mips/kernel/sysrq.c +++ b/arch/mips/kernel/sysrq.c @@ -52,7 +52,7 @@ static void sysrq_handle_tlbdump(int key) #endif }
-static struct sysrq_key_op sysrq_tlbdump_op = { +static const struct sysrq_key_op sysrq_tlbdump_op = { .handler = sysrq_handle_tlbdump, .help_msg = "show-tlbs(x)", .action_msg = "Show TLB entries",
On Wed, May 13, 2020 at 10:43:45PM +0100, Emil Velikov wrote:
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Thomas Bogendoerfer tsbogend@alpha.franken.de Cc: linux-mips@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better it this gets merged this via the tty tree.
arch/mips/kernel/sysrq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Thomas Bogendoerfer tsbogend@alpha.franken.de
Thomas.
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Michael Ellerman mpe@ellerman.id.au Cc: Benjamin Herrenschmidt benh@kernel.crashing.org Cc: Paul Mackerras paulus@samba.org Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree. --- arch/powerpc/xmon/xmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index 7af840c0fc93..0d8ca5c9f131 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -3842,7 +3842,7 @@ static void sysrq_handle_xmon(int key) xmon_init(0); }
-static struct sysrq_key_op sysrq_xmon_op = { +static const struct sysrq_key_op sysrq_xmon_op = { .handler = sysrq_handle_xmon, .help_msg = "xmon(x)", .action_msg = "Entering xmon",
Emil Velikov emil.l.velikov@gmail.com writes:
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Michael Ellerman mpe@ellerman.id.au Cc: Benjamin Herrenschmidt benh@kernel.crashing.org Cc: Paul Mackerras paulus@samba.org Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree.
Fine by me.
Acked-by: Michael Ellerman mpe@ellerman.id.au
cheers
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index 7af840c0fc93..0d8ca5c9f131 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -3842,7 +3842,7 @@ static void sysrq_handle_xmon(int key) xmon_init(0); }
-static struct sysrq_key_op sysrq_xmon_op = { +static const struct sysrq_key_op sysrq_xmon_op = { .handler = sysrq_handle_xmon, .help_msg = "xmon(x)", .action_msg = "Entering xmon", -- 2.25.1
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: "David S. Miller" davem@davemloft.net Cc: sparclinux@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree. --- arch/sparc/kernel/process_64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c index 4282116e28e7..423011e60982 100644 --- a/arch/sparc/kernel/process_64.c +++ b/arch/sparc/kernel/process_64.c @@ -313,7 +313,7 @@ static void sysrq_handle_globreg(int key) trigger_all_cpu_backtrace(); }
-static struct sysrq_key_op sparc_globalreg_op = { +static const struct sysrq_key_op sparc_globalreg_op = { .handler = sysrq_handle_globreg, .help_msg = "global-regs(y)", .action_msg = "Show Global CPU Regs", @@ -388,7 +388,7 @@ static void sysrq_handle_globpmu(int key) pmu_snapshot_all_cpus(); }
-static struct sysrq_key_op sparc_globalpmu_op = { +static const struct sysrq_key_op sparc_globalpmu_op = { .handler = sysrq_handle_globpmu, .help_msg = "global-pmu(x)", .action_msg = "Show Global PMU Regs",
From: Emil Velikov emil.l.velikov@gmail.com Date: Wed, 13 May 2020 22:43:47 +0100
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: "David S. Miller" davem@davemloft.net Cc: sparclinux@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Acked-by: David S. Miller davem@davemloft.net
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Maarten Lankhorst maarten.lankhorst@linux.intel.com Cc: Maxime Ripard mripard@kernel.org Cc: Thomas Zimmermann tzimmermann@suse.de Cc: dri-devel@lists.freedesktop.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree. --- drivers/gpu/drm/drm_fb_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index a9771de4d17e..533767100efe 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -307,13 +307,13 @@ static void drm_fb_helper_sysrq(int dummy1) schedule_work(&drm_fb_helper_restore_work); }
-static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { +static const struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { .handler = drm_fb_helper_sysrq, .help_msg = "force-fb(V)", .action_msg = "Restore framebuffer console", }; #else -static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { }; +static const struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { }; #endif
static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
On Wed, May 13, 2020 at 10:43:48PM +0100, Emil Velikov wrote:
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Maarten Lankhorst maarten.lankhorst@linux.intel.com Cc: Maxime Ripard mripard@kernel.org Cc: Thomas Zimmermann tzimmermann@suse.de Cc: dri-devel@lists.freedesktop.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree.
Shouldn't conflict, looks all reasonable for merging through tty as one series.
Reviewed-by: Daniel Vetter daniel.vetter@ffwll.ch Acked-by: Daniel Vetter daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_fb_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index a9771de4d17e..533767100efe 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -307,13 +307,13 @@ static void drm_fb_helper_sysrq(int dummy1) schedule_work(&drm_fb_helper_restore_work); }
-static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { +static const struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { .handler = drm_fb_helper_sysrq, .help_msg = "force-fb(V)", .action_msg = "Restore framebuffer console", }; #else -static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { }; +static const struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { }; #endif
static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
2.25.1
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Jason Wessel jason.wessel@windriver.com Cc: Daniel Thompson daniel.thompson@linaro.org Cc: kgdb-bugreport@lists.sourceforge.net Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree. --- kernel/debug/debug_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 2b7c9b67931d..355bea54ca0e 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -920,7 +920,7 @@ static void sysrq_handle_dbg(int key) kgdb_breakpoint(); }
-static struct sysrq_key_op sysrq_dbg_op = { +static const struct sysrq_key_op sysrq_dbg_op = { .handler = sysrq_handle_dbg, .help_msg = "debug(g)", .action_msg = "DEBUG",
On Wed, May 13, 2020 at 10:43:49PM +0100, Emil Velikov wrote:
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Jason Wessel jason.wessel@windriver.com Cc: Daniel Thompson daniel.thompson@linaro.org Cc: kgdb-bugreport@lists.sourceforge.net Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Acked-by: Daniel Thompson daniel.thompson@linaro.org
Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree.
kernel/debug/debug_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 2b7c9b67931d..355bea54ca0e 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -920,7 +920,7 @@ static void sysrq_handle_dbg(int key) kgdb_breakpoint(); }
-static struct sysrq_key_op sysrq_dbg_op = { +static const struct sysrq_key_op sysrq_dbg_op = { .handler = sysrq_handle_dbg, .help_msg = "debug(g)", .action_msg = "DEBUG", -- 2.25.1
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" rjw@rjwysocki.net Cc: Len Brown len.brown@intel.com Cc: linux-pm@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree. --- kernel/power/poweroff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c index 6d475281c730..562aa0e450ed 100644 --- a/kernel/power/poweroff.c +++ b/kernel/power/poweroff.c @@ -29,7 +29,7 @@ static void handle_poweroff(int key) schedule_work_on(cpumask_first(cpu_online_mask), &poweroff_work); }
-static struct sysrq_key_op sysrq_poweroff_op = { +static const struct sysrq_key_op sysrq_poweroff_op = { .handler = handle_poweroff, .help_msg = "poweroff(o)", .action_msg = "Power Off",
On Wed, May 13, 2020 at 11:46 PM Emil Velikov emil.l.velikov@gmail.com wrote:
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" rjw@rjwysocki.net Cc: Len Brown len.brown@intel.com Cc: linux-pm@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Acked-by: Rafael J. Wysocki rafael.j.wysocki@intel.com
and I'm assuming that this is going to be applied along with the rest of the series.
Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree.
kernel/power/poweroff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c index 6d475281c730..562aa0e450ed 100644 --- a/kernel/power/poweroff.c +++ b/kernel/power/poweroff.c @@ -29,7 +29,7 @@ static void handle_poweroff(int key) schedule_work_on(cpumask_first(cpu_online_mask), &poweroff_work); }
-static struct sysrq_key_op sysrq_poweroff_op = { +static const struct sysrq_key_op sysrq_poweroff_op = { .handler = handle_poweroff, .help_msg = "poweroff(o)", .action_msg = "Power Off", -- 2.25.1
On Thu, 14 May 2020 at 12:21, Rafael J. Wysocki rafael@kernel.org wrote:
On Wed, May 13, 2020 at 11:46 PM Emil Velikov emil.l.velikov@gmail.com wrote:
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" rjw@rjwysocki.net Cc: Len Brown len.brown@intel.com Cc: linux-pm@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Acked-by: Rafael J. Wysocki rafael.j.wysocki@intel.com
Thanks
and I'm assuming that this is going to be applied along with the rest of the series.
I believe so, although I have not heard anything from the TTY maintainers yet.
-Emil
On Fri, May 15, 2020 at 11:11:57AM +0100, Emil Velikov wrote:
On Thu, 14 May 2020 at 12:21, Rafael J. Wysocki rafael@kernel.org wrote:
On Wed, May 13, 2020 at 11:46 PM Emil Velikov emil.l.velikov@gmail.com wrote:
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" rjw@rjwysocki.net Cc: Len Brown len.brown@intel.com Cc: linux-pm@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Acked-by: Rafael J. Wysocki rafael.j.wysocki@intel.com
Thanks
and I'm assuming that this is going to be applied along with the rest of the series.
I believe so, although I have not heard anything from the TTY maintainers yet.
I will take them all, thanks.
greg k-h
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: "Paul E. McKenney" paulmck@kernel.org Cc: Josh Triplett josh@joshtriplett.org Cc: rcu@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree. --- kernel/rcu/tree_stall.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 119ed6afd20f..4e6ed7b91f59 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -729,7 +729,7 @@ static void sysrq_show_rcu(int key) show_rcu_gp_kthreads(); }
-static struct sysrq_key_op sysrq_rcudump_op = { +static const struct sysrq_key_op sysrq_rcudump_op = { .handler = sysrq_show_rcu, .help_msg = "show-rcu(y)", .action_msg = "Show RCU tree",
On Wed, May 13, 2020 at 10:43:51PM +0100, Emil Velikov wrote:
With earlier commits, the API no longer discards the const-ness of the sysrq_key_op. As such we can add the notation.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: "Paul E. McKenney" paulmck@kernel.org Cc: Josh Triplett josh@joshtriplett.org Cc: rcu@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree.
Works for me:
Reviewed-by: Paul E. McKenney paulmck@kernel.org
kernel/rcu/tree_stall.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 119ed6afd20f..4e6ed7b91f59 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -729,7 +729,7 @@ static void sysrq_show_rcu(int key) show_rcu_gp_kthreads(); }
-static struct sysrq_key_op sysrq_rcudump_op = { +static const struct sysrq_key_op sysrq_rcudump_op = { .handler = sysrq_show_rcu, .help_msg = "show-rcu(y)", .action_msg = "Show RCU tree", -- 2.25.1
On Wed, May 13, 2020 at 10:43:41PM +0100, Emil Velikov wrote:
Export a pointer to the sysrq_get_key_op(). This way we can cleanly unregister it, instead of the current solutions of modifuing it inplace.
Since __sysrq_get_key_op() is no longer used externally, let's make it a static function.
This patch will allow us to limit access to each and every sysrq op and constify the sysrq handling.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Richard Henderson rth@twiddle.net Cc: Ivan Kokshaysky ink@jurassic.park.msu.ru Cc: Matt Turner mattst88@gmail.com Cc: linux-alpha@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree.
All now taken, thanks!
greg k-h
On Wed, May 13, 2020 at 10:43:41PM +0100, Emil Velikov wrote:
Export a pointer to the sysrq_get_key_op(). This way we can cleanly unregister it, instead of the current solutions of modifuing it inplace.
Since __sysrq_get_key_op() is no longer used externally, let's make it a static function.
This patch will allow us to limit access to each and every sysrq op and constify the sysrq handling.
This patch results in:
Building alpha:defconfig ... failed -------------- Error log: <stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp] arch/alpha/kernel/setup.c:435:13: error: initialization of 'void (*)(int)' from incompatible pointer type 'void (*)(void)'
... which does make me wonder if it was even build tested.
Guenter
--- # bad: [af7b4801030c07637840191c69eb666917e4135d] Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net # good: [3b69e8b4571125bec1f77f886174fe6cab6b9d75] Merge tag 'sh-for-5.8' of git://git.libc.org/linux-sh git bisect start 'HEAD' '3b69e8b45711' # good: [77f55d1305c11fb729b88f2c3f7881ba0831fa6f] staging: rtl8723bs: Use common packet header constants git bisect good 77f55d1305c11fb729b88f2c3f7881ba0831fa6f # bad: [f558b8364e19f9222e7976c64e9367f66bab02cc] Merge tag 'driver-core-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core git bisect bad f558b8364e19f9222e7976c64e9367f66bab02cc # good: [ca681aa49200422a4144ee376a2079a9f717bf11] Merge tag 'usb-for-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next git bisect good ca681aa49200422a4144ee376a2079a9f717bf11 # bad: [a1b44ea340b21c99b34c93acad233da727cb88ba] tty: serial: qcom_geni_serial: Add 51.2MHz frequency support git bisect bad a1b44ea340b21c99b34c93acad233da727cb88ba # good: [e0a851fe6b9b619527bd928aa93caaddd003f70c] serial: 8250: Avoid error message on reprobe git bisect good e0a851fe6b9b619527bd928aa93caaddd003f70c # bad: [57626ff1c9135211b92dfbea1923333c7b6dd12c] tty: n_gsm: Remove unnecessary test in gsm_print_packet() git bisect bad 57626ff1c9135211b92dfbea1923333c7b6dd12c # bad: [675cacf11462f112ab13d57e1163082161ef8708] MIPS: constify sysrq_key_op git bisect bad 675cacf11462f112ab13d57e1163082161ef8708 # bad: [0f1c9688a194d22bb81953bd85bd18b0115fd17f] tty/sysrq: alpha: export and use __sysrq_get_key_op() git bisect bad 0f1c9688a194d22bb81953bd85bd18b0115fd17f # good: [7b668c064ec33f3d687c3a413d05e355172e6c92] serial: 8250: Fix max baud limit in generic 8250 port git bisect good 7b668c064ec33f3d687c3a413d05e355172e6c92 # good: [beca62c4212ade1516a526784adf7f7d99c7f3d9] tty: mxser: make mxser_change_speed() return void git bisect good beca62c4212ade1516a526784adf7f7d99c7f3d9 # first bad commit: [0f1c9688a194d22bb81953bd85bd18b0115fd17f] tty/sysrq: alpha: export and use __sysrq_get_key_op()
On Wed, May 13, 2020 at 10:43:41PM +0100, Emil Velikov wrote:
Export a pointer to the sysrq_get_key_op(). This way we can cleanly unregister it, instead of the current solutions of modifuing it inplace.
Since __sysrq_get_key_op() is no longer used externally, let's make it a static function.
This patch will allow us to limit access to each and every sysrq op and constify the sysrq handling.
Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org Cc: Jiri Slaby jslaby@suse.com Cc: linux-kernel@vger.kernel.org Cc: Richard Henderson rth@twiddle.net Cc: Ivan Kokshaysky ink@jurassic.park.msu.ru Cc: Matt Turner mattst88@gmail.com Cc: linux-alpha@vger.kernel.org Signed-off-by: Emil Velikov emil.l.velikov@gmail.com
Please keep me in the CC list, as I'm not subscribed to the list.
IMHO it would be better if this gets merged this via the tty tree.
Still observed:
Building alpha:defconfig ... failed -------------- Error log: <stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp] arch/alpha/kernel/setup.c:434:13: error: initialization of 'void (*)(int)' from incompatible pointer type 'void (*)(void)' [-Werror=incompatible-pointer-types] 434 | .handler = machine_halt, | ^~~~~~~~~~~~ arch/alpha/kernel/setup.c:434:13: note: (near initialization for 'srm_sysrq_reboot_op.handler')
I did not see a reply to the initial report. Is this being addressed ?
Guenter
dri-devel@lists.freedesktop.org