Skip to content

[ciqlts9_6] exec: Cleanup POSIX timers right after de_thread() - #1689

Merged
PlaidCat merged 1 commit into
ciqlts9_6from
{maple}_ciqlts9_6
Oct 14, 2026
Merged

PlaidCat merged 1 commit into
ciqlts9_6from
{maple}_ciqlts9_6

Conversation

@ciq-kernel-automation

Copy link
Copy Markdown

Summary

This PR has been automatically created after successful completion of all CI stages.

Commit Message(s)

exec: Cleanup POSIX timers right after de_thread()

jira VULN-219518
cve CVE-2026-98260
commit-author Hyunwoo Kim <imv4bel@gmail.com>
commit acb03d3881818581052924a9bbbe92b8741ed448
commit-source-sha 75aa08b93c65766040f9ca99f41ac85ad22596b6
commit-source linux-6.18.y
upstream-diff |
    Context due to missing unrelated change:
    af7bb0d2ca4 ("exec: fix the racy usage of fs_struct->in_exec")

Test Results

✅ Build Stage

Architecture Build Time Total Time
x86_64 25m 11s 26m 14s
aarch64 18m 47s 19m 28s

✅ Boot Verification

✅ Kernel Selftests

Architecture Passed Failed Compared Against Status
x86_64 206 43 ciqlts9_6 ✅ No regressions
aarch64 153 46 ciqlts9_6 ✅ No regressions

✅ LTP Results

Architecture Passed Failed Compared Against Status
x86_64 1453 82 ciqlts9_6 ✅ No regressions
aarch64 1426 83 ciqlts9_6 ✅ No regressions

🤖 This PR was automatically generated by GitHub Actions
Run ID: 38457288999

jira VULN-219518
cve CVE-2026-98260
commit-author Hyunwoo Kim <imv4bel@gmail.com>
commit acb03d3
commit-source-sha 75aa08b
commit-source linux-6.18.y
upstream-diff |
    Context due to missing unrelated change:
    af7bb0d ("exec: fix the racy usage of fs_struct->in_exec")

commit acb03d3 upstream.

A per-thread CPU timer holds a reference to the PID of the thread it is
attached to and, while it is armed, its node is queued in that thread's
posix_cputimers. The task is looked up by that PID.

When a non-leader thread exec()s, de_thread() changes which task owns
that PID. pid_task(timer->it.cpu.pid, PIDTYPE_PID) then returns NULL,
but the node is still queued on tsk, which is alive. timer_lock_sighand()
takes a failed lookup to mean that the node is already dequeued, so it
has nothing to undo.

begin_new_exec() calls posix_cpu_timers_exit(me) right after
exec_task_namespaces() and that removes the leftover node, so the state
normally stays invisible. But bprm->point_of_no_return is set before
de_thread(), so if unshare_files(), set_mm_exe_file(), exec_mmap() or
exec_task_namespaces() fails, the task dies before it gets there.
exit_itimers() then frees the k_itimer while its node is still queued,
and reaping tsk later erases that freed node from the rbtree.

In short:

      the non-leader thread B           the parent

  timer_create(CLOCK_THREAD_CPUTIME_ID)
  timer_settime()
    arm_timer()            // the node is queued on B
  execve()
    de_thread(B)
      exchange_tids(B, leader)  // B's PID now belongs to the leader
      release_task(leader)
        __exit_signal(leader)
          posix_cpu_timers_exit(leader)  // cleans leader's queue, not B's
          __unhash_process(leader)  // that PID has no task anymore
    exec_mmap()
      mmap_read_lock_killable(old_mm)
                                kill(B, SIGKILL)
      // -EINTR
  get_signal()
    do_exit()
      exit_itimers()
        posix_timer_delete()
          posix_cpu_timer_del()
        posix_timer_unhash_and_free()  // freed while still queued
                                wait4()
                                  release_task(B)
                                    posix_cpu_timers_exit(B)
                                      cleanup_timerqueue()
                                        timerqueue_del()  // use-after-free

Move the POSIX timer cleanup right after de_thread() before any of the
later failure conditions brings the task into do_exit().

[ tglx: Move the cleanup right after de_thread() ]

Fixes: 55e8c8e ("posix-cpu-timers: Store a reference to a pid not a task")
	Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
	Signed-off-by: Thomas Gleixner <tglx@kernel.org>
	Tested-by: Kijo Park <red993688@gmail.com>
	Reviewed-by: Oleg Nesterov <oleg@redhat.com>
	Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
	Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/ao7Q8miiuLAPVnWv@v4bel
Link: https://patch.msgid.link/20260911090541.627712075@kernel.org
	Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 75aa08b)
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
@ciq-kernel-automation ciq-kernel-automation Bot added the created-by-kernelci Tag PRs that were automatically created when a user branch was pushed to the repo (kernelCI) label Oct 13, 2026
@github-actions

Copy link
Copy Markdown

🔍 Diffofdiffs: 1 backport differs from upstream

View the diffofdiffs report.

Open to anyone signed in to GitHub. Report expires 2027-01-11 23:40 UTC.

# Subject Backport Upstream
1 exec: Cleanup POSIX timers right after de_thread() b9e19ecd19ba acb03d388181

Checked PR revision b9e19ecd19ba against base 879dc8dcfef9.

@github-actions

Copy link
Copy Markdown

🤖 Validation Checks In Progress Workflow run: https://github.com/ctrliq/kernel-src-tree/actions/runs/38486388163

@github-actions

Copy link
Copy Markdown

✅ Validation checks completed successfully View full results: https://github.com/ctrliq/kernel-src-tree/actions/runs/38486388163

@kerneltoast kerneltoast left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@PlaidCat PlaidCat self-assigned this Oct 14, 2026
@PlaidCat
PlaidCat requested a review from a team October 14, 2026 13:12

@bmastbergen bmastbergen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥌

@PlaidCat
PlaidCat merged commit 1ea5d58 into ciqlts9_6 Oct 14, 2026
8 checks passed
@PlaidCat
PlaidCat deleted the {maple}_ciqlts9_6 branch October 14, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by-kernelci Tag PRs that were automatically created when a user branch was pushed to the repo (kernelCI)

Development

Successfully merging this pull request may close these issues.

3 participants