Whamcloud - gitweb
LU-7530 mdt: Do not leak identity when no nodemap is present 19/17519/5
authorOleg Drokin <oleg.drokin@intel.com>
Wed, 9 Dec 2015 02:44:18 +0000 (21:44 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 13 Dec 2015 20:56:49 +0000 (20:56 +0000)
It looks like sometimes nodemap structure on the export is not there
due to a race in old_init_ucred_common.
Move the nodemap check to the start not to leak identity reference
in such a case.

The bug was introduced in commit 2aea469a3a6e214d from LU-7199

Also silence the warning as there's nothing sysadmins could do when
it happens.

Change-Id: I5329ccb16201a71a263eb586e3a486b26ff238db
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-on: http://review.whamcloud.com/17519
Tested-by: Jenkins
Reviewed-by: Kit Westneat <kit.westneat@gmail.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/mdt/mdt_lib.c

index 6d03fee..574ea5e 100644 (file)
@@ -472,6 +472,13 @@ static int old_init_ucred_common(struct mdt_thread_info *info,
        struct lu_nodemap       *nodemap =
                info->mti_exp->exp_target_data.ted_nodemap;
 
+       if (nodemap == NULL) {
+               CDEBUG(D_SEC, "%s: cli %s/%p nodemap not set.\n",
+                      mdt2obd_dev(mdt)->obd_name,
+                      info->mti_exp->exp_client_uuid.uuid, info->mti_exp);
+               RETURN(-EACCES);
+       }
+
        if (!is_identity_get_disabled(mdt->mdt_identity_cache)) {
                identity = mdt_identity_get(mdt->mdt_identity_cache,
                                            uc->uc_fsuid);
@@ -487,12 +494,7 @@ static int old_init_ucred_common(struct mdt_thread_info *info,
        }
        uc->uc_identity = identity;
 
-       if (nodemap == NULL) {
-               CERROR("%s: cli %s/%p nodemap not set.\n",
-                     mdt2obd_dev(mdt)->obd_name,
-                     info->mti_exp->exp_client_uuid.uuid, info->mti_exp);
-               RETURN(-EACCES);
-       } else if (uc->uc_o_uid == nodemap->nm_squash_uid) {
+       if (uc->uc_o_uid == nodemap->nm_squash_uid) {
                uc->uc_fsuid = nodemap->nm_squash_uid;
                uc->uc_fsgid = nodemap->nm_squash_gid;
                uc->uc_cap = 0;