]> git.baikalelectronics.ru Git - kernel.git/commitdiff
usb: gadget: f_fs: Fix use after free issue as part of queue failure
authorSriharsha Allenki <sallenki@codeaurora.org>
Thu, 26 Mar 2020 11:56:20 +0000 (17:26 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Apr 2020 08:50:06 +0000 (10:50 +0200)
commit 8ce17713289a17499aaa981e0d0fdbe461a5ca74 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: c3751367a549 ("usb: gadget: f_fs: add aio support")
Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
CC: stable <stable@vger.kernel.org>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Link: https://lore.kernel.org/r/20200326115620.12571-1-sallenki@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_fs.c

index a9a711e046148ffc868ac2faf7ef33fc9051be9f..87fdeb042c678355f857f94575092172b3aa0857 100644 (file)
@@ -1120,6 +1120,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);
                if (unlikely(ret)) {
+                       io_data->req = NULL;
                        usb_ep_free_request(ep->ep, req);
                        goto error_lock;
                }