| Subject | Re: [patch 20/24] x86/speculation: Split out TIF update | From | Tim Chen <> | Date | Wed, 21 Nov 2018 18:13:56 -0800 |
| |
On Wed, Nov 21, 2018 at 09:14:50PM +0100, Thomas Gleixner wrote: > +static void task_update_spec_tif(struct task_struct *tsk, int tifbit, bool on) > { > bool update; > > + if (on) > + update = !test_and_set_tsk_thread_flag(tsk, tifbit); > + else > + update = test_and_clear_tsk_thread_flag(tsk, tifbit); > + > + /* > + * If being set on non-current task, delay setting the CPU > + * mitigation until it is scheduled next. > + */ > + if (tsk == current && update) > + speculation_ctrl_update_current();
I think all the call paths from prctl and seccomp coming here has tsk == current.
But if task_update_spec_tif gets used in the future where tsk is running on a remote CPU, this could lead to the MSR getting out of sync with the running task's TIF flag. This will break either performance or security.
Should we add a WARN_ON(smp_processor_id() != task_cpu(tsk));
in case the assumption breaks that task is on local CPU, or document this assumption?
Thanks.
Tim
|