]> Git Repo - linux.git/commitdiff
posix-cpu-timers: Prevent spuriously armed 0-value itimer
authorFrederic Weisbecker <[email protected]>
Mon, 13 Sep 2021 14:53:32 +0000 (16:53 +0200)
committerThomas Gleixner <[email protected]>
Thu, 23 Sep 2021 09:53:51 +0000 (11:53 +0200)
Resetting/stopping an itimer eventually leads to it being reprogrammed
with an actual "0" value. As a result the itimer expires on the next
tick, triggering an unexpected signal.

To fix this, make sure that
struct signal_struct::it[CPUCLOCK_PROF/VIRT]::expires is set to 0 when
setitimer() passes a 0 it_value, indicating that the timer must stop.

Fixes: 406dd42bd1ba ("posix-cpu-timers: Force next expiration recalc after itimer reset")
Reported-by: Victor Stinner <[email protected]>
Reported-by: Chris Hixon <[email protected]>
Signed-off-by: Frederic Weisbecker <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
kernel/time/posix-cpu-timers.c

index ee736861b18f7e5a30df8d259ce4bd1f9b6d50e7..643d412ac6235eae110975f60247c97a8f278225 100644 (file)
@@ -1404,7 +1404,8 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clkid,
                        }
                }
 
-               *newval += now;
+               if (*newval)
+                       *newval += now;
        }
 
        /*
This page took 0.05128 seconds and 4 git commands to generate.