From patchwork Tue May 7 04:41:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongjie Fang X-Patchwork-Id: 10932277 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C4AB1390 for ; Tue, 7 May 2019 04:57:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7146B286DF for ; Tue, 7 May 2019 04:57:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63DA5287D4; Tue, 7 May 2019 04:57:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7BCB286DF for ; Tue, 7 May 2019 04:57:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725867AbfEGE5z (ORCPT ); Tue, 7 May 2019 00:57:55 -0400 Received: from asrmicro.com ([210.13.118.86]:37981 "EHLO mail2012.asrmicro.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbfEGE5z (ORCPT ); Tue, 7 May 2019 00:57:55 -0400 X-Greylist: delayed 914 seconds by postgrey-1.27 at vger.kernel.org; Tue, 07 May 2019 00:57:54 EDT Received: from localhost (10.1.170.159) by mail2012.asrmicro.com (10.1.24.123) with Microsoft SMTP Server (TLS) id 15.0.847.32; Tue, 7 May 2019 12:42:01 +0800 From: hongjiefang To: , , CC: , hongjiefang Subject: [PATCH] fscrypt: don't set policy for a dead directory Date: Tue, 7 May 2019 12:41:48 +0800 Message-ID: <1557204108-29048-1-git-send-email-hongjiefang@asrmicro.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.1.170.159] X-ClientProxiedBy: mail2012.asrmicro.com (10.1.24.123) To mail2012.asrmicro.com (10.1.24.123) Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP if the directory had been removed, should not set policy for it. Signed-off-by: hongjiefang --- fs/crypto/policy.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index bd7eaf9..82900a4 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -77,6 +77,12 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg) inode_lock(inode); + /* don't set policy for a dead directory */ + if (IS_DEADDIR(inode)) { + ret = -ENOENT; + goto deaddir_out; + } + ret = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx)); if (ret == -ENODATA) { if (!S_ISDIR(inode->i_mode)) @@ -96,6 +102,7 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg) ret = -EEXIST; } +deaddir_out: inode_unlock(inode); mnt_drop_write_file(filp);