projects
/
platform
/
kernel
/
linux-rpi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4096052
)
driver: base: fix UAF when driver_attach failed
author
Schspa Shi
<schspa@gmail.com>
Fri, 13 May 2022 11:24:44 +0000
(19:24 +0800)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 16:36:09 +0000
(18:36 +0200)
[ Upstream commit
310862e574001a97ad02272bac0fd13f75f42a27
]
When driver_attach(drv); failed, the driver_private will be freed.
But it has been added to the bus, which caused a UAF.
To fix it, we need to delete it from the bus when failed.
Fixes:
190888ac01d0
("driver core: fix possible missing of device probe")
Signed-off-by: Schspa Shi <schspa@gmail.com>
Link:
https://lore.kernel.org/r/20220513112444.45112-1-schspa@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/base/bus.c
patch
|
blob
|
history
diff --git
a/drivers/base/bus.c
b/drivers/base/bus.c
index
bdc98c5
..
d171535
100644
(file)
--- a/
drivers/base/bus.c
+++ b/
drivers/base/bus.c
@@
-617,7
+617,7
@@
int bus_add_driver(struct device_driver *drv)
if (drv->bus->p->drivers_autoprobe) {
error = driver_attach(drv);
if (error)
- goto out_
unregister
;
+ goto out_
del_list
;
}
module_add_driver(drv->owner, drv);
@@
-644,6
+644,8
@@
int bus_add_driver(struct device_driver *drv)
return 0;
+out_del_list:
+ klist_del(&priv->knode_bus);
out_unregister:
kobject_put(&priv->kobj);
/* drv->p is freed in driver_release() */