Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+7 -3
+7 -3
kernel/unwind/deferred.c
··· 231 231 int unwind_deferred_request(struct unwind_work *work, u64 *cookie) 232 232 { 233 233 struct unwind_task_info *info = &current->unwind_info; 234 + int twa_mode = TWA_RESUME; 234 235 unsigned long old, bits; 235 236 unsigned long bit; 236 237 int ret; ··· 247 246 * Trigger a warning to make it obvious that an architecture 248 247 * is using this in NMI when it should not be. 249 248 */ 250 - if (WARN_ON_ONCE(!CAN_USE_IN_NMI && in_nmi())) 251 - return -EINVAL; 249 + if (in_nmi()) { 250 + if (WARN_ON_ONCE(!CAN_USE_IN_NMI)) 251 + return -EINVAL; 252 + twa_mode = TWA_NMI_CURRENT; 253 + } 252 254 253 255 /* Do not allow cancelled works to request again */ 254 256 bit = READ_ONCE(work->bit); ··· 289 285 } 290 286 291 287 /* The work has been claimed, now schedule it. */ 292 - ret = task_work_add(current, &info->work, TWA_RESUME); 288 + ret = task_work_add(current, &info->work, twa_mode); 293 289 294 290 if (WARN_ON_ONCE(ret)) 295 291 WRITE_ONCE(info->unwind_mask, 0);