usb: Don't use %pK through printk
Subsystems (3)
v2 cover usb: Don't use %pK through printk
Restricted pointers ("%pK") are not meant to be used through printk(). It can unintentionally expose security sensitive, raw pointer values.
Use regular pointer formatting instead.
---
Changes in v2:
- Refer to original %p->%pK changes in commit messages
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Thomas Weißschuh (2):
usb: core: Don't use %pK through printk
usb: dwc3: Don't use %pK through printk
drivers/usb/core/hcd.c | 4 ++-- drivers/usb/core/urb.c | 2 +- drivers/usb/dwc3/dwc3-st.c | 2 +- drivers/usb/dwc3/gadget.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-)
---
base-commit: 80e54e84911a923c40d7bee33a34c1b4be148d7a
change-id: 20250217-restricted-pointers-usb-8c711bae6994
Best regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
PATCH v2 1/2 usb: core: Don't use %pK through printk
This is a revert of
commit 2f964780c03b ("USB: core: replace %p with %pK").
When the formatting was changed from %p to %pK that was a security improvement, as %p would leak raw pointer values to the kernel log. Since commit ad67b74d2469 ("printk: hash addresses printed with %p") the regular %p has been improved to avoid this issue.
On the other hand, restricted pointers ("%pK") were never meant to be used through printk(). They can unintentionally still leak raw pointers or acquire sleeping looks in atomic contexts.
Switch back to regular %p again.
--- drivers/usb/core/hcd.c | 4 ++-- drivers/usb/core/urb.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/usb/core/hcd.c +2 -2
@@ -1609,7 +1609,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 %pK fail %d\n" , +dev_dbg (&udev->dev,"hcd_unlink_urb %p fail %d\n" , urb, retval);usb_put_dev (udev); }
@@ -1786,7 +1786,7 @@ void usb_hcd_flush_endpoint(struct usb_device *udev,/* kick hcd */ unlink1 (hcd, urb, -ESHUTDOWN );dev_dbg (hcd->self.controller, -"shutdown urb %pK ep%d%s-%s\n" , +"shutdown urb %p ep%d%s-%s\n" , urb,usb_endpoint_num (&ep->desc), is_in ?"in" :"out" ,usb_ep_type_string (usb_endpoint_type (&ep->desc)));
drivers/usb/core/urb.c +1 -1
@@ -376,7 +376,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 %pK submitted while active\n" , urb); +WARN_ONCE (1 ,"URB %p submitted while active\n" , urb);return -EBUSY ; }
Signature · 1 line
2.48.1
PATCH v2 2/2 usb: dwc3: Don't use %pK through printk
In reply to Thomas WeißschuhThis is a revert of
commit 04fb365c453e ("usb: dwc3: replace %p with %pK")
When the formatting was changed from %p to %pK that was a security improvement, as %p would leak raw pointer values to the kernel log. Since commit ad67b74d2469 ("printk: hash addresses printed with %p") the regular %p has been improved to avoid this issue.
On the other hand, restricted pointers ("%pK") were never meant to be used through printk(). They can unintentionally still leak raw pointers or acquire sleeping looks in atomic contexts.
Switch back to regular %p again.
--- drivers/usb/dwc3/dwc3-st.c | 2 +- drivers/usb/dwc3/gadget.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/usb/dwc3/dwc3-st.c +1 -1
@@ -225,7 +225,7 @@ static int st_dwc3_probe(struct platform_device *pdev) dwc3_data->syscfg_reg_off = res->start; -dev_vdbg (dev,"glue-logic addr 0x%pK, syscfg-reg offset 0x%x\n" , +dev_vdbg (dev,"glue-logic addr 0x%p, syscfg-reg offset 0x%x\n" , dwc3_data->glue_base, dwc3_data->syscfg_reg_off); struct device_node *child __free(device_node) = of_get_compatible_child(node,
drivers/usb/dwc3/gadget.c +3 -3
@@ -1971,12 +1971,12 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)return -ESHUTDOWN ; } -if (WARN (req->dep != dep,"request %pK belongs to '%s'\n" , +if (WARN (req->dep != dep,"request %p belongs to '%s'\n" , &req->request, req->dep->name))return -EINVAL ;if (WARN (req->status <DWC3_REQUEST_STATUS_COMPLETED , -"%s: request %pK already in flight\n" , +"%s: request %p already in flight\n" , dep->name, &req->request))return -EINVAL ;
@@ -2165,7 +2165,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, } } -dev_err (dwc->dev,"request %pK was not queued to %s\n" , +dev_err (dwc->dev,"request %p was not queued to %s\n" , request, ep->name); ret = -EINVAL ; out:
Signature · 1 line
2.48.1