All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] xen-netback: correct length checks on hash copy_ops
@ 2016-05-18  7:53 Paul Durrant
  2016-05-18  9:42 ` Wei Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Paul Durrant @ 2016-05-18  7:53 UTC (permalink / raw)
  To: xen-devel, netdev; +Cc: Paul Durrant, Wei Liu

The length checks on the grant table copy_ops for setting hash key and
hash mapping are checking the local 'len' value which is correct in
the case of the former but not the latter. This was picked up by
static analysis checks.

This patch replaces checks of 'len' with 'copy_op.len' in both cases
to correct the incorrect check, keep the two checks consistent, and to
make it clear what the checks are for.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 drivers/net/xen-netback/hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c
index 392e392..fb87cb3 100644
--- a/drivers/net/xen-netback/hash.c
+++ b/drivers/net/xen-netback/hash.c
@@ -311,7 +311,7 @@ u32 xenvif_set_hash_key(struct xenvif *vif, u32 gref, u32 len)
 	if (len > XEN_NETBK_MAX_HASH_KEY_SIZE)
 		return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
 
-	if (len != 0) {
+	if (copy_op.len != 0) {
 		gnttab_batch_copy(&copy_op, 1);
 
 		if (copy_op.status != GNTST_okay)
@@ -359,7 +359,7 @@ u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
 		if (mapping[off++] >= vif->num_queues)
 			return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
 
-	if (len != 0) {
+	if (copy_op.len != 0) {
 		gnttab_batch_copy(&copy_op, 1);
 
 		if (copy_op.status != GNTST_okay)
-- 
2.1.4

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

* Re: [PATCH net-next] xen-netback: correct length checks on hash copy_ops
  2016-05-18  7:53 [PATCH net-next] xen-netback: correct length checks on hash copy_ops Paul Durrant
  2016-05-18  9:42 ` Wei Liu
@ 2016-05-18  9:42 ` Wei Liu
  2016-05-20 17:51 ` David Miller
  2016-05-20 17:51 ` David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2016-05-18  9:42 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, netdev, Wei Liu

On Wed, May 18, 2016 at 08:53:01AM +0100, Paul Durrant wrote:
> The length checks on the grant table copy_ops for setting hash key and
> hash mapping are checking the local 'len' value which is correct in
> the case of the former but not the latter. This was picked up by
> static analysis checks.
> 
> This patch replaces checks of 'len' with 'copy_op.len' in both cases
> to correct the incorrect check, keep the two checks consistent, and to
> make it clear what the checks are for.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: Wei Liu <wei.liu2@citrix.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

> ---
>  drivers/net/xen-netback/hash.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c
> index 392e392..fb87cb3 100644
> --- a/drivers/net/xen-netback/hash.c
> +++ b/drivers/net/xen-netback/hash.c
> @@ -311,7 +311,7 @@ u32 xenvif_set_hash_key(struct xenvif *vif, u32 gref, u32 len)
>  	if (len > XEN_NETBK_MAX_HASH_KEY_SIZE)
>  		return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>  
> -	if (len != 0) {
> +	if (copy_op.len != 0) {
>  		gnttab_batch_copy(&copy_op, 1);
>  
>  		if (copy_op.status != GNTST_okay)
> @@ -359,7 +359,7 @@ u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
>  		if (mapping[off++] >= vif->num_queues)
>  			return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>  
> -	if (len != 0) {
> +	if (copy_op.len != 0) {
>  		gnttab_batch_copy(&copy_op, 1);
>  
>  		if (copy_op.status != GNTST_okay)
> -- 
> 2.1.4
> 

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

* Re: [PATCH net-next] xen-netback: correct length checks on hash copy_ops
  2016-05-18  7:53 [PATCH net-next] xen-netback: correct length checks on hash copy_ops Paul Durrant
@ 2016-05-18  9:42 ` Wei Liu
  2016-05-18  9:42 ` Wei Liu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2016-05-18  9:42 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, Wei Liu, netdev

On Wed, May 18, 2016 at 08:53:01AM +0100, Paul Durrant wrote:
> The length checks on the grant table copy_ops for setting hash key and
> hash mapping are checking the local 'len' value which is correct in
> the case of the former but not the latter. This was picked up by
> static analysis checks.
> 
> This patch replaces checks of 'len' with 'copy_op.len' in both cases
> to correct the incorrect check, keep the two checks consistent, and to
> make it clear what the checks are for.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: Wei Liu <wei.liu2@citrix.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

> ---
>  drivers/net/xen-netback/hash.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c
> index 392e392..fb87cb3 100644
> --- a/drivers/net/xen-netback/hash.c
> +++ b/drivers/net/xen-netback/hash.c
> @@ -311,7 +311,7 @@ u32 xenvif_set_hash_key(struct xenvif *vif, u32 gref, u32 len)
>  	if (len > XEN_NETBK_MAX_HASH_KEY_SIZE)
>  		return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>  
> -	if (len != 0) {
> +	if (copy_op.len != 0) {
>  		gnttab_batch_copy(&copy_op, 1);
>  
>  		if (copy_op.status != GNTST_okay)
> @@ -359,7 +359,7 @@ u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
>  		if (mapping[off++] >= vif->num_queues)
>  			return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>  
> -	if (len != 0) {
> +	if (copy_op.len != 0) {
>  		gnttab_batch_copy(&copy_op, 1);
>  
>  		if (copy_op.status != GNTST_okay)
> -- 
> 2.1.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH net-next] xen-netback: correct length checks on hash copy_ops
  2016-05-18  7:53 [PATCH net-next] xen-netback: correct length checks on hash copy_ops Paul Durrant
  2016-05-18  9:42 ` Wei Liu
  2016-05-18  9:42 ` Wei Liu
@ 2016-05-20 17:51 ` David Miller
  2016-05-20 17:51 ` David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2016-05-20 17:51 UTC (permalink / raw)
  To: paul.durrant; +Cc: xen-devel, netdev, wei.liu2

From: Paul Durrant <paul.durrant@citrix.com>
Date: Wed, 18 May 2016 08:53:01 +0100

> The length checks on the grant table copy_ops for setting hash key and
> hash mapping are checking the local 'len' value which is correct in
> the case of the former but not the latter. This was picked up by
> static analysis checks.
> 
> This patch replaces checks of 'len' with 'copy_op.len' in both cases
> to correct the incorrect check, keep the two checks consistent, and to
> make it clear what the checks are for.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

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

* Re: [PATCH net-next] xen-netback: correct length checks on hash copy_ops
  2016-05-18  7:53 [PATCH net-next] xen-netback: correct length checks on hash copy_ops Paul Durrant
                   ` (2 preceding siblings ...)
  2016-05-20 17:51 ` David Miller
@ 2016-05-20 17:51 ` David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2016-05-20 17:51 UTC (permalink / raw)
  To: paul.durrant; +Cc: xen-devel, wei.liu2, netdev

From: Paul Durrant <paul.durrant@citrix.com>
Date: Wed, 18 May 2016 08:53:01 +0100

> The length checks on the grant table copy_ops for setting hash key and
> hash mapping are checking the local 'len' value which is correct in
> the case of the former but not the latter. This was picked up by
> static analysis checks.
> 
> This patch replaces checks of 'len' with 'copy_op.len' in both cases
> to correct the incorrect check, keep the two checks consistent, and to
> make it clear what the checks are for.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* [PATCH net-next] xen-netback: correct length checks on hash copy_ops
@ 2016-05-18  7:53 Paul Durrant
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Durrant @ 2016-05-18  7:53 UTC (permalink / raw)
  To: xen-devel, netdev; +Cc: Paul Durrant, Wei Liu

The length checks on the grant table copy_ops for setting hash key and
hash mapping are checking the local 'len' value which is correct in
the case of the former but not the latter. This was picked up by
static analysis checks.

This patch replaces checks of 'len' with 'copy_op.len' in both cases
to correct the incorrect check, keep the two checks consistent, and to
make it clear what the checks are for.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 drivers/net/xen-netback/hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c
index 392e392..fb87cb3 100644
--- a/drivers/net/xen-netback/hash.c
+++ b/drivers/net/xen-netback/hash.c
@@ -311,7 +311,7 @@ u32 xenvif_set_hash_key(struct xenvif *vif, u32 gref, u32 len)
 	if (len > XEN_NETBK_MAX_HASH_KEY_SIZE)
 		return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
 
-	if (len != 0) {
+	if (copy_op.len != 0) {
 		gnttab_batch_copy(&copy_op, 1);
 
 		if (copy_op.status != GNTST_okay)
@@ -359,7 +359,7 @@ u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
 		if (mapping[off++] >= vif->num_queues)
 			return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
 
-	if (len != 0) {
+	if (copy_op.len != 0) {
 		gnttab_batch_copy(&copy_op, 1);
 
 		if (copy_op.status != GNTST_okay)
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

end of thread, other threads:[~2016-05-20 17:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-18  7:53 [PATCH net-next] xen-netback: correct length checks on hash copy_ops Paul Durrant
2016-05-18  9:42 ` Wei Liu
2016-05-18  9:42 ` Wei Liu
2016-05-20 17:51 ` David Miller
2016-05-20 17:51 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2016-05-18  7:53 Paul Durrant

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.