fs: sysfs: do not remove files if group is null
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Greg, Rafael,
Have you had a chance to review this patch?
Thank You,
Daniel
-----Original Message-----
From: Daniel Steger <[email protected]>
Sent: Monday, August 9, 2021 1:42 PM
To: [email protected]; [email protected]
Cc: [email protected]; Daniel Steger <[email protected]>
Subject: [PATCH] fs: sysfs: do not remove files if group is null
The current implementation allows the remove_files() API to be called without checking if the grp->name is null. Ensure that the group name is valid prior to removing files.
This patch fixes a race condition where device_del() will cleanup sysfs entries prior to device managed sysfs entries. This results in a NULL group->name and a system error during device cleanup.
To reproduce the issue, simply create a new child device in a platform driver of your choice. Add a sysfs file group using devm API. On driver exist ensure to unregister your child device. Do not call devm_device_remove_group() and leave it up to the implementation to automatically clean up the files. Here is where you will see a kernel error complaining that the files have already been removed.
--- fs/sysfs/group.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/sysfs/group.c +3 -2
@@ -286,9 +286,10 @@ void sysfs_remove_group(struct kobject *kobj,kernfs_get (kn); } -remove_files (kn, grp); -if (grp->name) +if (grp->name) { +remove_files (kn, grp);kernfs_remove (kn); + }kernfs_put (kn); }
--
2.25.1
[email protected]
maintainerA: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
A: No.
Q: Should I include quotations after my reply?
http://daringfireball.net/2007/07/on_top
Quoted 3 lines · Daniel Steger
Hi Greg, Rafael,
Have you had a chance to review this patch?
What patch?
Quoted 10 lines
Thank You,
Daniel-----Original Message-----
From: Daniel Steger <[email protected]>
Sent: Monday, August 9, 2021 1:42 PM
To: [email protected]; [email protected]
Cc: [email protected]; Daniel Steger <[email protected]>
Subject: [PATCH] fs: sysfs: do not remove files if group is null
What is the message id of this, I do not see it on my side at all.
Quoted 2 lines
The current implementation allows the
remove_files()API to be called without checking if thegrp->nameis null. Ensure that the group name is valid prior to removing files.
At the least, wrap your lines at 72 columns, we can't take this as-is...
thanks,
greg k-h
[email protected]
maintainerQuoted 8 lines · On Tue, Aug 17, 2021 at 06:18:07PM +0200, [email protected] wrote:
Quoted 6 lines
-----Original Message-----
From: Daniel Steger <[email protected]>
Sent: Monday, August 9, 2021 1:42 PM
To: [email protected]; [email protected]
Cc: [email protected]; Daniel Steger <[email protected]>
Subject: [PATCH] fs: sysfs: do not remove files if group is nullWhat is the message id of this, I do not see it on my side at all.
lore.kernel.org also never got this, so I think the issue might be on your side :(