Skip to content

Commit f63ec55

Browse files
Sriharsha Allenkigregkh
authored andcommitted
usb: gadget: f_fs: Fix use after free issue as part of queue failure
In AIO case, the request is freed up if ep_queue fails. However, io_data->req still has the reference to this freed request. In the case of this failure if there is aio_cancel call on this io_data it will lead to an invalid dequeue operation and a potential use after free issue. Fix this by setting the io_data->req to NULL when the request is freed as part of queue failure. Fixes: 2e4c755 ("usb: gadget: f_fs: add aio support") Signed-off-by: Sriharsha Allenki <[email protected]> CC: stable <[email protected]> Reviewed-by: Peter Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6e56274 commit f63ec55

File tree

1 file changed

+1
-0
lines changed
  • drivers/usb/gadget/function

1 file changed

+1
-0
lines changed

drivers/usb/gadget/function/f_fs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
11201120

11211121
ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC);
11221122
if (unlikely(ret)) {
1123+
io_data->req = NULL;
11231124
usb_ep_free_request(ep->ep, req);
11241125
goto error_lock;
11251126
}

0 commit comments

Comments
 (0)