From mboxrd@z Thu Jan 1 00:00:00 1970 From: NeilBrown Subject: [PATCH 04/13] security/selinux: check for LOOKUP_RCU in _follow_link. Date: Mon, 16 Mar 2015 15:43:19 +1100 Message-ID: <20150316044319.23648.82820.stgit@notabene.brown> References: <20150316043602.23648.52734.stgit@notabene.brown> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Al Viro Return-path: In-Reply-To: <20150316043602.23648.52734.stgit@notabene.brown> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Some of dentry_has_perm() is not rcu-safe, so if LOOKUP_RCU is set in selinux_inode_follow_link(), give up with -ECHILD. It is possible that dentry_has_perm could sometimes complete in RCU more, in which case the flag could be propagated further down the stack... Signed-off-by: NeilBrown --- security/selinux/hooks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index e3074e01f058..5d4de8cbfaa6 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2866,6 +2866,8 @@ static int selinux_inode_follow_link(struct dentry *dentry, int flags) { const struct cred *cred = current_cred(); + if (flags & LOOKUP_RCU) + return -ECHILD; return dentry_has_perm(cred, dentry, FILE__READ); }