mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@kernel.org>
To: Yun Zhou <yun.zhou@windriver.com>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Vasileios Almpanis <vasilisalmpanis@gmail.com>
Subject: Re: [PATCH] i2c: prevent new device registration during adapter removal
Date: Fri, 31 Jul 2026 23:48:31 +0200	[thread overview]
Message-ID: <am0WA-ar1NsjNXYw@zenone.zhora.eu> (raw)
In-Reply-To: <20260730071831.352749-1-yun.zhou@windriver.com>

Hi Yun,

uuhh... woow, check this patch here[*]. Your AI agents look to be
in sync.

I read Vasileios patch first and then yours.

On Thu, Jul 30, 2026 at 03:18:31PM +0800, Yun Zhou wrote:
> Remove new_device and delete_device sysfs attributes early in
> i2c_del_adapter() to prevent concurrent client registrations during
> adapter teardown. Without this, a racing new_device_store() can
> register a client that will never be cleaned up, causing
> wait_for_completion() to block indefinitely.

You can also mention the UAF that Vasileios AI found.

> Fixes: 99cd8e25875a ("i2c: Add a sysfs interface to instantiate devices")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yun Zhou <yun.zhou@windriver.com>
> ---
>  drivers/i2c/i2c-core-base.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index 3ec04787a737..0f207520d6f9 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -1817,6 +1817,14 @@ void i2c_del_adapter(struct i2c_adapter *adap)
>  
>  	i2c_acpi_remove_space_handler(adap);
>  
> +	/*
> +	 * Remove new_device/delete_device sysfs attrs early to prevent
> +	 * new client registrations via userspace while we're tearing down.
> +	 * kernfs will wait for any in-flight writes to complete.
> +	 */
> +	device_remove_file(&adap->dev, &dev_attr_new_device);
> +	device_remove_file(&adap->dev, &dev_attr_delete_device);

I prefer this fix, though, but I don't think we need to manually
remove delete_device.

Andi

[*] https://patchwork.ozlabs.org/project/linux-i2c/patch/20260730162540.291570-1-vasilisalmpanis@gmail.com/

> +
>  	i2c_deregister_clients(adap);
>  
>  	/* device name is gone after device_unregister */
> -- 
> 2.43.0
> 

      reply	other threads:[~2026-07-31 21:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30  7:18 Yun Zhou
2026-07-31 21:48 ` Andi Shyti [this message]

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=am0WA-ar1NsjNXYw@zenone.zhora.eu \
    --to=andi.shyti@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vasilisalmpanis@gmail.com \
    --cc=yun.zhou@windriver.com \
    /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

all inboxes | Powered by JetHome®