From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753554AbbCPErN (ORCPT ); Mon, 16 Mar 2015 00:47:13 -0400 Received: from cantor2.suse.de ([195.135.220.15]:56188 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751638AbbCPEoe (ORCPT ); Mon, 16 Mar 2015 00:44:34 -0400 From: NeilBrown To: Al Viro Date: Mon, 16 Mar 2015 15:43:19 +1100 Subject: [PATCH 04/13] security/selinux: check for LOOKUP_RCU in _follow_link. Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <20150316044319.23648.82820.stgit@notabene.brown> In-Reply-To: <20150316043602.23648.52734.stgit@notabene.brown> References: <20150316043602.23648.52734.stgit@notabene.brown> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@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); }