All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3.16] staging: usbip stub_rx fix static checker warning on unnecessary checks
@ 2018-02-26 21:12 ` Shuah Khan
  0 siblings, 0 replies; 4+ messages in thread
From: Shuah Khan @ 2018-02-26 21:12 UTC (permalink / raw)
  To: valentina.manea.m, shuah, gregkh
  Cc: Shuah Khan, devel, linux-usb, linux-kernel, stable, bwh, dan.carpenter

Upstream commit 10c901209306
("usbip: stub_rx: fix static checker warning on unnecessary checks")

Back-port fix for static checker warning on unnecessary checks

smatch warnings:
drivers/staging/usbip/stub_rx.c:360 get_pipe() warn: impossible
condition '(pdu->u.cmd_submit.transfer_buffer_length > ((~0 >> 1))) =>
(s32min-s32max > s32max)'
drivers/staging/usbip/stub_rx.c:501 stub_recv_cmd_submit() warn: always
true condition '(pdu->u.cmd_submit.transfer_buffer_length <= ((~0 >>
1))) => (s32min-s32max <= s32max)'

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
 drivers/staging/usbip/stub_rx.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
index 35f59747122a..d8544ab9577b 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/staging/usbip/stub_rx.c
@@ -356,14 +356,6 @@ static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu)
 
 	epd = &ep->desc;
 
-	/* validate transfer_buffer_length */
-	if (pdu->u.cmd_submit.transfer_buffer_length > INT_MAX) {
-		dev_err(&sdev->udev->dev,
-			"CMD_SUBMIT: -EMSGSIZE transfer_buffer_length %d\n",
-			pdu->u.cmd_submit.transfer_buffer_length);
-		return -1;
-	}
-
 	if (usb_endpoint_xfer_control(epd)) {
 		if (dir == USBIP_DIR_OUT)
 			return usb_sndctrlpipe(udev, epnum);
@@ -497,8 +489,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
 	}
 
 	/* allocate urb transfer buffer, if needed */
-	if (pdu->u.cmd_submit.transfer_buffer_length > 0 &&
-	    pdu->u.cmd_submit.transfer_buffer_length <= INT_MAX) {
+	if (pdu->u.cmd_submit.transfer_buffer_length > 0) {
 		priv->urb->transfer_buffer =
 			kzalloc(pdu->u.cmd_submit.transfer_buffer_length,
 				GFP_KERNEL);
-- 
2.14.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [3.16] staging: usbip stub_rx fix static checker warning on unnecessary checks
@ 2018-02-26 21:12 ` Shuah Khan
  0 siblings, 0 replies; 4+ messages in thread
From: Shuah Khan @ 2018-02-26 21:12 UTC (permalink / raw)
  To: valentina.manea.m, shuah, gregkh
  Cc: Shuah Khan, devel, linux-usb, linux-kernel, stable, bwh, dan.carpenter

Upstream commit 10c901209306
("usbip: stub_rx: fix static checker warning on unnecessary checks")

Back-port fix for static checker warning on unnecessary checks

smatch warnings:
drivers/staging/usbip/stub_rx.c:360 get_pipe() warn: impossible
condition '(pdu->u.cmd_submit.transfer_buffer_length > ((~0 >> 1))) =>
(s32min-s32max > s32max)'
drivers/staging/usbip/stub_rx.c:501 stub_recv_cmd_submit() warn: always
true condition '(pdu->u.cmd_submit.transfer_buffer_length <= ((~0 >>
1))) => (s32min-s32max <= s32max)'

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
 drivers/staging/usbip/stub_rx.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
index 35f59747122a..d8544ab9577b 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/staging/usbip/stub_rx.c
@@ -356,14 +356,6 @@ static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu)
 
 	epd = &ep->desc;
 
-	/* validate transfer_buffer_length */
-	if (pdu->u.cmd_submit.transfer_buffer_length > INT_MAX) {
-		dev_err(&sdev->udev->dev,
-			"CMD_SUBMIT: -EMSGSIZE transfer_buffer_length %d\n",
-			pdu->u.cmd_submit.transfer_buffer_length);
-		return -1;
-	}
-
 	if (usb_endpoint_xfer_control(epd)) {
 		if (dir == USBIP_DIR_OUT)
 			return usb_sndctrlpipe(udev, epnum);
@@ -497,8 +489,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
 	}
 
 	/* allocate urb transfer buffer, if needed */
