Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	Dominik Brodowski <linux@dominikbrodowski.net>,
	Sultan Alsawaf <sultan@kerneltoast.com>
Subject: Re: [PATCH 2/2] random: spread out jitter callback to different CPUs
Date: Thu, 6 Oct 2022 14:41:11 +0200	[thread overview]
Message-ID: <Yz7M5zJmzKSk/LYH@linutronix.de> (raw)
In-Reply-To: <Yz7JXEaTFWa1VLKJ@zx2c4.com>

On 2022-10-06 06:26:04 [-0600], Jason A. Donenfeld wrote:
> e) del_timer_sync() on line 5 is called, and its `base->running_timer !=
>    timer` check is false, because of step (c).

If `base->running_timer != timer` then the timer ('s callback) is not
currently active/ running. Therefore it can be removed from the timer
bucket (in case it is pending in the future).
If `base->running_timer == timer` then the timer ('s callback) is
currently active. del_timer_sync() will loop in cpu_relax() until the
callback finished. And then try again.

> f) `stack.timer` gets freed / goes out of scope.
> 
> g) The callback scheduled from step (b) runs, and we have a UaF.
> 
> That's, anyway, what I understand Sultan to have pointed out to me. In
> looking at this closely, though, to write this email, I noticed that
> add_timer_on() does set TIMER_MIGRATING, which lock_timer_base() spins
> on. So actually, maybe this scenario should be accounted for? Sultan, do
> you care to comment here?

During TIMER_MIGRATING the del_timer_sync() caller will spin until the
condition is over. So it can remove the timer from the right bucket and
check if it is active vs the right bucket.

> Jason

Sebastian

  reply	other threads:[~2022-10-06 12:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30 23:10 [PATCH 1/2] random: schedule jitter credit for next jiffy, not in two jiffies Jason A. Donenfeld
2022-09-30 23:10 ` [PATCH 2/2] random: spread out jitter callback to different CPUs Jason A. Donenfeld
2022-10-01  9:21   ` Jason A. Donenfeld
2022-10-05 17:26     ` Sebastian Andrzej Siewior
2022-10-05 21:08       ` Jason A. Donenfeld
2022-10-06  6:46         ` Sebastian Andrzej Siewior
2022-10-06 12:26           ` Jason A. Donenfeld
2022-10-06 12:41             ` Sebastian Andrzej Siewior [this message]
2022-10-06 16:39               ` Sultan Alsawaf
2022-10-07  7:29                 ` Sebastian Andrzej Siewior
2022-10-07 14:01             ` Jason A. Donenfeld
2022-10-07 14:55               ` Sebastian Andrzej Siewior
2022-10-07 15:32                 ` Jason A. Donenfeld
2022-11-29 16:08                   ` [PATCH v2] " Jason A. Donenfeld
2022-11-29 18:27                     ` [PATCH v3] " Jason A. Donenfeld
     [not found]                       ` <20221130014514.6494-1-hdanton@sina.com>
2022-11-30  1:49                         ` Jason A. Donenfeld
2022-11-30 18:48                       ` [PATCH v4] " Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yz7M5zJmzKSk/LYH@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=Jason@zx2c4.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=sultan@kerneltoast.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox