diff mbox

IB/core: memset attr variable to prevent garbage data

Message ID 45be0302-ea5d-4f35-892a-47617edd27ec@CMEXHTCAS1.ad.emulex.com (mailing list archive)
State Superseded
Headers show

Commit Message

Devesh Sharma Sept. 26, 2014, 10:19 a.m. UTC
During create-ah from user land, uverbs is sending
garbage data in attr.dmac and attr.vlan_id. This
patch prevents the same.

Signed-off-by: Devesh Sharma <devesh.sharma@emulex.com>
---
 drivers/infiniband/core/uverbs_cmd.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Yann Droneaud Sept. 26, 2014, 12:12 p.m. UTC | #1
Hi,

Le vendredi 26 septembre 2014 à 15:49 +0530, Devesh Sharma a écrit :
> During create-ah from user land, uverbs is sending
> garbage data in attr.dmac and attr.vlan_id. This
> patch prevents the same.
> 
> Signed-off-by: Devesh Sharma <devesh.sharma@emulex.com>
> ---
>  drivers/infiniband/core/uverbs_cmd.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index 0600c50..0b1ce71 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -2508,6 +2508,7 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
>  		goto err;
>  	}
>  
> +	memset(&attr, 0, sizeof(attr));

It's a bit overkill.

>  	attr.dlid 	       = cmd.attr.dlid;
>  	attr.sl 	       = cmd.attr.sl;
>  	attr.src_path_bits     = cmd.attr.src_path_bits;

Just do

         memset(attr.dmac, 0, sizeof(attr.dmac));
         attr.vlan_id = 0;

In the spirit of
<http://marc.info/?i=1409661154-13718-1-git-send-email-ogerlitz@mellanox.com>,
please add the following to the commit message:

Fixes: dd5f03beb4f7 ('IB/core: Ethernet L2 attributes in verbs/cm
structures')
Cc: Matan Barak <matanb@mellanox.com>
Cc: Or Gerlitz <ogerlitz@mellanox.com>
diff mbox

Patch

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 0600c50..0b1ce71 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2508,6 +2508,7 @@  ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
 		goto err;
 	}
 
+	memset(&attr, 0, sizeof(attr));
 	attr.dlid 	       = cmd.attr.dlid;
 	attr.sl 	       = cmd.attr.sl;
 	attr.src_path_bits     = cmd.attr.src_path_bits;