Re: [PATCH] i2c: fix use-after-free in debugfs directory during adapter removal

Hillf Danton <[email protected]> Sat, 1 Aug 2026 11:49:38 +0800
Newsgroups org.kernel.vger.linux-i2c,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Fri, 31 Jul 2026 23:55:47 +0200 Andi Shyti wrote:
> Hi Yun,
> 
> On Wed, Jul 29, 2026 at 04:58:53PM +0800, Yun Zhou wrote:
> > Move debugfs_remove_recursive() after device_unregister() in
> > i2c_del_adapter() to fix a race condition where a new i2c device probe
> > can access the adapter's already-freed debugfs dentry.
> > 
> > The race occurs when:
> > 1. i2c_del_adapter() calls debugfs_remove_recursive(adap->debugfs),
> >    freeing the debugfs dentry.
> > 2. Before device_unregister() completes, another thread writes to the
> >    sysfs 'new_device' attribute, triggering i2c_device_probe().
> > 3. i2c_device_probe() calls debugfs_create_dir() with the stale
> >    adapter->debugfs pointer, causing a GPF in start_dirop() when
> >    trying to lock the freed inode.
> > 
> > Reported-by: [email protected]
> > Closes: https://syzkaller.appspot.com/bug?extid=1e3d934ee3cff1ac188b
> > Fixes: 73febd775bdb ("i2c: create debugfs entry per adapter")
> > Cc: [email protected]
> > Signed-off-by: Yun Zhou <[email protected]>
> 
> This is the third patch of this kind I've reviewed, starting from
> the latest. I'm sorry, but I don't need AI to send me patches; I
> can do that myself. I don't need intermediaries.
> 
> If your goal is to be replaced by AI, you're doing a pretty good
> job.
> 
> I'm NAKing this patch on principle. Read your second patch to
> understand why; read your own patches and understand them before
> sending.
> 
Given no version info in the subject line, can you show links to the
first and second patches to double check AI.

Hillf

> Andi