From 10e516109d7bb9863f1ca066a7e0842b9c7fbcb2 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 8 Dec 2015 21:44:18 -0500 Subject: [PATCH] LU-7530 mdt: Do not leak identity when no nodemap is present 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 Reviewed-on: http://review.whamcloud.com/17519 Tested-by: Jenkins Reviewed-by: Kit Westneat Reviewed-by: John L. Hammond --- lustre/mdt/mdt_lib.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index 6d03fee..574ea5e 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -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; -- 1.8.3.1