From patchwork Thu Jul 2 00:04:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11637597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B85E6C1 for ; Thu, 2 Jul 2020 00:05:52 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E832F2077D for ; Thu, 2 Jul 2020 00:05:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E832F2077D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 2B45721FF31; Wed, 1 Jul 2020 17:05:27 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 56FF721FC03 for ; Wed, 1 Jul 2020 17:05:09 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 7872C46B; Wed, 1 Jul 2020 20:05:02 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 76CCE2B6; Wed, 1 Jul 2020 20:05:02 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Wed, 1 Jul 2020 20:04:55 -0400 Message-Id: <1593648298-10571-16-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1593648298-10571-1-git-send-email-jsimmons@infradead.org> References: <1593648298-10571-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 15/18] lustre: llite: don't hold inode_lock for security notify X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Boyko , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Alexander Boyko With selinux enabled client has a dead lock which leads to client eviction from MDS. 1 thread 2 thread do file open do stat inode_lock(parend dir) got LDLM_PR(parent dir) enqueue LDLM_CW(parent dir) waits on inode_lock to notify security waits timeout on enqueue and client eviction because client didn't cancel a LDLM_PR lock security_inode_notifysecctx()->selinux_inode_notifysecctx()-> selinux_inode_setsecurity() The call of selinux_inode_setsecurity doesn't need to hold inode_lock. Fixes: f4d3cf7642 ("lustre: llite: set sec ctx on client's inode at create time") Cray-bug-id: LUS-8924 WC-bug-id: https://jira.whamcloud.com/browse/LU-13617 Lustre-commit: f87359b51f61a ("LU-13617 llite: don't hold inode_lock for security notify") Signed-off-by: Alexander Boyko Reviewed-on: https://review.whamcloud.com/38792 Reviewed-by: Sebastien Buisson Reviewed-by: Andrew Perepechko Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/dir.c | 6 ++++-- fs/lustre/llite/namei.c | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c index 463c5d7..e3305f7 100644 --- a/fs/lustre/llite/dir.c +++ b/fs/lustre/llite/dir.c @@ -489,11 +489,13 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump, dentry.d_inode = inode; if (sbi->ll_flags & LL_SBI_FILE_SECCTX) { - inode_lock(inode); + /* no need to protect selinux_inode_setsecurity() by + * inode_lock. Taking it would lead to a client deadlock + * LU-13617 + */ err = security_inode_notifysecctx(inode, op_data->op_file_secctx, op_data->op_file_secctx_size); - inode_unlock(inode); } else { err = ll_inode_init_security(&dentry, inode, parent); } diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c index 2353a8f..251d6be 100644 --- a/fs/lustre/llite/namei.c +++ b/fs/lustre/llite/namei.c @@ -659,10 +659,12 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, } if (secctx && secctxlen != 0) { - inode_lock(inode); + /* no need to protect selinux_inode_setsecurity() by + * inode_lock. Taking it would lead to a client deadlock + * LU-13617 + */ rc = security_inode_notifysecctx(inode, secctx, secctxlen); - inode_unlock(inode); if (rc) CWARN("cannot set security context for " DFID ": rc = %d\n", PFID(ll_inode2fid(inode)), rc); @@ -1198,13 +1200,15 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, return PTR_ERR(inode); if ((ll_i2sbi(inode)->ll_flags & LL_SBI_FILE_SECCTX) && secctx) { - inode_lock(inode); /* must be done before d_instantiate, because it calls * security_d_instantiate, which means a getxattr if security * context is not set yet */ + /* no need to protect selinux_inode_setsecurity() by + * inode_lock. Taking it would lead to a client deadlock + * LU-13617 + */ rc = security_inode_notifysecctx(inode, secctx, secctxlen); - inode_unlock(inode); if (rc) return rc; } @@ -1370,15 +1374,17 @@ static int ll_new_node(struct inode *dir, struct dentry *dentry, goto err_exit; if (sbi->ll_flags & LL_SBI_FILE_SECCTX) { - inode_lock(inode); /* must be done before d_instantiate, because it calls * security_d_instantiate, which means a getxattr if security * context is not set yet */ + /* no need to protect selinux_inode_setsecurity() by + * inode_lock. Taking it would lead to a client deadlock + * LU-13617 + */ err = security_inode_notifysecctx(inode, op_data->op_file_secctx, op_data->op_file_secctx_size); - inode_unlock(inode); if (err) goto err_exit; }