From: Peter Chen <peter.chen@nxp.com>
To: Sriharsha Allenki <sallenki@codeaurora.org>
Cc: "balbi@kernel.org" <balbi@kernel.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"mgautam@codeaurora.org" <mgautam@codeaurora.org>,
"jackp@codeaurora.org" <jackp@codeaurora.org>
Subject: Re: [PATCH] usb: gadget: f_fs: Fix use after free issue as part of queue failure
Date: Thu, 26 Mar 2020 11:19:12 +0000 [thread overview]
Message-ID: <20200326111933.GA23632@b29397-desktop> (raw)
In-Reply-To: <20200326060033.14550-1-sallenki@codeaurora.org>
On 20-03-26 11:30:33, Sriharsha Allenki wrote:
> 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.
>
> Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Peter
> ---
> drivers/usb/gadget/function/f_fs.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 571917677d35..767f30b86645 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -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;
> }
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
--
Thanks,
Peter Chen
prev parent reply other threads:[~2020-03-26 11:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-26 6:00 [PATCH] usb: gadget: f_fs: Fix use after free issue as part of queue failure Sriharsha Allenki
2020-03-26 8:16 ` Greg KH
2020-03-26 8:44 ` Sriharsha Allenki
2020-03-26 9:30 ` Greg KH
2020-03-26 12:33 ` Sriharsha Allenki
2020-03-26 11:19 ` Peter Chen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200326111933.GA23632@b29397-desktop \
--to=peter.chen@nxp.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jackp@codeaurora.org \
--cc=linux-usb@vger.kernel.org \
--cc=mgautam@codeaurora.org \
--cc=sallenki@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox