mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
unwind: Fix unwind_deferred_request() vs NMI
task_work_add(RWA_RESUME) isn't NMI-safe, use TWA_NMI_CURRENT when used from NMI context. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Link: https://patch.msgid.link/20250924080119.005422353@infradead.org
This commit is contained in:
@@ -231,6 +231,7 @@ void unwind_deferred_task_exit(struct task_struct *task)
|
|||||||
int unwind_deferred_request(struct unwind_work *work, u64 *cookie)
|
int unwind_deferred_request(struct unwind_work *work, u64 *cookie)
|
||||||
{
|
{
|
||||||
struct unwind_task_info *info = ¤t->unwind_info;
|
struct unwind_task_info *info = ¤t->unwind_info;
|
||||||
|
int twa_mode = TWA_RESUME;
|
||||||
unsigned long old, bits;
|
unsigned long old, bits;
|
||||||
unsigned long bit;
|
unsigned long bit;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -246,8 +247,11 @@ int unwind_deferred_request(struct unwind_work *work, u64 *cookie)
|
|||||||
* Trigger a warning to make it obvious that an architecture
|
* Trigger a warning to make it obvious that an architecture
|
||||||
* is using this in NMI when it should not be.
|
* is using this in NMI when it should not be.
|
||||||
*/
|
*/
|
||||||
if (WARN_ON_ONCE(!CAN_USE_IN_NMI && in_nmi()))
|
if (in_nmi()) {
|
||||||
return -EINVAL;
|
if (WARN_ON_ONCE(!CAN_USE_IN_NMI))
|
||||||
|
return -EINVAL;
|
||||||
|
twa_mode = TWA_NMI_CURRENT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Do not allow cancelled works to request again */
|
/* Do not allow cancelled works to request again */
|
||||||
bit = READ_ONCE(work->bit);
|
bit = READ_ONCE(work->bit);
|
||||||
@@ -285,7 +289,7 @@ int unwind_deferred_request(struct unwind_work *work, u64 *cookie)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The work has been claimed, now schedule it. */
|
/* The work has been claimed, now schedule it. */
|
||||||
ret = task_work_add(current, &info->work, TWA_RESUME);
|
ret = task_work_add(current, &info->work, twa_mode);
|
||||||
|
|
||||||
if (WARN_ON_ONCE(ret))
|
if (WARN_ON_ONCE(ret))
|
||||||
WRITE_ONCE(info->unwind_mask, 0);
|
WRITE_ONCE(info->unwind_mask, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user