Thread (8 messages) 8 messages, 2 authors, 2021-12-31

Re: [PATCH v3 2/2] usb: gadget: clear related members when goto fail

From: Alan Stern <stern@rowland.harvard.edu>
Date: 2021-12-30 19:50:24
Also in: lkml

On Thu, Dec 30, 2021 at 02:46:00PM -0500, Alan Stern wrote:
On Thu, Dec 30, 2021 at 01:11:32PM +0800, Hangyu Hua wrote:
quoted
dev->config and dev->hs_config and dev->dev need to be cleaned if
dev_config fails to avoid UAF.
quoted
@@ -1875,6 +1875,9 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 
 	value = usb_gadget_probe_driver(&gadgetfs_driver);
 	if (value != 0) {
+		dev->dev = NULL;
+		dev->hs_config = NULL;
+		dev->config = NULL;
 		kfree (dev->buf);
 		dev->buf = NULL;
Why not just grep the lock and goto fail?
Wrong word: I meant to write "grab", not "grep".

Alan Stern
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help