From: Pan Bian <bianpan2016@163.com>
To: Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Colin Ian King <colin.king@canonical.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Chuhong Yuan <hslester96@gmail.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Pan Bian <bianpan2016@163.com>
Subject: [PATCH] usb: gadget: pch_udc: fix use after free
Date: Wed, 6 Nov 2019 16:38:23 +0800 [thread overview]
Message-ID: <1573029503-18369-1-git-send-email-bianpan2016@163.com> (raw)
The next field of the DMA descriptor is written after releasing the
descriptor, which may result in a use-after-free issue. Set the value of
the field before it is released to fix the bug.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/usb/gadget/udc/pch_udc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index 265dab2bbfac..c5b8ec908aab 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -1518,8 +1518,8 @@ static void pch_udc_free_dma_chain(struct pch_udc_dev *dev,
/* do not free first desc., will be done by free for request */
td = phys_to_virt(addr);
addr2 = (dma_addr_t)td->next;
- dma_pool_free(dev->data_requests, td, addr);
td->next = 0x00;
+ dma_pool_free(dev->data_requests, td, addr);
addr = addr2;
}
req->chain_len = 1;
--
2.7.4
next reply other threads:[~2019-11-06 8:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-06 8:38 Pan Bian [this message]
2019-11-06 8:54 ` [PATCH] usb: gadget: pch_udc: fix use after free Andy Shevchenko
2019-11-06 20:35 ` Gustavo A. R. Silva
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=1573029503-18369-1-git-send-email-bianpan2016@163.com \
--to=bianpan2016@163.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=balbi@kernel.org \
--cc=bhelgaas@google.com \
--cc=colin.king@canonical.com \
--cc=gregkh@linuxfoundation.org \
--cc=hslester96@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).