Re: [PATCH v7] kcov: fix data corruption and race conditions on PREEMPT_RT

From: Andrew Morton

Date: Sat Jul 25 2026 - 18:01:30 EST


On Thu, 16 Jul 2026 08:01:29 +0900 Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:

> syzbot is reporting KCOV state corruption on PREEMPT_RT kernels, for the
> temporary storage used for saving/restoring remote KCOV state is currently
> allocated as the per-CPU area.
>
> On PREEMPT_RT kernels, softirq handlers run as preemptible task threads
> (e.g., ksoftirqd). If a softirq context preempts a task running a remote
> KCOV session, it safely saves the task's state into the per-CPU area.
> However, if that softirq thread is subsequently preempted by a higher-
> priority softirq thread on the same CPU, the second softirq will overwrite
> the same per-CPU area, permanently destroying the original task's KCOV
> state.
>
> Fix this data corruption by moving the temporary storage from the per-CPU
> area to the per-thread area. Since each softirq thread now owns its own
> task context, nested softirq preemption no longer causes data overwrites.

All sounds rather unpleasant. Should we add cc:stable here?