[openib-general] [PATCH] Opensm - modifying uninitialized memory

Yael Kalka yael at mellanox.co.il
Mon Nov 7 04:47:54 PST 2005


Hi Hal,

While running opensm with valgrind we found out that there is a
problem  with osm_req_set function. It clears the madw.data by size of
IB_SMP_DATA_SIZE, but the function doesn't require a payload of this
size. In osm_ucast_mgr there was a call to the function with a payload
of smaller size.
For fixing it - I've added a payload_size to the osm_req_set.
It seems more correct then to just fix the specific call in the
osm_ucast_mgr.
The attached patch fixes it.

Thanks,
Yael

Signed-off-by:  Yael Kalka <yael at mellanox.co.il>

Index: include/opensm/osm_req.h
===================================================================
--- include/opensm/osm_req.h	(revision 3975)
+++ include/opensm/osm_req.h	(working copy)
@@ -308,6 +308,7 @@ osm_req_set(
 	IN const osm_req_t* const p_req,
 	IN const osm_dr_path_t* const p_path,
 	IN const uint8_t* const p_payload,
+   IN const size_t payload_size,
 	IN const uint16_t attr_id,
 	IN const uint32_t attr_mod,
 	IN const cl_disp_msgid_t err_msg,
@@ -323,6 +324,9 @@ osm_req_set(
 *	p_payload
 *		[in] Pointer to the SMP payload to send.
 *
+*  payload_size
+*		[in] The size of the payload to be copied to the SMP data field.
+*
 *	attr_id
 *		[in] Attribute ID to request.
 *
Index: opensm/osm_state_mgr.c
===================================================================
--- opensm/osm_state_mgr.c	(revision 3975)
+++ opensm/osm_state_mgr.c	(working copy)
@@ -1667,6 +1667,7 @@ __osm_state_mgr_send_handover(
    status = osm_req_set( p_mgr->p_req,
                          osm_physp_get_dr_path_ptr
                          ( osm_port_get_default_phys_ptr( p_port ) ), payload,
+                         sizeof(payload),
                          IB_MAD_ATTR_SM_INFO, IB_SMINFO_ATTR_MOD_HANDOVER,
                          CL_DISP_MSGID_NONE, &context );
 
Index: opensm/osm_req.c
===================================================================
--- opensm/osm_req.c	(revision 3975)
+++ opensm/osm_req.c	(working copy)
@@ -210,6 +210,7 @@ osm_req_set(
   IN const osm_req_t* const p_req,
   IN const osm_dr_path_t* const p_path,
   IN const uint8_t* const p_payload,
+  IN const size_t payload_size,
   IN const uint16_t attr_id,
   IN const uint32_t attr_mod,
   IN const cl_disp_msgid_t err_msg,
@@ -286,7 +287,7 @@ osm_req_set(
     p_madw->context = *p_context;
 
   cl_memcpy( osm_madw_get_smp_ptr( p_madw )->data,
-             p_payload, IB_SMP_DATA_SIZE );
+             p_payload, payload_size );
 
   osm_vl15_post( p_req->p_vl15, p_madw );
 
Index: opensm/osm_mcast_mgr.c
===================================================================
--- opensm/osm_mcast_mgr.c	(revision 3975)
+++ opensm/osm_mcast_mgr.c	(working copy)
@@ -488,6 +488,7 @@ __osm_mcast_mgr_set_tbl(
     status = osm_req_set( p_mgr->p_req,
                           p_path,
                           (void*)block,
+                          sizeof(block),
                           IB_MAD_ATTR_MCAST_FWD_TBL,
                           cl_hton32( block_id_ho ),
                           CL_DISP_MSGID_NONE,
Index: opensm/osm_ucast_mgr.c
===================================================================
--- opensm/osm_ucast_mgr.c	(revision 3975)
+++ opensm/osm_ucast_mgr.c	(working copy)
@@ -830,6 +830,7 @@ __osm_ucast_mgr_set_table(
   status = osm_req_set( p_mgr->p_req,
                         p_path,
                         (uint8_t*)&si,
+                        sizeof(si),
                         IB_MAD_ATTR_SWITCH_INFO,
                         0,
                         CL_DISP_MSGID_NONE,
@@ -864,6 +865,7 @@ __osm_ucast_mgr_set_table(
     status = osm_req_set( p_mgr->p_req,
                           p_path,
                           block,
+                          sizeof(block),
                           IB_MAD_ATTR_LIN_FWD_TBL,
                           cl_hton32( block_id_ho ),
                           CL_DISP_MSGID_NONE,
Index: opensm/osm_link_mgr.c
===================================================================
--- opensm/osm_link_mgr.c	(revision 3975)
+++ opensm/osm_link_mgr.c	(working copy)
@@ -355,6 +355,7 @@ osm_link_mgr_set_physp_pi(
     status = osm_req_set( p_mgr->p_req,
                           osm_physp_get_dr_path_ptr( p_physp ),
                           payload,
+                          sizeof(payload),
                           IB_MAD_ATTR_PORT_INFO,
                           cl_hton32(port_num),
                           CL_DISP_MSGID_NONE,
Index: opensm/osm_sw_info_rcv.c
===================================================================
--- opensm/osm_sw_info_rcv.c	(revision 3975)
+++ opensm/osm_sw_info_rcv.c	(working copy)
@@ -84,6 +84,7 @@ __osm_si_rcv_clear_sc_bit(
   status = osm_req_set( p_rcv->p_req,
                         osm_node_get_any_dr_path_ptr( p_node ),
                         payload,
+                        sizeof(payload),
                         IB_MAD_ATTR_SWITCH_INFO,
                         0,
                         CL_DISP_MSGID_NONE,
Index: opensm/osm_lid_mgr.c
===================================================================
--- opensm/osm_lid_mgr.c	(revision 3975)
+++ opensm/osm_lid_mgr.c	(working copy)
@@ -1154,6 +1154,7 @@ __osm_lid_mgr_set_physp_pi(
     status = osm_req_set( p_mgr->p_req,
                           osm_physp_get_dr_path_ptr( p_physp ),
                           payload,
+                          sizeof(payload),
                           IB_MAD_ATTR_PORT_INFO,
                           cl_hton32(osm_physp_get_port_num( p_physp )),
                           CL_DISP_MSGID_NONE,




More information about the general mailing list