LSM: Add and use a hook for side-channel safety checks
Subsystems (5)
v2 cover LSM: Add and use a hook for side-channel safety checks
v2: SELinux access policy corrected.
Use real_cred instead of cred.
This patchset provide a mechanism by which a security module can advise the system about potential side-channel vulnerabilities. If security_safe_sidechannel() returns 0 the security modules do not know of any data that would be subject to a side-channel attack. If the security module maintains data that it believes may be susceptible to a side-channel attack it will return -EACCES.
Simple hooks are provided for SELinux and Smack. A new security module is provided to make determinations regarding traditional task attributes, including user IDs, capability sets and namespaces.
--- MAINTAINERS | 6 ++ arch/x86/mm/tlb.c | 12 ++- include/linux/lsm_hooks.h | 12 +++ include/linux/security.h | 1 + security/Kconfig | 1 + security/Makefile | 2 + security/security.c | 6 ++ security/selinux/hooks.c | 9 +++ security/sidechannel/Kconfig | 60 ++++++++++++++ security/sidechannel/Makefile | 1 + security/sidechannel/sidechannel.c | 156 +++++++++++++++++++++++++++++++++++++ security/smack/smack_lsm.c | 18 +++++ 12 files changed, 280 insertions(+), 4 deletions(-)
RFC PATCH v2 1/5 LSM: Introduce a hook for side-channel danger
From: Casey Schaufler <[email protected]>
There may be cases where the data maintained for security controls is more sensitive than general process information and that may be subjected to side-channel attacks. An LSM hook is provided so that this can be check for where the system would take action should the current task have potential access to the passed task.
--- include/linux/lsm_hooks.h | 7 +++++++ include/linux/security.h | 1 + security/security.c | 5 +++++ 3 files changed, 13 insertions(+)
include/linux/lsm_hooks.h +7 -0
@@ -698,6 +698,11 @@* security attributes, e.g. for /proc/pid inodes. * @p contains the task_struct for the task. * @inode contains the inode structure for the inode. +* @task_safe_sidechannel: +* Check if a side channel attack is harmless for the current task and @p. +* The caller may have determined that no attack is possible, in which +* case this hook won't get called. +* @p contains the task_struct for the task. * * Security hooks for Netlink messaging. *
@@ -1611,6 +1616,7 @@ union security_list_options {int (*task_prctl)(int option,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5);void (*task_to_inode)(struct task_struct *p,struct inode *inode); +int (*task_safe_sidechannel)(struct task_struct *p);int (*ipc_permission)(struct kern_ipc_perm *ipcp,short flag);void (*ipc_getsecid)(struct kern_ipc_perm *ipcp,u32 *secid);
@@ -1897,6 +1903,7 @@ struct security_hook_heads {struct hlist_head task_kill;struct hlist_head task_prctl;struct hlist_head task_to_inode; +struct hlist_head task_safe_sidechannel;struct hlist_head ipc_permission;struct hlist_head ipc_getsecid;struct hlist_head msg_msg_alloc_security;
include/linux/security.h +1 -0
@@ -366,6 +366,7 @@ int security_task_kill(struct task_struct *p, struct siginfo *info,int security_task_prctl (int option,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5);void security_task_to_inode (struct task_struct *p,struct inode *inode); +int security_task_safe_sidechannel (struct task_struct *p);int security_ipc_permission (struct kern_ipc_perm *ipcp,short flag);void security_ipc_getsecid (struct kern_ipc_perm *ipcp,u32 *secid);int security_msg_msg_alloc (struct msg_msg *msg);
security/security.c +5 -0
@@ -1165,6 +1165,11 @@ void security_task_to_inode(struct task_struct *p, struct inode *inode)call_void_hook (task_to_inode, p, inode); } +int security_task_safe_sidechannel (struct task_struct *p) +{ +return call_int_hook (task_safe_sidechannel,0 , p); +} +int security_ipc_permission (struct kern_ipc_perm *ipcp,short flag) {return call_int_hook (ipc_permission,0 , ipcp, flag);
Signature · 1 line
2.17.1
RFC PATCH v2 2/5 X86: Support LSM determination of side-channel vulnerability
In reply to Casey SchauflerFrom: Casey Schaufler <[email protected]>
When switching between tasks it may be necessary to set an indirect branch prediction barrier if the tasks are potentially vulnerable to side-channel attacks. This adds a call to security_task_safe_sidechannel so that security modules can weigh in on the decision.
--- arch/x86/mm/tlb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/mm/tlb.c +8 -4
@@ -7,6 +7,7 @@#include <linux/export.h> #include <linux/cpu.h> #include <linux/debugfs.h> +#include <linux/security.h> #include <asm/tlbflush.h> #include <asm/mmu_context.h>
@@ -270,11 +271,14 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,* threads. It will also not flush if we switch to idle * thread and back to the same process. It will flush if we * switch to a different non-dumpable process. +* If a security module thinks that the transition +* is unsafe do the flush. */ -if (tsk && tsk->mm && - tsk->mm->context.ctx_id != last_ctx_id && -get_dumpable (tsk->mm) !=SUID_DUMP_USER ) -indirect_branch_prediction_barrier (); +if (tsk && tsk->mm && tsk->mm->context.ctx_id != last_ctx_id) { +if (get_dumpable (tsk->mm) !=SUID_DUMP_USER || +security_task_safe_sidechannel (tsk) !=0 ) +indirect_branch_prediction_barrier (); + }if (IS_ENABLED (CONFIG_VMAP_STACK )) {/*
Signature · 1 line
2.17.1
RFC PATCH v2 3/5 LSM: Security module checking for side-channel dangers
In reply to Casey SchauflerFrom: Casey Schaufler <[email protected]>
The sidechannel LSM checks for cases where a side-channel attack may be dangerous based on security attributes of tasks. This includes:
Effective UID of the tasks is different Capablity sets are different
Tasks are in different namespaces
An option is also provided to assert that task are never to be considered safe. This is high paranoia, and expensive as well.
--- MAINTAINERS | 6 ++ include/linux/lsm_hooks.h | 5 + security/Kconfig | 1 + security/Makefile | 2 + security/security.c | 1 + security/sidechannel/Kconfig | 60 +++++++++++ security/sidechannel/Makefile | 1 + security/sidechannel/sidechannel.c | 156 +++++++++++++++++++++++++++++ 8 files changed, 232 insertions(+) create mode 100644 security/sidechannel/Kconfig create mode 100644 security/sidechannel/Makefile create mode 100644 security/sidechannel/sidechannel.c
MAINTAINERS +6 -0
@@ -13066,6 +13066,12 @@ F: drivers/slimbus/ F: Documentation/devicetree/bindings/slimbus/ F: include/linux/slimbus.h +SIDECHANNEL SECURITY MODULE +M: Casey Schaufler <[email protected]> +L: [email protected] +S: Maintained +F: security/sidechannel/ + SMACK SECURITY MODULE M: Casey Schaufler <[email protected]> L: [email protected]
include/linux/lsm_hooks.h +5 -0
@@ -2088,5 +2088,10 @@ void __init loadpin_add_hooks(void);#else static inline void loadpin_add_hooks (void ) { };#endif +#ifdef CONFIG_SECURITY_SIDECHANNEL +void __init sidechannel_add_hooks (void ); +#else +static inline void sidechannel_add_hooks (void ) { }; +#endif #endif /* ! __LINUX_LSM_HOOKS_H */
security/Kconfig +1 -0
@@ -237,6 +237,7 @@ source security/tomoyo/Kconfig source security/apparmor/Kconfig source security/loadpin/Kconfig source security/yama/Kconfig +source security/sidechannel/Kconfig source security/integrity/Kconfig
security/Makefile +2 -0
@@ -10,6 +10,7 @@ subdir-$(CONFIG_SECURITY_TOMOYO) += tomoyo subdir-$(CONFIG_SECURITY_APPARMOR) += apparmor subdir-$(CONFIG_SECURITY_YAMA) += yama subdir-$(CONFIG_SECURITY_LOADPIN) += loadpin +subdir-$(CONFIG_SECURITY_SIDECHANNEL) += sidechannel # always enable default capabilities obj-y += commoncap.o
@@ -25,6 +26,7 @@ obj-$(CONFIG_SECURITY_TOMOYO) += tomoyo/ obj-$(CONFIG_SECURITY_APPARMOR) += apparmor/ obj-$(CONFIG_SECURITY_YAMA) += yama/ obj-$(CONFIG_SECURITY_LOADPIN) += loadpin/ +obj-$(CONFIG_SECURITY_SIDECHANNEL) += sidechannel/ obj-$(CONFIG_CGROUP_DEVICE) += device_cgroup.o # Object integrity file lists
security/security.c +1 -0
@@ -80,6 +80,7 @@ int __init security_init(void)capability_add_hooks ();yama_add_hooks ();loadpin_add_hooks (); +sidechannel_add_hooks ();/* * Load all the remaining security modules.
security/sidechannel/Kconfig new file +60 -0
60 lines not on this page · raw message
security/sidechannel/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_SECURITY_SIDECHANNEL) += sidechannel.o
security/sidechannel/sidechannel.c new file +156 -0
156 lines not on this page · raw message
Signature · 1 line
2.17.1
RFC PATCH v2 4/5 Smack: Support determination of side-channel vulnerability
In reply to Casey SchauflerSmack considers its private task data safe if the current task has read access to the passed task.
--- security/smack/smack_lsm.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
security/smack/smack_lsm.c +18 -0
@@ -2299,6 +2299,23 @@ static void smack_task_to_inode(struct task_struct *p, struct inode *inode) isp->smk_inode = skp; } +/** +* smack_task_safe_sidechannel - Are the task and current sidechannel safe? +* @p: task to check on +* +* A crude value for sidechannel safety is that the current task is +* already allowed to read from the other. +* +* Returns 0 if the tasks are sidechannel safe, -EACCES otherwise. +*/ +static int smack_task_safe_sidechannel (struct task_struct *p) +{ +struct smack_known *skp =smk_of_task_struct (p); +struct smack_known *ckp =smk_of_task_struct (current); + +return smk_access (ckp, skp,MAY_READ ,NULL ); +} +/* * Socket hooks. */
@@ -4718,6 +4735,7 @@ static struct security_hook_list smack_hooks[] __lsm_ro_after_init = {LSM_HOOK_INIT (task_movememory, smack_task_movememory),LSM_HOOK_INIT (task_kill, smack_task_kill),LSM_HOOK_INIT (task_to_inode, smack_task_to_inode), +LSM_HOOK_INIT (task_safe_sidechannel, smack_task_safe_sidechannel),LSM_HOOK_INIT (ipc_permission, smack_ipc_permission), LSM_HOOK_INIT(ipc_getsecid, smack_ipc_getsecid),
Signature · 1 line
2.17.1
RFC PATCH v2 5/5 SELinux: Support SELinux determination of side-channel vulnerability
In reply to Casey SchauflerSELinux considers tasks to be side-channel safe if they have PROCESS_SHARE access.
--- security/selinux/hooks.c | 9 +++++++++ 1 file changed, 9 insertions(+)
security/selinux/hooks.c +9 -0
@@ -4219,6 +4219,14 @@ static void selinux_task_to_inode(struct task_struct *p,spin_unlock (&isec->lock); } +static int selinux_task_safe_sidechannel (struct task_struct *p) +{ +struct av_decision avd; + +return avc_has_perm_noaudit (&selinux_state,current_sid (),task_sid (p), +SECCLASS_FILE ,FILE__READ ,0 , &avd); +} +/* Returns error only if unable to parse addresses */ static int selinux_parse_skb_ipv4 (struct sk_buff *skb,struct common_audit_data *ad,u8 *proto)
@@ -7002,6 +7010,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {LSM_HOOK_INIT (task_movememory, selinux_task_movememory),LSM_HOOK_INIT (task_kill, selinux_task_kill),LSM_HOOK_INIT (task_to_inode, selinux_task_to_inode), +LSM_HOOK_INIT (task_safe_sidechannel, selinux_task_safe_sidechannel),LSM_HOOK_INIT (ipc_permission, selinux_ipc_permission), LSM_HOOK_INIT(ipc_getsecid, selinux_ipc_getsecid),
Signature · 1 line
2.17.1
Re: [PATCH RFC v2 3/5] LSM: Security module checking for side-channel dangers
In reply to Casey SchauflerQuoted 14 lines · Casey Schaufler
From: Casey Schaufler <[email protected]>
The sidechannel LSM checks for cases where a side-channel attack may be dangerous based on security attributes of tasks. This includes:
Effective UID of the tasks is different Capablity sets are different
Tasks are in different namespaces
An option is also provided to assert that task are never to be considered safe. This is high paranoia, and expensive as well.Signed-off-by Casey Schaufler <[email protected]>
[...]
Quoted 4 lines
security/sidechannel/sidechannel.c new file +4
-0+#ifdef CONFIG_SECURITY_SIDECHANNEL_UIDS +static int safe_by_uid (struct task_struct *p) +{ +const struct cred *ccred =current_real_cred ();
security/sidechannel/sidechannel.c line 45
Quoted 10 lines
security/sidechannel/sidechannel.c new file +10
-0+const struct cred *pcred =get_task_cred (p); + +/* +* Credential checks. Considered safe if: +* UIDs are the same +*/ +if (ccred != pcred && ccred->euid.val != pcred->euid.val) +return -EACCES ; +return 0 ; +}
This function looks bogus. get_task_cred() bumps the refcount on the returned cred struct pointer, but you don't drop it. You probably want to use something that doesn't fiddle with the refcount at all here to avoid cacheline bouncing - possibly a raw rcu_dereference_protected() if there are no better helpers.
Same thing for the other get_task_cred() calls further down in the patch.
Re: [PATCH RFC v2 2/5] X86: Support LSM determination of side-channel vulnerability
In reply to Casey SchauflerQuoted 32 lines · Casey Schaufler
From: Casey Schaufler <[email protected]>
When switching between tasks it may be necessary to set an indirect branch prediction barrier if the tasks are potentially vulnerable to side-channel attacks. This adds a call to
security_task_safe_sidechannelso that security modules can weigh in on the decision.Signed-off-by Casey Schaufler <[email protected]>--- arch/x86/mm/tlb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)arch/x86/mm/tlb.c +3
-0@@ -7,6 +7,7 @@#include <linux/export.h> #include <linux/cpu.h> #include <linux/debugfs.h> +#include <linux/security.h> #include <asm/tlbflush.h> #include <asm/mmu_context.h> @@ -270,11 +271,14 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,* threads. It will also not flush if we switch to idle * thread and back to the same process. It will flush if we * switch to a different non-dumpable process. +* If a security module thinks that the transition +* is unsafe do the flush.
arch/x86/mm/tlb.c void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, · line 281
Quoted 10 lines
arch/x86/mm/tlb.c +5
-4*/ -if (tsk && tsk->mm && - tsk->mm->context.ctx_id != last_ctx_id && -get_dumpable (tsk->mm) !=SUID_DUMP_USER ) -indirect_branch_prediction_barrier (); +if (tsk && tsk->mm && tsk->mm->context.ctx_id != last_ctx_id) { +if (get_dumpable (tsk->mm) !=SUID_DUMP_USER || +security_task_safe_sidechannel (tsk) !=0 ) +indirect_branch_prediction_barrier (); + }
When you posted v1 of this series, I asked:
| Does this enforce transitivity? What happens if we first switch from | an attacker task to a task without ->mm, and immediately afterwards | from the task without ->mm to a victim task? In that case, whether a | flush happens between the attacker task and the victim task depends on | whether the LSM thinks that the mm-less task should have access to the | victim task, right?
Have you addressed that? I don't see it...
RE: [PATCH RFC v2 2/5] X86: Support LSM determination of side-channel vulnerability
Quoted 60 lines
-----Original Message-----
From: Jann Horn [mailto:[email protected]]
Sent: Friday, August 17, 2018 4:55 PM
To: Schaufler, Casey <[email protected]>
Cc: Kernel Hardening <[email protected]>; kernel list <[email protected]>; linux-security-module <linux-security- [email protected]>; [email protected]; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; [email protected]; Arjan van de Ven <[email protected]>
Subject: Re: [PATCH RFC v2 2/5] X86: Support LSM determination of side- channel vulnerabilityarch/x86/mm/tlb.c void switch_mm_irqs_off(struct mm_struct *prev,
Quoted 27 lines · Casey Schaufler
From: Casey Schaufler <[email protected]>
When switching between tasks it may be necessary to set an indirect branch prediction barrier if the tasks are potentially vulnerable to side-channel attacks. This adds a call to
security_task_safe_sidechannelso that security modules can weigh in on the decision.Signed-off-by Casey Schaufler <[email protected]>--- arch/x86/mm/tlb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)arch/x86/mm/tlb.c +1
-0@@ -7,6 +7,7 @@#include <linux/export.h> #include <linux/cpu.h> #include <linux/debugfs.h> +#include <linux/security.h> #include <asm/tlbflush.h> #include <asm/mmu_context.h> @@ -270,11 +271,14 @@ void switch_mm_irqs_off(struct mm_struct *prev,struct
mm_struct*next,Quoted 5 lines
arch/x86/mm/tlb.c +2
-0* threads. It will also not flush if we switch to idle * thread and back to the same process. It will flush if we * switch to a different non-dumpable process. +* If a security module thinks that the transition +* is unsafe do the flush. arch/x86/mm/tlb.c void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, · line 281
Quoted 10 lines
arch/x86/mm/tlb.c +5
-4*/ -if (tsk && tsk->mm && - tsk->mm->context.ctx_id != last_ctx_id && -get_dumpable (tsk->mm) !=SUID_DUMP_USER ) -indirect_branch_prediction_barrier (); +if (tsk && tsk->mm && tsk->mm->context.ctx_id != last_ctx_id) { +if (get_dumpable (tsk->mm) !=SUID_DUMP_USER || +security_task_safe_sidechannel (tsk) !=0 ) +indirect_branch_prediction_barrier (); + }When you posted v1 of this series, I asked:
Quoted 8 lines
| Does this enforce transitivity? What happens if we first switch from | an attacker task to a task without ->mm, and immediately afterwards | from the task without ->mm to a victim task? In that case, whether a | flush happens between the attacker task and the victim task depends on | whether the LSM thinks that the mm-less task should have access to the | victim task, right?Have you addressed that? I don't see it...
Nope. That's going to require maintaining state about all the tasks in the chain that might still have cache involvement.
A -> B -> C -> D
If B and C don't do anything cacheworthy D could conceivably attack A. The amount of state required to detect this case would be prohibitive. I think that if you're sufficiently concerned about this case you should just go ahead and set the barrier. I'm willing to learn something that says I'm wrong.
RE: [PATCH RFC v2 3/5] LSM: Security module checking for side-channel dangers
In reply to Jann HornQuoted 50 lines
-----Original Message-----
From: Jann Horn [mailto:[email protected]]
Sent: Friday, August 17, 2018 4:53 PM
To: Schaufler, Casey <[email protected]>
Cc: Kernel Hardening <[email protected]>; kernel list <[email protected]>; linux-security-module <linux-security- [email protected]>; [email protected]; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; [email protected]; Arjan van de Ven <[email protected]>
Subject: Re: [PATCH RFC v2 3/5] LSM: Security module checking for side- channel dangersQuoted 14 lines · Casey Schaufler
From: Casey Schaufler <[email protected]>
The sidechannel LSM checks for cases where a side-channel attack may be dangerous based on security attributes of tasks. This includes:
Effective UID of the tasks is different Capablity sets are different
Tasks are in different namespaces
An option is also provided to assert that task are never to be considered safe. This is high paranoia, and expensive as well.Signed-off-by Casey Schaufler <[email protected]>[...]
Quoted 4 lines
security/sidechannel/sidechannel.c new file +4
-0+#ifdef CONFIG_SECURITY_SIDECHANNEL_UIDS +static int safe_by_uid (struct task_struct *p) +{ +const struct cred *ccred =current_real_cred ();security/sidechannel/sidechannel.c line 45
Quoted 10 lines
security/sidechannel/sidechannel.c new file +10
-0+const struct cred *pcred =get_task_cred (p); + +/* +* Credential checks. Considered safe if: +* UIDs are the same +*/ +if (ccred != pcred && ccred->euid.val != pcred->euid.val) +return -EACCES ; +return 0 ; +}This function looks bogus.
get_task_cred()bumps the refcount on the returned cred struct pointer, but you don't drop it. You probably want to use something that doesn't fiddle with the refcount at all here to avoid cacheline bouncing - possibly a rawrcu_dereference_protected()if there are no better helpers.
Quoted 1 line
Same thing for the other
get_task_cred()calls further down in the patch.
Thanks. Looks like I whacked out v2 a bit hastily.
Re: [PATCH RFC v2 5/5] SELinux: Support SELinux determination of side-channel vulnerability
In reply to Casey SchauflerQuoted 2 lines · Casey Schaufler
SELinux considers tasks to be side-channel safe if they have
PROCESS_SHAREaccess.
Now the description and the code no longer match.
Quoted 11 lines
Signed-off-by Casey Schaufler <[email protected]>--- security/selinux/hooks.c | 9 +++++++++ 1 file changed, 9 insertions(+)security/selinux/hooks.c +0
-0
security/selinux/hooks.c static void selinux_task_to_inode(struct task_struct *p, · line 4228
Quoted 10 lines
security/selinux/hooks.c +7
-0@@ -4219,6 +4219,14 @@ static void selinux_task_to_inode(struct task_struct *p,spin_unlock (&isec->lock); } +static int selinux_task_safe_sidechannel (struct task_struct *p) +{ +struct av_decision avd; + +return avc_has_perm_noaudit (&selinux_state,current_sid (),task_sid (p), +SECCLASS_FILE ,FILE__READ ,0 , &avd); +}
And my question from before still stands: why do we need a new hook and new security module instead of just using ptrace_may_access()?
Quoted 13 lines
security/selinux/hooks.c +2
-0+/* Returns error only if unable to parse addresses */ static int selinux_parse_skb_ipv4 (struct sk_buff *skb,struct common_audit_data *ad,u8 *proto)@@ -7002,6 +7010,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {LSM_HOOK_INIT (task_movememory, selinux_task_movememory),LSM_HOOK_INIT (task_kill, selinux_task_kill),LSM_HOOK_INIT (task_to_inode, selinux_task_to_inode), +LSM_HOOK_INIT (task_safe_sidechannel, selinux_task_safe_sidechannel),LSM_HOOK_INIT (ipc_permission, selinux_ipc_permission), LSM_HOOK_INIT(ipc_getsecid, selinux_ipc_getsecid),
RE: [PATCH RFC v2 5/5] SELinux: Support SELinux determination of side-channel vulnerability
Quoted 11 lines
-----Original Message-----
From: Stephen Smalley [mailto:[email protected]]
Sent: Monday, August 20, 2018 9:03 AM
To: Schaufler, Casey <[email protected]>; kernel- [email protected]; [email protected]; linux-security- [email protected]; [email protected]; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH RFC v2 5/5] SELinux: Support SELinux determination of side-channel vulnerability
Quoted 5 lines
Quoted 2 lines · Casey Schaufler
SELinux considers tasks to be side-channel safe if they have
PROCESS_SHAREaccess.Now the description and the code no longer match.
You're right.
Quoted 21 lines
security/selinux/hooks.c static void selinux_task_to_inode(struct
Quoted 11 lines
Signed-off-by Casey Schaufler <[email protected]>--- security/selinux/hooks.c | 9 +++++++++ 1 file changed, 9 insertions(+)security/selinux/hooks.c +0
-0@@ -4219,6 +4219,14 @@ static void selinux_task_to_inode(struct
task_struct*p,security/selinux/hooks.c static void selinux_task_to_inode(struct task_struct *p,
Quoted 8 lines
security/selinux/hooks.c +5
-0spin_unlock (&isec->lock); } +static int selinux_task_safe_sidechannel (struct task_struct *p) +{ +struct av_decision avd; + + return avc_has_perm_noaudit(&selinux_state, current_sid(),
task_sid(p),
Quoted 5 lines
security/selinux/hooks.c static void selinux_task_to_inode(struct task_struct *p, · line 4228
Quoted 2 lines
security/selinux/hooks.c +2
-0+ SECCLASS_FILE, FILE__READ, 0, &avd); +}And my question from before still stands: why do we need a new hook and new security module instead of just using
ptrace_may_access()?
Locking. The SELinux check, for example, will lock up solid while trying to generate an audit record. There is no good reason aside from coding convenience to assume that the same restrictions will apply for side-channel as apply to ptrace. I'm actually a touch surprised you're not suggesting a separate SECCLASS or access mode for the SELinux hook.
Quoted 16 lines
security/selinux/hooks.c static struct security_hook_list selinux_hooks[]
Quoted 6 lines
security/selinux/hooks.c +1
-0+/* Returns error only if unable to parse addresses */ static int selinux_parse_skb_ipv4 (struct sk_buff *skb,struct common_audit_data *ad,u8 *proto)@@ -7002,6 +7010,7 @@ static struct security_hook_list selinux_hooks[]
__lsm_ro_after_init= {security/selinux/hooks.c static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
Quoted 4 lines
security/selinux/hooks.c +1
-0LSM_HOOK_INIT (task_movememory, selinux_task_movememory),LSM_HOOK_INIT (task_kill, selinux_task_kill),LSM_HOOK_INIT (task_to_inode, selinux_task_to_inode), + LSM_HOOK_INIT(task_safe_sidechannel,
selinux_task_safe_sidechannel),Quoted 4 lines
security/selinux/hooks.c +0
-0LSM_HOOK_INIT (ipc_permission, selinux_ipc_permission), LSM_HOOK_INIT(ipc_getsecid, selinux_ipc_getsecid),
Re: [PATCH RFC v2 5/5] SELinux: Support SELinux determination of side-channel vulnerability
Quoted 46 lines · Casey
Quoted 11 lines
-----Original Message-----
From: Stephen Smalley [mailto:sds at tycho.nsa.gov]
Sent: Monday, August 20, 2018 9:03 AM
To: Schaufler, Casey <[email protected]>; kernel-
hardening at lists.openwall.com; linux-kernel at vger.kernel.org; linux-security- module at vger.kernel.org; selinux at tycho.nsa.gov; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; kristen at linux.intel.com; arjan at linux.intel.com
Subject: Re: [PATCH RFC v2 5/5] SELinux: Support SELinux determination of side-channel vulnerabilityQuoted 5 lines
Quoted 2 lines · Casey Schaufler
SELinux considers tasks to be side-channel safe if they have
PROCESS_SHAREaccess.Now the description and the code no longer match.
You're right.
Quoted 21 lines
security/selinux/hooks.c static void selinux_task_to_inode(struct
Quoted 11 lines
Signed-off-by Casey Schaufler <[email protected]>--- security/selinux/hooks.c | 9 +++++++++ 1 file changed, 9 insertions(+)security/selinux/hooks.c +0
-0@@ -4219,6 +4219,14 @@ static void selinux_task_to_inode(struct
task_struct*p,security/selinux/hooks.c static void selinux_task_to_inode(struct task_struct *p,
Quoted 8 lines
security/selinux/hooks.c +5
-0spin_unlock (&isec->lock); } +static int selinux_task_safe_sidechannel (struct task_struct *p) +{ +struct av_decision avd; + + return avc_has_perm_noaudit(&selinux_state, current_sid(),
task_sid(p),Quoted 5 lines
security/selinux/hooks.c static void selinux_task_to_inode(struct task_struct *p, · line 4228
Quoted 2 lines
security/selinux/hooks.c +2
-0+ SECCLASS_FILE, FILE__READ, 0, &avd); +}And my question from before still stands: why do we need a new hook and new security module instead of just using
ptrace_may_access()?
Quoted 5 lines
Locking. The SELinux check, for example, will lock up solid while trying to generate an audit record. There is no good reason aside from coding convenience to assume that the same restrictions will apply for side-channel as apply to ptrace. I'm actually a touch surprised you're not suggesting a separate SECCLASS or access mode for the SELinux hook.
The PTRACE_MODE_NOAUDIT flag to ptrace_may_access() would address the locking concern. Duplicating the ptrace access checking logic seems prone to errors and inconsistencies. I can't imagine policy writers understanding what "safe sidechannel" means, much less deciding when to allow it.
Quoted 18 lines
Quoted 17 lines
security/selinux/hooks.c static struct security_hook_list selinux_hooks[]
Quoted 7 lines
security/selinux/hooks.c +1
-0+/* Returns error only if unable to parse addresses */ static int selinux_parse_skb_ipv4 (struct sk_buff *skb,struct common_audit_data *ad,u8 *proto)@@ -7002,6 +7010,7 @@ static struct security_hook_list selinux_hooks[]
__lsm_ro_after_init= {security/selinux/hooks.c static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
Quoted 4 lines
security/selinux/hooks.c +1
-0LSM_HOOK_INIT (task_movememory, selinux_task_movememory),LSM_HOOK_INIT (task_kill, selinux_task_kill),LSM_HOOK_INIT (task_to_inode, selinux_task_to_inode), + LSM_HOOK_INIT(task_safe_sidechannel,
selinux_task_safe_sidechannel),Quoted 4 lines
security/selinux/hooks.c +0
-0LSM_HOOK_INIT (ipc_permission, selinux_ipc_permission), LSM_HOOK_INIT(ipc_getsecid, selinux_ipc_getsecid),
RE: [PATCH RFC v2 5/5] SELinux: Support SELinux determination of side-channel vulnerability
Quoted 58 lines
-----Original Message-----
From: Stephen Smalley [mailto:[email protected]]
Sent: Monday, August 20, 2018 10:44 AM
To: Schaufler, Casey <[email protected]>; kernel- [email protected]; [email protected]; linux-security- [email protected]; [email protected]; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH RFC v2 5/5] SELinux: Support SELinux determination of side-channel vulnerabilityQuoted 46 lines · Casey
Quoted 11 lines
-----Original Message-----
From: Stephen Smalley [mailto:[email protected]]
Sent: Monday, August 20, 2018 9:03 AM
To: Schaufler, Casey <[email protected]>; kernel- [email protected]; [email protected]; linux-security- [email protected]; [email protected]; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH RFC v2 5/5] SELinux: Support SELinux determination of side-channel vulnerabilityQuoted 5 lines
Quoted 2 lines · Casey Schaufler
SELinux considers tasks to be side-channel safe if they have
PROCESS_SHAREaccess.Now the description and the code no longer match.
You're right.
Quoted 26 lines
security/selinux/hooks.c static void selinux_task_to_inode(struct
Quoted 11 lines
Signed-off-by Casey Schaufler <[email protected]>--- security/selinux/hooks.c | 9 +++++++++ 1 file changed, 9 insertions(+)security/selinux/hooks.c +0
-0@@ -4219,6 +4219,14 @@ static void selinux_task_to_inode(struct
task_struct*p,security/selinux/hooks.c static void selinux_task_to_inode(struct task_struct *p,
Quoted 8 lines
security/selinux/hooks.c +5
-0spin_unlock (&isec->lock); } +static int selinux_task_safe_sidechannel (struct task_struct *p) +{ +struct av_decision avd; + + return avc_has_perm_noaudit(&selinux_state, current_sid(),
task_sid(p),security/selinux/hooks.c static void selinux_task_to_inode(struct task_struct *p, · line 4228
Quoted 2 lines
security/selinux/hooks.c +2
-0+ SECCLASS_FILE, FILE__READ, 0, &avd); +}And my question from before still stands: why do we need a new hook and new security module instead of just using
ptrace_may_access()?
Quoted 8 lines
Quoted 5 lines
Locking. The SELinux check, for example, will lock up solid while trying to generate an audit record. There is no good reason aside from coding convenience to assume that the same restrictions will apply for side-channel as apply to ptrace. I'm actually a touch surprised you're not suggesting a separate SECCLASS or access mode for the SELinux hook.
The
PTRACE_MODE_NOAUDITflag toptrace_may_access()would address the locking concern.
OK ...
Quoted 2 lines
Duplicating the ptrace access checking logic seems prone to errors and inconsistencies.
That's true only if the ptrace logic and the safe-sidechannel logic are identical. I don't believe that is a safe assumption. It would sure be convenient. But I would hate to see a change made for either ptrace or safe_sidechannel that interfered with the correct behavior of the other.
Quoted 3 lines
I can't imagine policy writers
understanding what "safe sidechannel" means, much less deciding when to allow it.
I can't argue with that. But then, I have always had trouble with the SELinux policy scheme.
Re: [PATCH RFC v2 2/5] X86: Support LSM determination of side-channel vulnerability
In reply to Schaufler, CaseyQuoted 68 lines · Casey
Quoted 68 lines
-----Original Message-----
From: Jann Horn [mailto:[email protected]]
Sent: Friday, August 17, 2018 4:55 PM
To: Schaufler, Casey <[email protected]>
Cc: Kernel Hardening <[email protected]>; kernel list <[email protected]>; linux-security-module <linux-security- [email protected]>; [email protected]; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; [email protected]; Arjan van de Ven <[email protected]>
Subject: Re: [PATCH RFC v2 2/5] X86: Support LSM determination of side- channel vulnerabilityarch/x86/mm/tlb.c void switch_mm_irqs_off(struct mm_struct *prev,
Quoted 27 lines · Casey Schaufler
From: Casey Schaufler <[email protected]>
When switching between tasks it may be necessary to set an indirect branch prediction barrier if the tasks are potentially vulnerable to side-channel attacks. This adds a call to
security_task_safe_sidechannelso that security modules can weigh in on the decision.Signed-off-by Casey Schaufler <[email protected]>--- arch/x86/mm/tlb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)arch/x86/mm/tlb.c +1
-0@@ -7,6 +7,7 @@#include <linux/export.h> #include <linux/cpu.h> #include <linux/debugfs.h> +#include <linux/security.h> #include <asm/tlbflush.h> #include <asm/mmu_context.h> @@ -270,11 +271,14 @@ void switch_mm_irqs_off(struct mm_struct *prev,struct
mm_struct*next,Quoted 5 lines
arch/x86/mm/tlb.c +2
-0* threads. It will also not flush if we switch to idle * thread and back to the same process. It will flush if we * switch to a different non-dumpable process. +* If a security module thinks that the transition +* is unsafe do the flush. arch/x86/mm/tlb.c void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, · line 281
Quoted 10 lines
arch/x86/mm/tlb.c +5
-4*/ -if (tsk && tsk->mm && - tsk->mm->context.ctx_id != last_ctx_id && -get_dumpable (tsk->mm) !=SUID_DUMP_USER ) -indirect_branch_prediction_barrier (); +if (tsk && tsk->mm && tsk->mm->context.ctx_id != last_ctx_id) { +if (get_dumpable (tsk->mm) !=SUID_DUMP_USER || +security_task_safe_sidechannel (tsk) !=0 ) +indirect_branch_prediction_barrier (); + }When you posted v1 of this series, I asked:
| Does this enforce transitivity? What happens if we first switch from | an attacker task to a task without ->mm, and immediately afterwards | from the task without ->mm to a victim task? In that case, whether a | flush happens between the attacker task and the victim task depends on | whether the LSM thinks that the mm-less task should have access to the | victim task, right?
Quoted 6 lines
Quoted 1 line
Have you addressed that? I don't see it...
Nope. That's going to require maintaining state about all the tasks in the chain that might still have cache involvement.
A -> B -> C -> D
Really?
Quoted 1 line
From what I can tell, it'd be enough to:
- ensure that the LSM-based access checks behave approximately transitively (which I think they already do, mostly)
- keep a copy of the metadata of the last non-kernel task on the CPU
Quoted 5 lines
If B and C don't do anything cacheworthy D could conceivably attack A. The amount of state required to detect this case would be prohibitive. I think that if you're sufficiently concerned about this case you should just go ahead and set the barrier. I'm willing to learn something that says I'm wrong.
That means that an attacker who can e.g. get a CPU to first switch from an attacker task to a softirqd (e.g. for network packet processing or whatever), then switch from the softirqd to a root-owned victim task would be able to bypass the check, right? That doesn't sound like a very complicated attack...
I very much dislike the idea of adding a mitigation with a known bypass technique to the kernel.
RE: [PATCH RFC v2 2/5] X86: Support LSM determination of side-channel vulnerability
Quoted 84 lines
-----Original Message-----
From: Jann Horn [mailto:[email protected]]
Sent: Tuesday, August 21, 2018 3:20 AM
To: Schaufler, Casey <[email protected]>
Cc: Kernel Hardening <[email protected]>; kernel list <[email protected]>; linux-security-module <linux-security- [email protected]>; [email protected]; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; [email protected]; Arjan van de Ven <[email protected]>
Subject: Re: [PATCH RFC v2 2/5] X86: Support LSM determination of side- channel vulnerabilityQuoted 39 lines · Casey
Quoted 39 lines
-----Original Message-----
From: Jann Horn [mailto:[email protected]]
Sent: Friday, August 17, 2018 4:55 PM
To: Schaufler, Casey <[email protected]>
Cc: Kernel Hardening <[email protected]>; kernel list <[email protected]>; linux-security-module <linux-security- [email protected]>; [email protected]; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; [email protected]; Arjan van de Ven <[email protected]>
Subject: Re: [PATCH RFC v2 2/5] X86: Support LSM determination of side- channel vulnerabilityQuoted 24 lines · Casey Schaufler
From: Casey Schaufler <[email protected]>
When switching between tasks it may be necessary to set an indirect branch prediction barrier if the tasks are potentially vulnerable to side-channel attacks. This adds a call to
security_task_safe_sidechannelso that security modules can weigh in on the decision.Signed-off-by Casey Schaufler <[email protected]>--- arch/x86/mm/tlb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)arch/x86/mm/tlb.c +1
-0@@ -7,6 +7,7 @@#include <linux/export.h> #include <linux/cpu.h> #include <linux/debugfs.h> +#include <linux/security.h> Quoted 3 lines
Quoted 3 lines
arch/x86/mm/tlb.c void switch_mm_irqs_off(struct mm_struct
Quoted 3 lines
arch/x86/mm/tlb.c +0
-0#include <asm/tlbflush.h> #include <asm/mmu_context.h> @@ -270,11 +271,14 @@ void switch_mm_irqs_off(struct mm_struct*prev,
Quoted 12 lines
Quoted 12 lines
struct
mm_struct*next,Quoted 11 lines
arch/x86/mm/tlb.c +3
-4* threads. It will also not flush if we switch to idle * thread and back to the same process. It will flush if we * switch to a different non-dumpable process. +* If a security module thinks that the transition +* is unsafe do the flush. */ -if (tsk && tsk->mm && - tsk->mm->context.ctx_id != last_ctx_id && -get_dumpable (tsk->mm) !=SUID_DUMP_USER ) -indirect_branch_prediction_barrier (); +if (tsk && tsk->mm && tsk->mm->context.ctx_id != last_ctx_id){
Quoted 14 lines
Quoted 14 lines
arch/x86/mm/tlb.c void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, · line 281
Quoted 4 lines
arch/x86/mm/tlb.c +4
-0+if (get_dumpable (tsk->mm) !=SUID_DUMP_USER || +security_task_safe_sidechannel (tsk) !=0 ) +indirect_branch_prediction_barrier (); + }When you posted v1 of this series, I asked:
| Does this enforce transitivity? What happens if we first switch from | an attacker task to a task without ->mm, and immediately afterwards | from the task without ->mm to a victim task? In that case, whether a | flush happens between the attacker task and the victim task depends on | whether the LSM thinks that the mm-less task should have access to the | victim task, right?
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Have you addressed that? I don't see it...
Nope. That's going to require maintaining state about all the tasks in the chain that might still have cache involvement.
A -> B -> C -> DReally?
I am willing to be educated otherwise. My understanding of Modern Processor Technology will never be so deep that I won't listen to reason.
Quoted 5 lines
From what I can tell, it'd be enough to:
- ensure that the LSM-based access checks behave approximately transitively (which I think they already do, mostly)
Smack rules are explicitly and intentionally not transitive.
A reads B, B reads C does *not* imply A reads C.
Quoted 1 line
- keep a copy of the metadata of the last non-kernel task on the CPU
Do you have a suggestion of how one might do that? I'm willing to believe the information could be available, but I have yet to come up with a mechanism for getting it.
Quoted 7 lines
Quoted 6 lines
If B and C don't do anything cacheworthy D could conceivably attack A. The amount of state required to detect this case would be prohibitive. I think that if you're sufficiently concerned about this case you should just go ahead and set the barrier. I'm willing to learn something that says I'm wrong.
Quoted 5 lines
That means that an attacker who can e.g. get a CPU to first switch from an attacker task to a softirqd (e.g. for network packet processing or whatever), then switch from the softirqd to a root-owned victim task would be able to bypass the check, right? That doesn't sound like a very complicated attack...
Maybe my brain is still stuck in the 1980's, but that sounds pretty complicated to me! Of course, the fact that it's beyond where I would go doesn't mean it's implausible.
Quoted 3 lines
I very much dislike the idea of adding a mitigation with a known bypass technique to the kernel.
That's fair. I'll look more closely at getting previous_cred_this_cpu().
Thank!
Re: [PATCH RFC v2 2/5] X86: Support LSM determination of side-channel vulnerability
Quoted 99 lines · Casey
Quoted 85 lines
-----Original Message-----
From: Jann Horn [mailto:[email protected]]
Sent: Tuesday, August 21, 2018 3:20 AM
To: Schaufler, Casey <[email protected]>
Cc: Kernel Hardening <[email protected]>; kernel list <[email protected]>; linux-security-module <linux-security- [email protected]>; [email protected]; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; [email protected]; Arjan van de Ven <[email protected]>
Subject: Re: [PATCH RFC v2 2/5] X86: Support LSM determination of side- channel vulnerabilityQuoted 39 lines · Casey
Quoted 39 lines
-----Original Message-----
From: Jann Horn [mailto:[email protected]]
Sent: Friday, August 17, 2018 4:55 PM
To: Schaufler, Casey <[email protected]>
Cc: Kernel Hardening <[email protected]>; kernel list <[email protected]>; linux-security-module <linux-security- [email protected]>; [email protected]; Hansen, Dave <[email protected]>; Dock, Deneen T <[email protected]>; [email protected]; Arjan van de Ven <[email protected]>
Subject: Re: [PATCH RFC v2 2/5] X86: Support LSM determination of side- channel vulnerabilityQuoted 24 lines · Casey Schaufler
From: Casey Schaufler <[email protected]>
When switching between tasks it may be necessary to set an indirect branch prediction barrier if the tasks are potentially vulnerable to side-channel attacks. This adds a call to
security_task_safe_sidechannelso that security modules can weigh in on the decision.Signed-off-by Casey Schaufler <[email protected]>--- arch/x86/mm/tlb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)arch/x86/mm/tlb.c +1
-0@@ -7,6 +7,7 @@#include <linux/export.h> #include <linux/cpu.h> #include <linux/debugfs.h> +#include <linux/security.h> Quoted 3 lines
Quoted 3 lines
arch/x86/mm/tlb.c void switch_mm_irqs_off(struct mm_struct
Quoted 3 lines
arch/x86/mm/tlb.c +0
-0#include <asm/tlbflush.h> #include <asm/mmu_context.h> @@ -270,11 +271,14 @@ void switch_mm_irqs_off(struct mm_struct*prev,
Quoted 12 lines
Quoted 12 lines
struct
mm_struct*next,Quoted 11 lines
arch/x86/mm/tlb.c +3
-4* threads. It will also not flush if we switch to idle * thread and back to the same process. It will flush if we * switch to a different non-dumpable process. +* If a security module thinks that the transition +* is unsafe do the flush. */ -if (tsk && tsk->mm && - tsk->mm->context.ctx_id != last_ctx_id && -get_dumpable (tsk->mm) !=SUID_DUMP_USER ) -indirect_branch_prediction_barrier (); +if (tsk && tsk->mm && tsk->mm->context.ctx_id != last_ctx_id){
Quoted 14 lines
Quoted 14 lines
arch/x86/mm/tlb.c void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, · line 281
Quoted 4 lines
arch/x86/mm/tlb.c +4
-0+if (get_dumpable (tsk->mm) !=SUID_DUMP_USER || +security_task_safe_sidechannel (tsk) !=0 ) +indirect_branch_prediction_barrier (); + }When you posted v1 of this series, I asked:
| Does this enforce transitivity? What happens if we first switch from | an attacker task to a task without ->mm, and immediately afterwards | from the task without ->mm to a victim task? In that case, whether a | flush happens between the attacker task and the victim task depends on | whether the LSM thinks that the mm-less task should have access to the | victim task, right?Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Have you addressed that? I don't see it...
Nope. That's going to require maintaining state about all the tasks in the chain that might still have cache involvement.
A -> B -> C -> DReally?
I am willing to be educated otherwise. My understanding of Modern Processor Technology will never be so deep that I won't listen to reason.
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
From what I can tell, it'd be enough to:
- ensure that the LSM-based access checks behave approximately transitively (which I think they already do, mostly)
Smack rules are explicitly and intentionally not transitive.
A reads B, B reads C does *not* imply A reads C.
Ah. :(
Well, at least for UID-based checks, capability comparisons and namespace comparisons, the relationship should be transitive, right?
Quoted 5 lines
Quoted 1 line
- keep a copy of the metadata of the last non-kernel task on the CPU
Do you have a suggestion of how one might do that? I'm willing to believe the information could be available, but I have yet to come up with a mechanism for getting it.
The obvious solution would be to take a refcounted reference on the old task's objective creds, but you probably want to avoid the resulting cache line bouncing...
For safe_by_uid(), I think you could get away with just stashing the last UID in a percpu variable, instead of keeping the full creds struct around. That should be fairly cheap?
Namespace comparisons, and whatever SELinux/Smack/AppArmor do internally, are probably more complicated, since you'd potentially have to deal with changes of internal IDs and such if the policy gets reloaded in the wrong moment.
For namespaces, perhaps you could give each namespace a unique 128-bit ID and then save and compare those, just like UIDs.
For LSMs whose internal IDs might change after a policy reload, things would probably be more messy. Perhaps you could save, e.g. for SELinux, something like an (sid,policy_generation_counter) pair? I don't know all that much about the internals of classic LSMs.
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
If B and C don't do anything cacheworthy D could conceivably attack A. The amount of state required to detect this case would be prohibitive. I think that if you're sufficiently concerned about this case you should just go ahead and set the barrier. I'm willing to learn something that says I'm wrong.
That means that an attacker who can e.g. get a CPU to first switch from an attacker task to a softirqd (e.g. for network packet processing or whatever), then switch from the softirqd to a root-owned victim task would be able to bypass the check, right? That doesn't sound like a very complicated attack...
Quoted 3 lines
Maybe my brain is still stuck in the 1980's, but that sounds pretty complicated to me! Of course, the fact that it's beyond where I would go doesn't mean it's implausible.
It seems to me like this could happen relatively easily if you have one attacker task that keeps calling sched_yield() together with a victim task on a logical core that's also running a softirqd? Attacker voluntarily preempts, softirqd runs for packet processing, softirqd ends processing, kernel schedules victim? I'm not sure how high the injection success rate would be with that though.
Quoted 7 lines
Quoted 2 lines
I very much dislike the idea of adding a mitigation with a known bypass technique to the kernel.
That's fair. I'll look more closely at getting
previous_cred_this_cpu().Thank!