Commit 076a50db authored by Sriharsha Allenki's avatar Sriharsha Allenki Committed by Kleber Sacilotto de Souza

usb: gadget: f_fs: Fix use after free issue as part of queue failure

BugLink: https://bugs.launchpad.net/bugs/1875905

commit f63ec55f upstream.

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: 2e4c7553 ("usb: gadget: f_fs: add aio support")
Signed-off-by: default avatarSriharsha Allenki <sallenki@codeaurora.org>
CC: stable <stable@vger.kernel.org>
Reviewed-by: default avatarPeter Chen <peter.chen@nxp.com>
Link: https://lore.kernel.org/r/20200326115620.12571-1-sallenki@codeaurora.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent ddf397c3
...@@ -812,6 +812,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) ...@@ -812,6 +812,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC); ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC);
if (unlikely(ret)) { if (unlikely(ret)) {
io_data->req = NULL;
usb_ep_free_request(ep->ep, req); usb_ep_free_request(ep->ep, req);
goto error_lock; goto error_lock;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment