@@ -416,22 +416,25 @@ enum ssb_mitigation_cmd {
416416 SPEC_STORE_BYPASS_CMD_AUTO ,
417417 SPEC_STORE_BYPASS_CMD_ON ,
418418 SPEC_STORE_BYPASS_CMD_PRCTL ,
419+ SPEC_STORE_BYPASS_CMD_SECCOMP ,
419420};
420421
421422static const char * ssb_strings [] = {
422423 [SPEC_STORE_BYPASS_NONE ] = "Vulnerable" ,
423424 [SPEC_STORE_BYPASS_DISABLE ] = "Mitigation: Speculative Store Bypass disabled" ,
424- [SPEC_STORE_BYPASS_PRCTL ] = "Mitigation: Speculative Store Bypass disabled via prctl"
425+ [SPEC_STORE_BYPASS_PRCTL ] = "Mitigation: Speculative Store Bypass disabled via prctl" ,
426+ [SPEC_STORE_BYPASS_SECCOMP ] = "Mitigation: Speculative Store Bypass disabled via prctl and seccomp" ,
425427};
426428
427429static const struct {
428430 const char * option ;
429431 enum ssb_mitigation_cmd cmd ;
430432} ssb_mitigation_options [] = {
431- { "auto" , SPEC_STORE_BYPASS_CMD_AUTO }, /* Platform decides */
432- { "on" , SPEC_STORE_BYPASS_CMD_ON }, /* Disable Speculative Store Bypass */
433- { "off" , SPEC_STORE_BYPASS_CMD_NONE }, /* Don't touch Speculative Store Bypass */
434- { "prctl" , SPEC_STORE_BYPASS_CMD_PRCTL }, /* Disable Speculative Store Bypass via prctl */
433+ { "auto" , SPEC_STORE_BYPASS_CMD_AUTO }, /* Platform decides */
434+ { "on" , SPEC_STORE_BYPASS_CMD_ON }, /* Disable Speculative Store Bypass */
435+ { "off" , SPEC_STORE_BYPASS_CMD_NONE }, /* Don't touch Speculative Store Bypass */
436+ { "prctl" , SPEC_STORE_BYPASS_CMD_PRCTL }, /* Disable Speculative Store Bypass via prctl */
437+ { "seccomp" , SPEC_STORE_BYPASS_CMD_SECCOMP }, /* Disable Speculative Store Bypass via prctl and seccomp */
435438};
436439
437440static enum ssb_mitigation_cmd __init ssb_parse_cmdline (void )
@@ -481,8 +484,15 @@ static enum ssb_mitigation_cmd __init __ssb_select_mitigation(void)
481484
482485 switch (cmd ) {
483486 case SPEC_STORE_BYPASS_CMD_AUTO :
484- /* Choose prctl as the default mode */
485- mode = SPEC_STORE_BYPASS_PRCTL ;
487+ case SPEC_STORE_BYPASS_CMD_SECCOMP :
488+ /*
489+ * Choose prctl+seccomp as the default mode if seccomp is
490+ * enabled.
491+ */
492+ if (IS_ENABLED (CONFIG_SECCOMP ))
493+ mode = SPEC_STORE_BYPASS_SECCOMP ;
494+ else
495+ mode = SPEC_STORE_BYPASS_PRCTL ;
486496 break ;
487497 case SPEC_STORE_BYPASS_CMD_ON :
488498 mode = SPEC_STORE_BYPASS_DISABLE ;
@@ -530,12 +540,14 @@ static void ssb_select_mitigation()
530540}
531541
532542#undef pr_fmt
543+ #define pr_fmt (fmt ) "Speculation prctl: " fmt
533544
534545static int ssb_prctl_set (struct task_struct * task , unsigned long ctrl )
535546{
536547 bool update ;
537548
538- if (ssb_mode != SPEC_STORE_BYPASS_PRCTL )
549+ if (ssb_mode != SPEC_STORE_BYPASS_PRCTL &&
550+ ssb_mode != SPEC_STORE_BYPASS_SECCOMP )
539551 return - ENXIO ;
540552
541553 switch (ctrl ) {
@@ -583,7 +595,8 @@ int arch_prctl_spec_ctrl_set(struct task_struct *task, unsigned long which,
583595#ifdef CONFIG_SECCOMP
584596void arch_seccomp_spec_mitigate (struct task_struct * task )
585597{
586- ssb_prctl_set (task , PR_SPEC_FORCE_DISABLE );
598+ if (ssb_mode == SPEC_STORE_BYPASS_SECCOMP )
599+ ssb_prctl_set (task , PR_SPEC_FORCE_DISABLE );
587600}
588601#endif
589602
@@ -592,6 +605,7 @@ static int ssb_prctl_get(struct task_struct *task)
592605 switch (ssb_mode ) {
593606 case SPEC_STORE_BYPASS_DISABLE :
594607 return PR_SPEC_DISABLE ;
608+ case SPEC_STORE_BYPASS_SECCOMP :
595609 case SPEC_STORE_BYPASS_PRCTL :
596610 if (task_spec_ssb_force_disable (task ))
597611 return PR_SPEC_PRCTL | PR_SPEC_FORCE_DISABLE ;
0 commit comments