From: Dan Carpenter <error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Chris Ball <cjb-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: re: HID: hiddev: protect against disconnect/NULL-dereference race
Date: Fri, 20 Aug 2010 23:24:14 +0200 [thread overview]
Message-ID: <20100820212413.GE6674@bicker> (raw)
The patch 7032269e87a "HID: hiddev: protect against
disconnect/NULL-dereference race" added a check to make sure that "hid"
was non-NULL. The problem is that it added the check after "hid" had
already been dereferenced.
drivers/hid/usbhid/hiddev.c +606 hiddev_ioctl(19)
warn: variable dereferenced before check 'hid'
599 struct usbhid_device *usbhid = hid->driver_data;
^^^^^^^^^^^^^^^^
dereferenced here.
600 void __user *user_arg = (void __user *)arg;
601 int i, r;
602
603 /* Called without BKL by compat methods so no BKL taken */
604
605 /* FIXME: Who or what stop this racing with a disconnect ?? */
606 if (!hiddev->exist || !hid)
^^^^
new check added here.
607 return -EIO;
So obviously in hind-sight this patch didn't fix the user's problem.
Also the user reported a NULL dereference, yes, but the stack dump which
says: "BUG: unable to handle kernel paging request at 6b6b6b6b" is a use
after free bug and that isn't addressed by adding a check for NULL.
I am just looking at this because it showed up with my static checker
and I'm not very familiar with this code. I think we need to take
"hiddev->existancelock" and make sure that exist is true before we
dereference hiddev in the ioctl function? Also it seems like there
should probably be some locking in hiddev_release().
regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
reply other threads:[~2010-08-20 21:24 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=20100820212413.GE6674@bicker \
--to=error27-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=cjb-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org \
--cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.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).