From: Frederic Weisbecker <frederic@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: linux-tip-commits@vger.kernel.org, Wongi Lee <qw3rtyp0@gmail.com>,
Jungwoo Lee <jwlee2217@gmail.com>,
Thomas Gleixner <tglx@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
stable@vger.kernel.org, x86@kernel.org
Subject: Re: [tip: timers/urgent] posix-cpu-timers: Prevent UAF caused by non-leader exec() race
Date: Wed, 8 Jul 2026 18:06:50 +0200 [thread overview]
Message-ID: <ak51mpHPzsQrGFmv@localhost.localdomain> (raw)
In-Reply-To: <178324479651.744054.11944477307374142373.tip-bot2@tip-bot2>
Le Sun, Jul 05, 2026 at 09:46:36AM -0000, tip-bot2 for Thomas Gleixner a écrit :
> The following commit has been merged into the timers/urgent branch of tip:
>
> Commit-ID: 920f893f735e92ba3a1cd9256899a186b161928d
> Gitweb: https://git.kernel.org/tip/920f893f735e92ba3a1cd9256899a186b161928d
> Author: Thomas Gleixner <tglx@kernel.org>
> AuthorDate: Fri, 03 Jul 2026 12:02:38 +02:00
> Committer: Thomas Gleixner <tglx@kernel.org>
> CommitterDate: Sun, 05 Jul 2026 11:44:06 +02:00
>
> posix-cpu-timers: Prevent UAF caused by non-leader exec() race
>
> Wongi and Jungwoo decoded and reported a non-leader exec() related race
> which can result in an UAF:
>
> sys_timer_delete() exec()
> posix_cpu_timer_del()
> // Observes old leader
> p = pid_task(pid, pid_type); de_thread()
> switch_leader();
> release_task(old_leader)
> __exit_signal(old_leader)
> sighand = lock(old_leader, sighand);
> posix_cpu_timers*_exit();
> sighand = lock_task_sighand(p) unhash_task(old_leader);
> sh = lock(p, sighand) old_leader->sighand = NULL;
> unlock(sighand);
> (p->sighand == NULL)
> unlock(sh)
> return NULL;
>
> // Returns without action
> if(!sighand)
> return 0;
> free_posix_timer();
>
> This is "harmless" unless the deleted timer was armed and enqueued in
> p->signal because on exec() a TGID targeted timer is inherited.
>
> As sys_timer_delete() freed the underlying posix timer object
> run_posix_cpu_timers() or any timerqueue related add/delete operations on
> other timers will access the freed object's timerqueue node, which results
> in an UAF.
>
> There is a similar problem vs. posix_cpu_timer_set(). For regular posix
> timers it just transiently returns -ESRCH to user space, but for the use
> case in do_cpu_nanosleep() it's the same UAF just that the k_itimer is
> allocated on the stack.
do_cpu_nanosleep() only targets current and since it's on the stack, no
other task can access it. And the current task can't be exiting/exec'ing
while calling posix_cpu_timer_set() on that stack timer.
> + * That's problematic for several functions:
> + *
> + * - posix_cpu_timer_del(): If the timer is still enqueued on the task the
> + * underlying k_itimer will be freed which results in a UAF in
> + * run_posix_cpu_timers() or on timerqueue related add/delete operations.
> + * If the timer is not enqueued, the failure is harmless
> + *
> + * - posix_cpu_timer_set(): Independent of the enqueued state that results in a
> + * transient failure which is user space visible (-ESRCH) for regular posix
> + * timers. But for the use case in do_cpu_nanosleep() it's the same UAF
> + * problem just that the timer is allocated on the stack.
Ditto.
Other than that:
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
--
Frederic Weisbecker
SUSE Labs
next prev parent reply other threads:[~2026-07-08 16:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-05 9:46 [tip: timers/urgent] posix-cpu-timers: Prevent UAF caused by non-leader exec() race tip-bot2 for Thomas Gleixner
2026-07-08 16:06 ` Frederic Weisbecker [this message]
2026-07-08 16:43 ` Oleg Nesterov
2026-07-08 18:04 ` Thomas Gleixner
2026-07-08 18:35 ` Oleg Nesterov
2026-07-08 20:27 ` Frederic Weisbecker
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=ak51mpHPzsQrGFmv@localhost.localdomain \
--to=frederic@kernel.org \
--cc=jwlee2217@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=qw3rtyp0@gmail.com \
--cc=stable@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/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