lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 29 Jun 2023 20:14:49 +0200
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Frederic Weisbecker <frederic@...nel.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Anna-Maria Behnsen <anna-maria@...utronix.de>,
        John Stultz <jstultz@...gle.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...nel.org>,
        Stephen Boyd <sboyd@...nel.org>,
        Eric Biederman <ebiederm@...ssion.com>,
        Oleg Nesterov <oleg@...hat.com>
Subject: Re: [patch 09/45] posix-cpu-timers: Fix posix_cpu_timer_get()
 behaviour

On Tue, Jun 27 2023 at 00:46, Frederic Weisbecker wrote:> On Tue, Jun 06, 2023 at 04:37:33PM +0200, Thomas Gleixner wrote:
>> Aside of that posix_cpu_timer_set() pointlessly arms SIGEV_NONE timers
>> which are later disarmed when the initial expiry happens. That's bogus and
>> just keeping the process wide timer active for nothing.
>> 
>> Cure this by:
>> 
>>      1) Avoiding to arm SIGEV_NONE timers
>> 
>>      2) Forwarding interval timers in posix_cpu_timer_get()
>> 
>>      3) Taking SIGEV_NONE into account when a oneshot timer has expired
>
> This patch does too many things at once...

Let me try again to split it up. I failed before ...

>> -static void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *itp)
>> +static void __posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *itp, u64 now)
>>  {
>> -	clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock);
>> -	struct cpu_timer *ctmr = &timer->it.cpu;
>> -	u64 now, expires = cpu_timer_getexpires(ctmr);
>> -	struct task_struct *p;
>> -
>> -	rcu_read_lock();
>> -	p = cpu_timer_task_rcu(timer);
>> -	if (!p)
>> -		goto out;
>> +	bool sigev_none = timer->it_sigev_notify == SIGEV_NONE;
>> +	u64 expires;
>>  
>>  	/*
>> -	 * Easy part: convert the reload time.
>> +	 * Make sure that interval timers are moved forward for the
>> +	 * following cases:
>> +	 *  - SIGEV_NONE timers which are never armed
>> +	 *  - Timers which expired, but the signal has not yet been
>> +	 *    delivered
>>  	 */
>> -	itp->it_interval = ktime_to_timespec64(timer->it_interval);
>> -
>> -	if (!expires)
>> -		goto out;
>> +	expires = bump_cpu_timer(timer, now);
>
> What if the expiration has been reached but we arrived here before
> handle_posix_cpu_timers() had a chance? In that case the call to
> bump_cpu_timer() may forward the timer and artificially create an
> overrun / missed event.

Bah. This clearly misses some conditionals so that it actually handles
the cases described in the comment above it...

Thanks,

        tglx


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