From: Sven Van Asbroeck <thesven73@gmail.com>
To: Samuel Ortiz <sameo@linux.intel.com>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC v1] NFC: port100: prevent use-after-free on disconnect
Date: Tue, 5 Feb 2019 11:01:18 -0500 [thread overview]
Message-ID: <20190205160118.27491-1-TheSven73@googlemail.com> (raw)
Problem:
The cmd_complete_work work could potentially run after resources
are freed in disconnect(). This could cause user-after-free
issues.
Solution:
Reorder disconnect() calls, and explicitly cancel the work
using cancel_work_sync().
Signed-off-by: Sven Van Asbroeck <TheSven73@googlemail.com>
---
Samuel,
I'm unfamiliar with this driver, and I don't have the h/w, so I cannot test it.
This is just a suggestion on how to fix a potential issue.
Sven
drivers/nfc/port100.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
index bb43cebda9dc..66d1bda9208c 100644
--- a/drivers/nfc/port100.c
+++ b/drivers/nfc/port100.c
@@ -1630,19 +1630,19 @@ static void port100_disconnect(struct usb_interface *interface)
struct port100 *dev;
dev = usb_get_intfdata(interface);
- usb_set_intfdata(interface, NULL);
nfc_digital_unregister_device(dev->nfc_digital_dev);
- nfc_digital_free_device(dev->nfc_digital_dev);
-
usb_kill_urb(dev->in_urb);
usb_kill_urb(dev->out_urb);
+ cancel_work_sync(&dev->cmd_complete_work);
+
usb_free_urb(dev->in_urb);
usb_free_urb(dev->out_urb);
usb_put_dev(dev->udev);
-
+ nfc_digital_free_device(dev->nfc_digital_dev);
kfree(dev->cmd);
+ usb_set_intfdata(interface, NULL);
nfc_info(&interface->dev, "Sony Port-100 NFC device disconnected\n");
}
--
2.17.1
reply other threads:[~2019-02-05 16:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190205160118.27491-1-TheSven73@googlemail.com \
--to=thesven73@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=sameo@linux.intel.com \
/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
all inboxes | Powered by JetHome®