@@ -416,22 +416,25 @@ enum ssb_mitigation_cmd {
416
416
SPEC_STORE_BYPASS_CMD_AUTO ,
417
417
SPEC_STORE_BYPASS_CMD_ON ,
418
418
SPEC_STORE_BYPASS_CMD_PRCTL ,
419
+ SPEC_STORE_BYPASS_CMD_SECCOMP ,
419
420
};
420
421
421
422
static const char * ssb_strings [] = {
422
423
[SPEC_STORE_BYPASS_NONE ] = "Vulnerable" ,
423
424
[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" ,
425
427
};
426
428
427
429
static const struct {
428
430
const char * option ;
429
431
enum ssb_mitigation_cmd cmd ;
430
432
} 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 */
435
438
};
436
439
437
440
static enum ssb_mitigation_cmd __init ssb_parse_cmdline (void )
@@ -481,8 +484,15 @@ static enum ssb_mitigation_cmd __init __ssb_select_mitigation(void)
481
484
482
485
switch (cmd ) {
483
486
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 ;
486
496
break ;
487
497
case SPEC_STORE_BYPASS_CMD_ON :
488
498
mode = SPEC_STORE_BYPASS_DISABLE ;
@@ -530,12 +540,14 @@ static void ssb_select_mitigation()
530
540
}
531
541
532
542
#undef pr_fmt
543
+ #define pr_fmt (fmt ) "Speculation prctl: " fmt
533
544
534
545
static int ssb_prctl_set (struct task_struct * task , unsigned long ctrl )
535
546
{
536
547
bool update ;
537
548
538
- if (ssb_mode != SPEC_STORE_BYPASS_PRCTL )
549
+ if (ssb_mode != SPEC_STORE_BYPASS_PRCTL &&
550
+ ssb_mode != SPEC_STORE_BYPASS_SECCOMP )
539
551
return - ENXIO ;
540
552
541
553
switch (ctrl ) {
@@ -583,7 +595,8 @@ int arch_prctl_spec_ctrl_set(struct task_struct *task, unsigned long which,
583
595
#ifdef CONFIG_SECCOMP
584
596
void arch_seccomp_spec_mitigate (struct task_struct * task )
585
597
{
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 );
587
600
}
588
601
#endif
589
602
@@ -592,6 +605,7 @@ static int ssb_prctl_get(struct task_struct *task)
592
605
switch (ssb_mode ) {
593
606
case SPEC_STORE_BYPASS_DISABLE :
594
607
return PR_SPEC_DISABLE ;
608
+ case SPEC_STORE_BYPASS_SECCOMP :
595
609
case SPEC_STORE_BYPASS_PRCTL :
596
610
if (task_spec_ssb_force_disable (task ))
597
611
return PR_SPEC_PRCTL | PR_SPEC_FORCE_DISABLE ;
0 commit comments