From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22BE41EE00F; Wed, 6 Nov 2024 12:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730897254; cv=none; b=QyFRTJpHibTL055gqJ5e0miUlOSHddtx5pIlsHGSqjYiG4O1ai1R6Ut4nxteFkZANJpVuyUBGjzn4jk2t2glv+z1QwvP8Gv5pMrLW3rXcBXNoL9N4cCOw1yReq4s0fmFcdQsdcO3gTR6icOay5pkXpTHOelbld2ITsnD2unctuc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730897254; c=relaxed/simple; bh=9nJv/kUUVM4jJcMZtD8DQfUF4lseZjiXmC4hvCFKb4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HkSxFL5HLGCQx8QKMsZX9/GY0HJBlp0QujaYlvBgS/+DxAv5tpwzQI6G34AS03AUb+/tw+mKXs1/uyCdOtuL0hA1mOgGKVwOM35YhDKyP+hX4sabozUmMDLAgObfbf5epRMKxvXJ7VDOofrR7ldCFP+7ixP5U2L9CiwQ6zxcnrk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ld2UcbF5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ld2UcbF5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1361FC4CECD; Wed, 6 Nov 2024 12:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730897253; bh=9nJv/kUUVM4jJcMZtD8DQfUF4lseZjiXmC4hvCFKb4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ld2UcbF56F2DFjGPkEQuYHCZS/abQnCBNlyk9nyghhGN3viXj+oxJN/AeIXIV9L3E BqglRudFxXPRsKgEFakuFMVjg9zlHxon2DWVCe0vcfvSbXO4W2QZvul4Fb9FFnaHe5 QYaU/xL0I+3kESkO9hAF0tYMHYxfFmVPJT4gjxoc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Ashish Sangwan , Namjae Jeon , Dirk Behme , "Rafael J. Wysocki" , Dan Williams Subject: [PATCH 6.1 071/126] Revert "driver core: Fix uevent_show() vs driver detach race" Date: Wed, 6 Nov 2024 13:04:32 +0100 Message-ID: <20241106120308.008333876@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120306.038154857@linuxfoundation.org> References: <20241106120306.038154857@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Greg Kroah-Hartman commit 9a71892cbcdb9d1459c84f5a4c722b14354158a5 upstream. This reverts commit 15fffc6a5624b13b428bb1c6e9088e32a55eb82c. This commit causes a regression, so revert it for now until it can come back in a way that works for everyone. Link: https://lore.kernel.org/all/172790598832.1168608.4519484276671503678.stgit@dwillia2-xfh.jf.intel.com/ Fixes: 15fffc6a5624 ("driver core: Fix uevent_show() vs driver detach race") Cc: stable Cc: Ashish Sangwan Cc: Namjae Jeon Cc: Dirk Behme Cc: Greg Kroah-Hartman Cc: Rafael J. Wysocki Cc: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 13 +++++-------- drivers/base/module.c | 4 ---- 2 files changed, 5 insertions(+), 12 deletions(-) --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -2559,7 +2558,6 @@ static const char *dev_uevent_name(struc static int dev_uevent(struct kobject *kobj, struct kobj_uevent_env *env) { struct device *dev = kobj_to_dev(kobj); - struct device_driver *driver; int retval = 0; /* add device node properties if present */ @@ -2588,12 +2586,8 @@ static int dev_uevent(struct kobject *ko if (dev->type && dev->type->name) add_uevent_var(env, "DEVTYPE=%s", dev->type->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(); + if (dev->driver) + add_uevent_var(env, "DRIVER=%s", dev->driver->name); /* Add common DT information about the device */ of_device_uevent(dev, env); @@ -2663,8 +2657,11 @@ static ssize_t uevent_show(struct device if (!env) return -ENOMEM; + /* Synchronize with really_probe() */ + device_lock(dev); /* let the kset specific function add its keys */ retval = kset->uevent_ops->uevent(&dev->kobj, env); + device_unlock(dev); if (retval) goto out; --- a/drivers/base/module.c +++ b/drivers/base/module.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "base.h" static char *make_driver_name(struct device_driver *drv) @@ -78,9 +77,6 @@ void module_remove_driver(struct device_ if (!drv) return; - /* Synchronize with dev_uevent() */ - synchronize_rcu(); - sysfs_remove_link(&drv->p->kobj, "module"); if (drv->owner)