arm64: treat PF_IO_WORKER like PF_KTHREAD for mitigations
PATCH 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.
---
arch/arm64/kernel/proton-pack.c +1 -1
@@ -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
Will Deacon
maintainerQuoted 13 lines · Jens Axboe
Like
PF_KTHREAD,PF_IO_WORKERnever exit to userspace. They exist entirely within the kernel, and hence don't need any task mitigations applied.Signed-off-by Jens Axboe <[email protected]>---
arch/arm64/kernel/proton-pack.c +0
-0
arch/arm64/kernel/proton-pack.c static void __update_pstate_ssbs(struct pt_regs *regs, bool state) · line 657
Quoted 5 lines
arch/arm64/kernel/proton-pack.c +1
-1@@ -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 );
Hmm, the other two uses of PF_KTHREAD in arch/arm64 also look pretty suspect in light of this proposal. Should we also update ssbs_thread_switch() and access_ok()? If not, then a comment would be handy to say why PF_KTHREAD is sufficient there.
Will
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 9 lines · Will Deacon
Quoted 8 lines · Jens Axboe
Like
PF_KTHREAD,PF_IO_WORKERnever exit to userspace. They exist entirely within the kernel, and hence don't need any task mitigations applied.Signed-off-by Jens Axboe <[email protected]>---
Quoted 15 lines
arch/arm64/kernel/proton-pack.c static void __update_pstate_ssbs(struct pt_regs *regs, bool state) · line 657
Quoted 10 lines
arch/arm64/kernel/proton-pack.c +1
-1@@ -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 );Hmm, the other two uses of
PF_KTHREADinarch/arm64also look pretty suspect in light of this proposal. Should we also updatessbs_thread_switch()andaccess_ok()? If not, then a comment would be handy to say whyPF_KTHREADis sufficient there.
The uaccess one looks like, PF_IO_WORKER threads are just normal userspace threads. The only difference is that they never exit to userspace, they remain in the kernel. But everything else is just like a thread.
But yes, the ssbs_thread_switch() should have this check too. I'll send out an updated patch.
Signature · 8 lines
Jens Axboe _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Catalin Marinas
maintainerQuoted 26 lines · Jens Axboe
Quoted 9 lines · Will Deacon
Quoted 8 lines · Jens Axboe
Like
PF_KTHREAD,PF_IO_WORKERnever exit to userspace. They exist entirely within the kernel, and hence don't need any task mitigations applied.Signed-off-by Jens Axboe <[email protected]>---
Quoted 15 lines
arch/arm64/kernel/proton-pack.c static void __update_pstate_ssbs(struct pt_regs *regs, bool state) · line 657
Quoted 10 lines
arch/arm64/kernel/proton-pack.c +1
-1@@ -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 );Hmm, the other two uses of
PF_KTHREADinarch/arm64also look pretty suspect in light of this proposal. Should we also updatessbs_thread_switch()andaccess_ok()? If not, then a comment would be handy to say whyPF_KTHREADis sufficient there.
Quoted 3 lines
The uaccess one looks like,
PF_IO_WORKERthreads are just normal userspace threads. The only difference is that they never exit to userspace, they remain in the kernel. But everything else is just like a thread.
IIUC these threads are cloned from a user thread and inherit the TIF flags. If the user already opted in to the tagged addr ABI (usually early by libc), TIF_TAGGED_ADDR would be set for all threads and inherited by io_worker threads so we get away with this. But it doesn't hurt to extend the access_ok check to PF_IO_WORKER just in case the user plays with the late enabling of TIF_TAGGED_ADDR.
Signature · 6 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Will Deacon
maintainerHey Jens,
Quoted 26 lines · Jens Axboe
Quoted 9 lines · Will Deacon
Quoted 8 lines · Jens Axboe
Like
PF_KTHREAD,PF_IO_WORKERnever exit to userspace. They exist entirely within the kernel, and hence don't need any task mitigations applied.Signed-off-by Jens Axboe <[email protected]>---
Quoted 15 lines
arch/arm64/kernel/proton-pack.c static void __update_pstate_ssbs(struct pt_regs *regs, bool state) · line 657
Quoted 10 lines
arch/arm64/kernel/proton-pack.c +1
-1@@ -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 );Hmm, the other two uses of
PF_KTHREADinarch/arm64also look pretty suspect in light of this proposal. Should we also updatessbs_thread_switch()andaccess_ok()? If not, then a comment would be handy to say whyPF_KTHREADis sufficient there.
Quoted 6 lines
The uaccess one looks like,
PF_IO_WORKERthreads are just normal userspace threads. The only difference is that they never exit to userspace, they remain in the kernel. But everything else is just like a thread.But yes, the
ssbs_thread_switch()should have this check too. I'll send out an updated patch.
I think this one slipped through the cracks, as I don't see any usage of PF_IO_WORKER in arch/arm64/. Do you plan to update the patch?
Cheers,
Will
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 33 lines · Will Deacon
Hey Jens,
Quoted 30 lines · Jens Axboe
Quoted 9 lines · Will Deacon
Quoted 8 lines · Jens Axboe
Like
PF_KTHREAD,PF_IO_WORKERnever exit to userspace. They exist entirely within the kernel, and hence don't need any task mitigations applied.Signed-off-by Jens Axboe <[email protected]>---
Quoted 15 lines
arch/arm64/kernel/proton-pack.c static void __update_pstate_ssbs(struct pt_regs *regs, bool state) · line 657
Quoted 10 lines
arch/arm64/kernel/proton-pack.c +1
-1@@ -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 );Hmm, the other two uses of
PF_KTHREADinarch/arm64also look pretty suspect in light of this proposal. Should we also updatessbs_thread_switch()andaccess_ok()? If not, then a comment would be handy to say whyPF_KTHREADis sufficient there.The uaccess one looks like,
PF_IO_WORKERthreads are just normal userspace threads. The only difference is that they never exit to userspace, they remain in the kernel. But everything else is just like a thread.
Quoted 6 lines
Quoted 2 lines
But yes, the
ssbs_thread_switch()should have this check too. I'll send out an updated patch.I think this one slipped through the cracks, as I don't see any usage of
PF_IO_WORKERinarch/arm64/. Do you plan to update the patch?
Oops, yes looks like it did. Should look something like this, added a comment as well. I'll send it out properly.
arch/arm64/kernel/process.c +4 -2
@@ -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
@@ -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