[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dfcb0456-dd75-4b9f-9cc8-f0658cd9ce29@I-love.SAKURA.ne.jp>
Date: Sat, 13 Jul 2024 07:18:41 +0900
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To: Dan Williams <dan.j.williams@...el.com>, gregkh@...uxfoundation.org
Cc: syzbot+4762dd74e32532cda5ff@...kaller.appspotmail.com,
stable@...r.kernel.org, Ashish Sangwan <a.sangwan@...sung.com>,
Namjae Jeon <namjae.jeon@...sung.com>,
Dirk Behme <dirk.behme@...bosch.com>,
"Rafael J. Wysocki" <rafael@...nel.org>, linux-kernel@...r.kernel.org,
linux-cxl@...r.kernel.org
Subject: Re: [PATCH] driver core: Fix uevent_show() vs driver detach race
On 2024/07/13 4:42, Dan Williams wrote:
> @@ -2668,8 +2670,12 @@ static int dev_uevent(const struct kobject *kobj, struct kobj_uevent_env *env)
> if (dev->type && dev->type->name)
> add_uevent_var(env, "DEVTYPE=%s", dev->type->name);
>
> - if (dev->driver)
> - add_uevent_var(env, "DRIVER=%s", dev->driver->name);
> + /* Synchronize with module_remove_driver() */
> + rcu_read_lock();
> + driver = READ_ONCE(dev->driver);
> + if (driver)
> + add_uevent_var(env, "DRIVER=%s", driver->name);
> + rcu_read_unlock();
>
Given that read of dev->driver is protected using RCU,
> @@ -97,6 +98,9 @@ void module_remove_driver(struct device_driver *drv)
> if (!drv)
> return;
>
where is
dev->driver = NULL;
performed prior to
> + /* Synchronize with dev_uevent() */
> + synchronize_rcu();
> +
this synchronize_rcu(), in order to make sure that
READ_ONCE(dev->driver) in dev_uevent() observes NULL?
> sysfs_remove_link(&drv->p->kobj, "module");
>
> if (drv->owner)
>
Powered by blists - more mailing lists