-	if (pdu->u.cmd_submit.transfer_buffer_length > 0 &&
-	    pdu->u.cmd_submit.transfer_buffer_length <= INT_MAX) {
+	if (pdu->u.cmd_submit.transfer_buffer_length > 0) {
 		priv->urb->transfer_buffer =
 			kzalloc(pdu->u.cmd_submit.transfer_buffer_length,
 				GFP_KERNEL);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 3.16] staging: usbip stub_rx fix static checker warning on unnecessary checks
@ 2018-11-11  1:33   ` Ben Hutchings
  0 siblings, 0 replies; 4+ messages in thread
From: Ben Hutchings @ 2018-11-11  1:33 UTC (permalink / raw)
  To: Shuah Khan, valentina.manea.m, shuah, gregkh
  Cc: devel, linux-usb, linux-kernel, stable, bwh, dan.carpenter

[-- Attachment #1: Type: text/plain, Size: 2147 bytes --]

On Mon, 2018-02-26 at 14:12 -0700, Shuah Khan wrote:
> Upstream commit 10c901209306
> ("usbip: stub_rx: fix static checker warning on unnecessary checks")
> 
> Back-port fix for static checker warning on unnecessary checks
> 
> smatch warnings:
> drivers/staging/usbip/stub_rx.c:360 get_pipe() warn: impossible
> condition '(pdu->u.cmd_submit.transfer_buffer_length > ((~0 >> 1))) =>
> (s32min-s32max > s32max)'
> drivers/staging/usbip/stub_rx.c:501 stub_recv_cmd_submit() warn: always
> true condition '(pdu->u.cmd_submit.transfer_buffer_length <= ((~0 >>
> 1))) => (s32min-s32max <= s32max)'

I've finally queued this up, thanks.

Ben.

> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
> ---
>  drivers/staging/usbip/stub_rx.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
> index 35f59747122a..d8544ab9577b 100644
> --- a/drivers/staging/usbip/stub_rx.c
> +++ b/drivers/staging/usbip/stub_rx.c
> @@ -356,14 +356,6 @@ static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu)
>  
>  	epd = &ep->desc;
>  
> -	/* validate transfer_buffer_length */
> -	if (pdu->u.cmd_submit.transfer_buffer_length > INT_MAX) {
> -		dev_err(&sdev->udev->dev,
> -			"CMD_SUBMIT: -EMSGSIZE transfer_buffer_length %d\n",
> -			pdu->u.cmd_submit.transfer_buffer_length);
> -		return -1;
> -	}
> -
>  	if (usb_endpoint_xfer_control(epd)) {
>  		if (dir == USBIP_DIR_OUT)
>  			return usb_sndctrlpipe(udev, epnum);
> @@ -497,8 +489,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
>  	}
>  
>  	/* allocate urb transfer buffer, if needed */
> -	if (pdu->u.cmd_submit.transfer_buffer_length > 0 &&
> -	    pdu->u.cmd_submit.transfer_buffer_length <= INT_MAX) {
> +	if (pdu->u.cmd_submit.transfer_buffer_length > 0) {
>  		priv->urb->transfer_buffer =
>  			kzalloc(pdu->u.cmd_submit.transfer_buffer_length,
>  				GFP_KERNEL);
-- 
Ben Hutchings
Reality is just a crutch for people who can't handle science fiction.



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [3.16] staging: usbip stub_rx fix static checker warning on unnecessary checks
@ 2018-11-11  1:33   ` Ben Hutchings
  0 siblings, 0 replies; 4+ messages in thread
From: Ben Hutchings @ 2018-11-11  1:33 UTC (permalink / raw)
  To: Shuah Khan, valentina.manea.m, shuah, gregkh
  Cc: devel, linux-usb, linux-kernel, stable, bwh, dan.carpenter

On Mon, 2018-02-26 at 14:12 -0700, Shuah Khan wrote:
> Upstream commit 10c901209306
> ("usbip: stub_rx: fix static checker warning on unnecessary checks")
> 
> Back-port fix for static checker warning on unnecessary checks
> 
> smatch warnings:
> drivers/staging/usbip/stub_rx.c:360 get_pipe() warn: impossible
> condition '(pdu->u.cmd_submit.transfer_buffer_length > ((~0 >> 1))) =>
> (s32min-s32max > s32max)'
> drivers/staging/usbip/stub_rx.c:501 stub_recv_cmd_submit() warn: always
> true condition '(pdu->u.cmd_submit.transfer_buffer_length <= ((~0 >>
> 1))) => (s32min-s32max <= s32max)'

I've finally queued this up, thanks.

Ben.

> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
> ---
>  drivers/staging/usbip/stub_rx.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
> index 35f59747122a..d8544ab9577b 100644
> --- a/drivers/staging/usbip/stub_rx.c
> +++ b/drivers/staging/usbip/stub_rx.c
> @@ -356,14 +356,6 @@ static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu)
>  
>  	epd = &ep->desc;
>  
> -	/* validate transfer_buffer_length */
> -	if (pdu->u.cmd_submit.transfer_buffer_length > INT_MAX) {
> -		dev_err(&sdev->udev->dev,
> -			"CMD_SUBMIT: -EMSGSIZE transfer_buffer_length %d\n",
> -			pdu->u.cmd_submit.transfer_buffer_length);
> -		return -1;
> -	}
> -
>  	if (usb_endpoint_xfer_control(epd)) {
>  		if (dir == USBIP_DIR_OUT)
>  			return usb_sndctrlpipe(udev, epnum);
> @@ -497,8 +489,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
>  	}
>  
>  	/* allocate urb transfer buffer, if needed */
> -	if (pdu->u.cmd_submit.transfer_buffer_length > 0 &&
> -	    pdu->u.cmd_submit.transfer_buffer_length <= INT_MAX) {
> +	if (pdu->u.cmd_submit.transfer_buffer_length > 0) {
>  		priv->urb->transfer_buffer =
>  			kzalloc(pdu->u.cmd_submit.transfer_buffer_length,
>  				GFP_KERNEL);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-11  1:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26 21:12 [PATCH 3.16] staging: usbip stub_rx fix static checker warning on unnecessary checks Shuah Khan
2018-02-26 21:12 ` [3.16] " Shuah Khan
2018-11-11  1:33 ` [PATCH 3.16] " Ben Hutchings
2018-11-11  1:33   ` [3.16] " Ben Hutchings

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.