USB: core: replace %p with %pK
authorVamsi Krishna Samavedam <vskrishn@codeaurora.org>
Tue, 16 May 2017 12:38:08 +0000 (14:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 May 2017 12:30:07 +0000 (14:30 +0200)
commit 2f964780c03b73de269b08d12aff96a9618d13f3 upstream.

Format specifier %p can leak kernel addresses while not valuing the
kptr_restrict system settings. When kptr_restrict is set to (1), kernel
pointers printed using the %pK format specifier will be replaced with
Zeros. Debugging Note : &pK prints only Zeros as address. If you need
actual address information, write 0 to kptr_restrict.

echo 0 > /proc/sys/kernel/kptr_restrict

[Found by poking around in a random vendor kernel tree, it would be nice
if someone would actually send these types of patches upstream - gkh]

Signed-off-by: Vamsi Krishna Samavedam <vskrishn@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/devio.c
drivers/usb/core/hcd.c
drivers/usb/core/urb.c

index f5c92d904ded329dfff64de542604ce7b5c9f756..54d2d6b604c00daaf82207b47857f289de875ae5 100644 (file)
@@ -373,11 +373,11 @@ static void snoop_urb(struct usb_device *udev,
 
        if (userurb) {          /* Async */
                if (when == SUBMIT)
-                       dev_info(&udev->dev, "userurb %p, ep%d %s-%s, "
+                       dev_info(&udev->dev, "userurb %pK, ep%d %s-%s, "
                                        "length %u\n",
                                        userurb, ep, t, d, length);
                else
-                       dev_info(&udev->dev, "userurb %p, ep%d %s-%s, "
+                       dev_info(&udev->dev, "userurb %pK, ep%d %s-%s, "
                                        "actual_length %u status %d\n",
                                        userurb, ep, t, d, length,
                                        timeout_or_status);
index ca2cbdb3aa672117f09bbf30bf75e6ef5ba9c2c9..c3f4f2ab7b33b585411afd5e99d5e99367f11cd8 100644 (file)
@@ -1696,7 +1696,7 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
                if (retval == 0)
                        retval = -EINPROGRESS;
                else if (retval != -EIDRM && retval != -EBUSY)
-                       dev_dbg(&udev->dev, "hcd_unlink_urb %p fail %d\n",
+                       dev_dbg(&udev->dev, "hcd_unlink_urb %pK fail %d\n",
                                        urb, retval);
                usb_put_dev(udev);
        }
@@ -1863,7 +1863,7 @@ rescan:
                /* kick hcd */
                unlink1(hcd, urb, -ESHUTDOWN);
                dev_dbg (hcd->self.controller,
-                       "shutdown urb %p ep%d%s%s\n",
+                       "shutdown urb %pK ep%d%s%s\n",
                        urb, usb_endpoint_num(&ep->desc),
                        is_in ? "in" : "out",
                        ({      char *s;
index c601e25b609fb58e6842c18e62e5c484c98182ae..e43ef7d2d00e7dbb0abe7761eacfef5c75b748fb 100644 (file)
@@ -335,7 +335,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
        if (!urb || !urb->complete)
                return -EINVAL;
        if (urb->hcpriv) {
-               WARN_ONCE(1, "URB %p submitted while active\n", urb);
+               WARN_ONCE(1, "URB %pK submitted while active\n", urb);
                return -EBUSY;
        }