From: Saeed Mahameed Date: Sun, 13 Apr 2014 08:58:36 +0000 (+0300) Subject: mlx4_vnic: fix potential data corruption in sprintf X-Git-Tag: v4.1.12-92~293^2~1^2~38 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c4c441fb17a1af34ca77401f6c4982da19b0882d;p=users%2Fjedix%2Flinux-maple.git mlx4_vnic: fix potential data corruption in sprintf Signed-off-by: Saeed Mahameed (Ported from Mellanox OFED 2.4) Signed-off-by: Mukesh Kacker --- diff --git a/drivers/net/ethernet/mellanox/mlx4_vnic/vnic.h b/drivers/net/ethernet/mellanox/mlx4_vnic/vnic.h index 03c12e93d211a..afdb7b73c2d48 100644 --- a/drivers/net/ethernet/mellanox/mlx4_vnic/vnic.h +++ b/drivers/net/ethernet/mellanox/mlx4_vnic/vnic.h @@ -155,6 +155,7 @@ extern struct ib_sa_client vnic_sa_client; #define VNIC_SYSFS_FLEN (VNIC_NAME_LEN * 2) /* SYSFS file name len, allow pre/suffix (32)*/ #define VNIC_SYSFS_LLEN 64 #define VNIC_VENDOR_LEN 8 +#define DISCOVER_NAME_LEN (VNIC_DESC_LEN + 5) /* VNIC_DESC_LEN + pkey len */ #define GID_LEN 16 #define GUID_LEN 8 #define IPV4_LEN 4 @@ -934,7 +935,7 @@ struct pkt_rcv_list { }; struct fip_discover { - char name[VNIC_NAME_LEN]; + char name[DISCOVER_NAME_LEN]; struct vnic_port *port; struct list_head discover_list; spinlock_t lock; diff --git a/drivers/net/ethernet/mellanox/mlx4_vnic/vnic_fip_discover.c b/drivers/net/ethernet/mellanox/mlx4_vnic/vnic_fip_discover.c index 3b87a44266373..86f5cc78ce835 100644 --- a/drivers/net/ethernet/mellanox/mlx4_vnic/vnic_fip_discover.c +++ b/drivers/net/ethernet/mellanox/mlx4_vnic/vnic_fip_discover.c @@ -231,7 +231,8 @@ int fip_discover_init(struct vnic_port *port, struct fip_discover *discover, discover->pkey = pkey; INIT_LIST_HEAD(&discover->gw_list); init_rwsem(&discover->l_rwsem); - sprintf(discover->name, "%s_P%x", port->name, discover->pkey); + snprintf(discover->name, DISCOVER_NAME_LEN, + "%s_P%x", port->name, discover->pkey); } INIT_LIST_HEAD(&discover->hadmin_cache); vnic_mcast_root_init(&discover->mcast_tree);