usbip: Fix vep_free_request() null pointer checks on input args
Subsystems (2)
Shuah Khan
maintainerPATCH 1/1 usbip: Fix vep_free_request() null pointer checks on input args
From: Shuah Khan <[email protected]>
Fix vep_free_request() to return when usb_ep and usb_request are null instead of calling WARN_ON.
--- drivers/usb/usbip/vudc_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/usbip/vudc_dev.c +1 -1
@@ -297,7 +297,7 @@ static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) {struct vrequest *req; -if (WARN_ON (!_ep || !_req)) +if (!_ep || !_req)return ; req =to_vrequest (_req);
Shuah Khan
maintainerPATCH 1/1 usbip: Fix vhci_urb_enqueue() URB null transfer buffer error path
From: Shuah Khan <[email protected]>
Fix vhci_urb_enqueue() to print error and return error instead of failing with WARN_ON.
--- drivers/usb/usbip/vhci_hcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/usbip/vhci_hcd.c +4 -2
@@ -702,8 +702,10 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag } vdev = &vhci_hcd->vdev[portnum-1 ]; -/* patch to usb_sg_init() is in 2.5.60 */ -BUG_ON (!urb->transfer_buffer && urb->transfer_buffer_length); +if (!urb->transfer_buffer && urb->transfer_buffer_length) { +dev_err (dev,"Null URB transfer buffer\n" ); +return -EINVAL ; + }spin_lock_irqsave (&vhci->lock, flags);
Greg KH
maintainerRe: [PATCH] usbip: Fix vhci_urb_enqueue() URB null transfer buffer error path
Quoted 15 lines · Shuah Khan
From: Shuah Khan <[email protected]>
Fix
vhci_urb_enqueue()to print error and return error instead of failing withWARN_ON.Signed-off-by Shuah Khan <[email protected]>--- drivers/usb/usbip/vhci_hcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/usb/usbip/vhci_hcd.c +0
-0
drivers/usb/usbip/vhci_hcd.c static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag · line 708
Quoted 9 lines
drivers/usb/usbip/vhci_hcd.c +4
-2@@ -702,8 +702,10 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag } vdev = &vhci_hcd->vdev[portnum-1 ]; -/* patch to usb_sg_init() is in 2.5.60 */ -BUG_ON (!urb->transfer_buffer && urb->transfer_buffer_length); +if (!urb->transfer_buffer && urb->transfer_buffer_length) { +dev_err (dev,"Null URB transfer buffer\n" ); +return -EINVAL ; + }
Could that BUG_ON be hit by userspace somehow? Or is this just an internal check for the api usage?
And sending out a 0 buffer length might be a valid thing (or at least a crazy attempt at something), so you might want to make that dev_dbg() in case userspace could trigger this to keep the log spam down.
thanks,
greg k-h
Re: [PATCH] usbip: Fix vhci_urb_enqueue() URB null transfer buffer error path
In reply to Shuah KhanHello!
Quoted 4 lines · Shuah Khan
From: Shuah Khan <[email protected]>
Fix
vhci_urb_enqueue()to print error and return error instead of failing withWARN_ON.
It's BUG_ON().
Quoted 12 lines
Signed-off-by Shuah Khan <[email protected]>--- drivers/usb/usbip/vhci_hcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/usb/usbip/vhci_hcd.c +0
-0@@ -702,8 +702,10 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag } vdev = &vhci_hcd->vdev[portnum-1 ];
drivers/usb/usbip/vhci_hcd.c static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag · line 711
Quoted 10 lines
drivers/usb/usbip/vhci_hcd.c +4
-2-/* patch to usb_sg_init() is in 2.5.60 */ -BUG_ON (!urb->transfer_buffer && urb->transfer_buffer_length); +if (!urb->transfer_buffer && urb->transfer_buffer_length) { +dev_err (dev,"Null URB transfer buffer\n" ); +return -EINVAL ; + }spin_lock_irqsave (&vhci->lock, flags);
MBR, Sergei
shuah
maintainerRe: [PATCH] usbip: Fix vhci_urb_enqueue() URB null transfer buffer error path
Quoted 10 lines · Sergei Shtylyov
Hello!
Quoted 4 lines · Shuah Khan
From: Shuah Khan <[email protected]>
Fix
vhci_urb_enqueue()to print error and return error instead of failing withWARN_ON.It's BUG_ON().
Thanks. I will fix it.
-- Shuah
Greg KH
maintainerQuoted 15 lines · Shuah Khan
From: Shuah Khan <[email protected]>
Fix
vep_free_request()to return whenusb_epandusb_requestare null instead of callingWARN_ON.Signed-off-by Shuah Khan <[email protected]>--- drivers/usb/usbip/vudc_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/usbip/vudc_dev.c +0
-0
drivers/usb/usbip/vudc_dev.c static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) · line 300
Quoted 5 lines
drivers/usb/usbip/vudc_dev.c +1
-1@@ -297,7 +297,7 @@ static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) {struct vrequest *req; -if (WARN_ON (!_ep || !_req)) +if (!_ep || !_req)
It's impossible for _ep to be NULL in this callback (see usb_ep_free_request() for where this is called from to prove that), so I don't think you need to check that. It's almost impossible for _req to be NULL, so you might as well leave that check in.
thanks,
greg k-h
shuah
maintainerQuoted 19 lines · Greg KH
Quoted 18 lines · Shuah Khan
From: Shuah Khan <[email protected]>
Fix
vep_free_request()to return whenusb_epandusb_requestare null instead of callingWARN_ON.Signed-off-by Shuah Khan <[email protected]>--- drivers/usb/usbip/vudc_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/usbip/vudc_dev.c +0
-0@@ -297,7 +297,7 @@ static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) {struct vrequest *req;
Quoted 8 lines
drivers/usb/usbip/vudc_dev.c static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) · line 300
Quoted 2 lines
drivers/usb/usbip/vudc_dev.c +1
-1-if (WARN_ON (!_ep || !_req)) +if (!_ep || !_req)It's impossible for
_epto be NULL in this callback (seeusb_ep_free_request()for where this is called from to prove that), so I don't think you need to check that. It's almost impossible for_reqto be NULL, so you might as well leave that check in.
Yes. ep can never be null here in vep_free_request(). I will leave this alone.
thanks,
-- Shuah
Greg KH
maintainerQuoted 28 lines · shuah
Quoted 11 lines · Greg KH
Quoted 10 lines · Shuah Khan
From: Shuah Khan <[email protected]>
Fix
vep_free_request()to return whenusb_epandusb_requestare null instead of callingWARN_ON.Signed-off-by Shuah Khan <[email protected]>--- drivers/usb/usbip/vudc_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 15 lines
drivers/usb/usbip/vudc_dev.c static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) · line 299
Quoted 9 lines
drivers/usb/usbip/vudc_dev.c +1
-1@@ -297,7 +297,7 @@ static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) {struct vrequest *req; -if (WARN_ON (!_ep || !_req)) +if (!_ep || !_req)It's impossible for
_epto be NULL in this callback (seeusb_ep_free_request()for where this is called from to prove that), so I don't think you need to check that. It's almost impossible for_reqto be NULL, so you might as well leave that check in.
Quoted 2 lines
Yes. ep can never be null here in
vep_free_request(). I will leave this alone.
You can drop the !_ep check at the least, no need to check something that is impossible to hit :)
thanks,
greg k-h
shuah
maintainerQuoted 29 lines · Greg KH
Quoted 28 lines · shuah
Quoted 26 lines · Greg KH
Quoted 15 lines · Shuah Khan
From: Shuah Khan <[email protected]>
Fix
vep_free_request()to return whenusb_epandusb_requestare null instead of callingWARN_ON.Signed-off-by Shuah Khan <[email protected]>--- drivers/usb/usbip/vudc_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/usbip/vudc_dev.c +0
-0drivers/usb/usbip/vudc_dev.c static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) · line 299
Quoted 4 lines
drivers/usb/usbip/vudc_dev.c +1
-1@@ -297,7 +297,7 @@ static void vep_free_request(struct usb_ep *_ep, struct usb_request *_req) {struct vrequest *req; -if (WARN_ON (!_ep || !_req)) +if (!_ep || !_req)It's impossible for
_epto be NULL in this callback (seeusb_ep_free_request()for where this is called from to prove that), so I don't think you need to check that. It's almost impossible for_reqto be NULL, so you might as well leave that check in.
Quoted 6 lines
Quoted 2 lines
Yes. ep can never be null here in
vep_free_request(). I will leave this alone.You can drop the !_ep check at the least, no need to check something that is impossible to hit :)
Thanks. I will do that.
-- Shuah