[LU-7944] Suspicious dereference of pointer before NULL check in mdt_obd_connect() Created: 29/Mar/16  Updated: 13/May/18  Resolved: 13/May/18

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Dmitry Eremin (Inactive) Assignee: WC Triage
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates LU-8182 Suspicious code in mdt_obd_connect Resolved
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

Suspicious dereference of pointer 'data' before NULL check at line 5174

  • An event which alters the program's state, leading to the defect
    mdt_handler.c:5163: 'data' is dereferenced.
  • An event which alters the program's state, leading to the defect
    mdt_handler.c:5174: 'data' is checked for NULL.
5144		static int mdt_obd_connect(const struct lu_env *env,
5145					   struct obd_export **exp, struct obd_device *obd,
5146					   struct obd_uuid *cluuid,
5147					   struct obd_connect_data *data,
5148					   void *localdata)
5149		{
5150			struct obd_export	*lexp;
5151			struct lustre_handle	conn = { 0 };
5152			struct mdt_device	*mdt;
5153			int			 rc;
5154			lnet_nid_t		*client_nid = localdata;
5155			ENTRY;
5156		 
5157			LASSERT(env != NULL);
5158			if (!exp || !obd || !cluuid)
5159				RETURN(-EINVAL);
5160		 
5161			mdt = mdt_dev(obd->obd_lu_dev);
5162		 
5163			if ((data->ocd_connect_flags & OBD_CONNECT_MDS_MDS) &&
5164			    !(data->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT)) {...}
5168		 
5169			/*
5170			 * first, check whether the stack is ready to handle requests
5171			 * XXX: probably not very appropriate method is used now
5172			 *      at some point we should find a better one
5173			 */
5174			if (!test_bit(MDT_FL_SYNCED, &mdt->mdt_state) && data != NULL &&
5175			    !(data->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT) &&
5176			    !(data->ocd_connect_flags & OBD_CONNECT_MDS_MDS)) {


 Comments   
Comment by Arshad Hussain [ 13/May/18 ]

While attempting to provide a fix for this. I noticed that this bug is already fixed by Fan's patch https://review.whamcloud.com/#/c/20391/2

Thanks
Arshad

Comment by Peter Jones [ 13/May/18 ]

Thanks Arshad. Closing as a duplicate of LU-8182

Generated at Sat Feb 10 02:13:16 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.