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.

posix-timers: Drop signal if timer has been deleted or reprogrammed

No point in delivering a signal from the past. POSIX does not specify the
behaviour here:

- "The effect of disarming or resetting a timer with pending expiration
notifications is unspecified."

- "The disposition of pending signals for the deleted timer is unspecified."

In both cases it is reasonable to expect that pending signals are
discarded. Especially in the reprogramming case it does not make sense to
account for previous overruns or to deliver a signal for a timer which has
been disarmed.

Drop the signal as that is conistent and understandable behaviour.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/all/20241001083835.553646280@linutronix.de

+5 -4
+5 -4
kernel/time/posix-timers.c
··· 250 250 } 251 251 252 252 /* 253 - * This function is called from the signal delivery code if 254 - * info::si_sys_private is not zero, which indicates that the timer has to 255 - * be rearmed. Restart the timer and update info::si_overrun. 253 + * This function is called from the signal delivery code. It decides 254 + * whether the signal should be dropped and rearms interval timers. 256 255 */ 257 256 bool posixtimer_deliver_signal(struct kernel_siginfo *info) 258 257 { 259 258 struct k_itimer *timr; 260 259 unsigned long flags; 260 + bool ret = false; 261 261 262 262 /* 263 263 * Release siglock to ensure proper locking order versus ··· 279 279 280 280 info->si_overrun = timer_overrun_to_int(timr, info->si_overrun); 281 281 } 282 + ret = true; 282 283 283 284 unlock_timer(timr, flags); 284 285 out: ··· 287 286 288 287 /* Don't expose the si_sys_private value to userspace */ 289 288 info->si_sys_private = 0; 290 - return true; 289 + return ret; 291 290 } 292 291 293 292 int posix_timer_queue_signal(struct k_itimer *timr)