Skip to contentSkip to conversation

arm64: treat PF_IO_WORKER like PF_KTHREAD for mitigations

PATCH In review Jens Axboe 2 participants 2 messages Mar 28, 2023 – Mar 29, 2023 arm64

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

PATCH v2 1/1 arm64: treat PF_IO_WORKER like PF_KTHREAD for mitigations

Like PF_KTHREAD, PF_IO_WORKER never exit to userspace. They exist entirely within the kernel, and hence don't need any task mitigations applied.

---

v2: include ssbs_thread_switch() too

arch/arm64/kernel/process.c +4 -2
index 71d59b5abede..9ce614b2177e 100644
@@ -445,9 +445,11 @@ static void ssbs_thread_switch(struct task_struct *next)
 {
 	/*
 	 * Nothing to do for kernel threads, but 'regs' may be junk
-	 * (e.g. idle task) so check the flags and bail early.
+	 * (e.g. idle task) so check the flags and bail early. Nothing to do
+	 * for IO worker threads either, as they never transition between
+	 * kernel and userspace.
 	 */
-	if (unlikely(next->flags & PF_KTHREAD))
+	if (unlikely(next->flags & (PF_KTHREAD | PF_IO_WORKER)))
 		return;
 
 	/*
arch/arm64/kernel/proton-pack.c +1 -1
index fca9cc6f5581..25a21c3d446c 100644
@@ -654,7 +654,7 @@ static void __update_pstate_ssbs(struct pt_regs *regs, bool state)
 void spectre_v4_enable_task_mitigation(struct task_struct *tsk)
 {
 	struct pt_regs *regs = task_pt_regs(tsk);
-	bool ssbs = false, kthread = tsk->flags & PF_KTHREAD;
+	bool ssbs = false, kthread = tsk->flags & (PF_KTHREAD | PF_IO_WORKER);
 
 	if (spectre_v4_mitigations_off())
 		ssbs = true;
Signature · 7 lines
Jens Axboe


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#1 lore raw
Quoted 9 lines · Jens Axboe

Like PF_KTHREAD, PF_IO_WORKER never exit to userspace. They exist entirely within the kernel, and hence don't need any task mitigations applied.

---

v2: include ssbs_thread_switch() too

As per the comments here -
https://lore.kernel.org/all/[email protected]/, I think we should update access_ok() as well.

Thanks.

Signature · 6 lines
Catalin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel