Skip to content

Commit 647da5f

Browse files
committed
posix-timers: Move sequence logic into struct k_itimer
The posix timer signal handling uses siginfo::si_sys_private for handling the sequence counter check. That indirection is not longer required and the sequence count value at signal queueing time can be stored in struct k_itimer itself. This removes the requirement of treating siginfo::si_sys_private special as it's now always zero as the kernel does not touch it anymore. Suggested-by: Eric W. Biederman <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Frederic Weisbecker <[email protected]> Acked-by: "Eric W. Biederman" <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent c2a4796 commit 647da5f

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

include/linux/posix-timers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ static inline void posix_cputimers_init_work(void) { }
162162
* @it_overrun: The overrun counter for pending signals
163163
* @it_overrun_last: The overrun at the time of the last delivered signal
164164
* @it_signal_seq: Sequence count to control signal delivery
165+
* @it_sigqueue_seq: The sequence count at the point where the signal was queued
165166
* @it_sigev_notify: The notify word of sigevent struct for signal delivery
166167
* @it_interval: The interval for periodic timers
167168
* @it_signal: Pointer to the creators signal struct
@@ -184,6 +185,7 @@ struct k_itimer {
184185
s64 it_overrun;
185186
s64 it_overrun_last;
186187
unsigned int it_signal_seq;
188+
unsigned int it_sigqueue_seq;
187189
int it_sigev_notify;
188190
enum pid_type it_pid_type;
189191
ktime_t it_interval;

include/uapi/asm-generic/siginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ union __sifields {
4646
__kernel_timer_t _tid; /* timer id */
4747
int _overrun; /* overrun count */
4848
sigval_t _sigval; /* same as below */
49-
int _sys_private; /* not to be passed to user */
49+
int _sys_private; /* Not used by the kernel. Historic leftover. Always 0. */
5050
} _timer;
5151

5252
/* POSIX.1b signals */

kernel/signal.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,12 +1976,10 @@ int posixtimer_send_sigqueue(struct k_itimer *tmr)
19761976
return -1;
19771977

19781978
/*
1979-
* Update @q::info::si_sys_private for posix timer signals with
1980-
* sighand locked to prevent a race against dequeue_signal() which
1981-
* decides based on si_sys_private whether to invoke
1982-
* posixtimer_rearm() or not.
1979+
* Update @tmr::sigqueue_seq for posix timer signals with sighand
1980+
* locked to prevent a race against dequeue_signal().
19831981
*/
1984-
q->info.si_sys_private = tmr->it_signal_seq;
1982+
tmr->it_sigqueue_seq = tmr->it_signal_seq;
19851983

19861984
ret = 1; /* the signal is ignored */
19871985
if (!prepare_signal(sig, t, false)) {

kernel/time/posix-timers.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static bool __posixtimer_deliver_signal(struct kernel_siginfo *info, struct k_it
259259
* since the signal was queued. In either case, don't rearm and
260260
* drop the signal.
261261
*/
262-
if (timr->it_signal_seq != info->si_sys_private || WARN_ON_ONCE(!timr->it_signal))
262+
if (timr->it_signal_seq != timr->it_sigqueue_seq || WARN_ON_ONCE(!timr->it_signal))
263263
return false;
264264

265265
if (!timr->it_interval || WARN_ON_ONCE(timr->it_status != POSIX_TIMER_REQUEUE_PENDING))
@@ -297,9 +297,6 @@ bool posixtimer_deliver_signal(struct kernel_siginfo *info, struct sigqueue *tim
297297
posixtimer_putref(timr);
298298

299299
spin_lock(&current->sighand->siglock);
300-
301-
/* Don't expose the si_sys_private value to userspace */
302-
info->si_sys_private = 0;
303300
return ret;
304301
}
305302

0 commit comments

Comments
 (0)