[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4a505533-b725-4e3f-94db-3d261937ea25@kzalloc.com>
Date: Sun, 3 Aug 2025 07:01:40 +0900
From: Yunseong Kim <ysk@...lloc.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Dmitry Vyukov <dvyukov@...gle.com>,
Andrey Konovalov <andreyknvl@...il.com>, Byungchul Park <byungchul@...com>,
max.byungchul.park@...il.com, "ppbuk5246 @ gmail . com"
<ppbuk5246@...il.com>, linux-kernel@...r.kernel.org,
Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
Alan Stern <stern@...land.harvard.edu>, Thomas Gleixner
<tglx@...utronix.de>, Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
stable@...r.kernel.org, kasan-dev@...glegroups.com,
syzkaller@...glegroups.com, linux-usb@...r.kernel.org,
linux-rt-devel@...ts.linux.dev
Subject: Re: [PATCH v2] kcov, usb: Fix invalid context sleep in softirq path
on PREEMPT_RT
Hi Greg,
On 8/3/25 6:30 오전, Greg Kroah-Hartman wrote:
> On Sat, Aug 02, 2025 at 02:26:49PM +0000, Yunseong Kim wrote:
>> The KCOV subsystem currently utilizes standard spinlock_t and local_lock_t
>> for synchronization. In PREEMPT_RT configurations, these locks can be
>> implemented via rtmutexes and may therefore sleep. This behavior is
>> problematic as kcov locks are sometimes used in atomic contexts or protect
>> data accessed during critical instrumentation paths where sleeping is not
>> permissible.
>>
>> Address these issues to make kcov PREEMPT_RT friendly:
>>
>> 1. Convert kcov->lock and kcov_remote_lock from spinlock_t to
>> raw_spinlock_t. This ensures they remain true, non-sleeping
>> spinlocks even on PREEMPT_RT kernels.
>>
>> 2. Refactor the KCOV_REMOTE_ENABLE path to move memory allocations
>> out of the critical section. All necessary struct kcov_remote
>> structures are now pre-allocated individually in kcov_ioctl()
>> using GFP_KERNEL (allowing sleep) before acquiring the raw
>> spinlocks.
>>
>> 3. Modify the ioctl handling logic to utilize these pre-allocated
>> structures within the critical section. kcov_remote_add() is
>> modified to accept a pre-allocated structure instead of allocating
>> one internally.
>>
>> 4. Remove the local_lock_t protection for kcov_percpu_data in
>> kcov_remote_start/stop(). Since local_lock_t can also sleep under
>> RT, and the required protection is against local interrupts when
>> accessing per-CPU data, it is replaced with explicit
>> local_irq_save/restore().
>
> why isn't this 4 different patches?
Thank you for your feedback on the patch. I’ll split it into four separate
patches for v3 to improve clarity.
Best regards,
Yunseong Kim
Powered by blists - more mailing lists