Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3392211ybp; Sun, 6 Oct 2019 10:56:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzD84JEGt8H5t+j0Tcu2ySEDLqPnzfv2o4SWBoIWv6w6rIpE/5La4ERlokmJqooTQBwWEJ3 X-Received: by 2002:a17:906:5c16:: with SMTP id e22mr21138549ejq.105.1570384567315; Sun, 06 Oct 2019 10:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384567; cv=none; d=google.com; s=arc-20160816; b=TPLzCm0F00pm8lT2JrZ32N7JyvjlEhPbIkTHNvnJMIuSj38KRMWmR47ZvNehyG6lYN Qhzq/Ad7uSAaqaosmTkHS1ZD3sR41FWypvs0VCTFXPbT93Mqfv5q92PET8OCYFl6Aks2 D/0MdpZgm7x+88SR5md0wBOyMh3G3nsUDhfOBNBYvSI3r8FsPYgyY0X54VMOp4S+A4xA xR3Cc2Y6rCmDUr3Ee3zkZ7RHkR9kxpBu4LIQxBC2q+Epva6e59lhvi65pmRfnJ26RZ/C p0P49bCIFqWVBJhuCIlvbi0Clc3hR/ipWFKi/rHvDSLA0/CJI6TyzVqc0AOvqOAOXT8J cFjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hDHOvdTu8wjxx7FufHEwgGSS8TCnS47CHLoYxt/NRII=; b=shP7XsI8quCRvTRC0/BAdsUf4h1DLu5qRtWtGqbjwkQa89vH17T81eDym5/86O0b87 tN6VLLUmnmx8D/JR08OOkb45rGwkoGcQbbIPEGC3hJIxabexUkHIAdS/MPlejrMLuo2L ZT2VyXgcKmvsLQuMfcIvlXMt7rNRTgn+RSwAIus70+esbdx1cGe0qfjiC0BX+tAFED/Y aFXGsnCnGkhjLogjL7m65dcFun1D5oA6ILZnkPnanJOt5Lq4Gras94HVkXY+tpPdPJkf wrmzoLWud0bl48Rv3Y3524A7d3DZSNCarOScyjB9jtIM464vSELOwZfqqGHWb9CYx85n hCZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bNlq86Bk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t37si8071465edd.25.2019.10.06.10.55.43; Sun, 06 Oct 2019 10:56:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bNlq86Bk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730414AbfJFRhe (ORCPT + 99 others); Sun, 6 Oct 2019 13:37:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:36438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730446AbfJFRh1 (ORCPT ); Sun, 6 Oct 2019 13:37:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D99202053B; Sun, 6 Oct 2019 17:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383446; bh=M7f/VWIS3/HVL4XSOEzhDN9zeadlxe+WeHhKS89VrqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bNlq86BkNIshrxYRHV5SfjHecOL5CI8cgpIydbdlpFXce0hzSEKKRf2uPNqbfTFDh XUKTZJl8fRq7T6h7ysV3oAukz9x64TRqA3lrxmQAduQJsqJryPWAvsFBgf0w5aTIYW Yxg1A8jOfuHJha1y1fh21zdvHzHwQWa1ZOK7JIvw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Smalley , Casey Schaufler , James Morris , Paul Moore , Sasha Levin Subject: [PATCH 5.2 107/137] selinux: fix residual uses of current_security() for the SELinux blob Date: Sun, 6 Oct 2019 19:21:31 +0200 Message-Id: <20191006171217.886557967@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171209.403038733@linuxfoundation.org> References: <20191006171209.403038733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephen Smalley [ Upstream commit 169ce0c081cd85f78388bb6c1638c1ad7b81bde7 ] We need to use selinux_cred() to fetch the SELinux cred blob instead of directly using current->security or current_security(). There were a couple of lingering uses of current_security() in the SELinux code that were apparently missed during the earlier conversions. IIUC, this would only manifest as a bug if multiple security modules including SELinux are enabled and SELinux is not first in the lsm order. After this change, there appear to be no other users of current_security() in-tree; perhaps we should remove it altogether. Fixes: bbd3662a8348 ("Infrastructure management of the cred security blob") Signed-off-by: Stephen Smalley Acked-by: Casey Schaufler Reviewed-by: James Morris Signed-off-by: Paul Moore Signed-off-by: Sasha Levin --- security/selinux/hooks.c | 2 +- security/selinux/include/objsec.h | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 3ec7ac70c3130..c106167423a12 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3403,7 +3403,7 @@ static int selinux_inode_copy_up_xattr(const char *name) static int selinux_kernfs_init_security(struct kernfs_node *kn_dir, struct kernfs_node *kn) { - const struct task_security_struct *tsec = current_security(); + const struct task_security_struct *tsec = selinux_cred(current_cred()); u32 parent_sid, newsid, clen; int rc; char *context; diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h index 91c5395dd20c2..586b7abd0aa73 100644 --- a/security/selinux/include/objsec.h +++ b/security/selinux/include/objsec.h @@ -37,16 +37,6 @@ struct task_security_struct { u32 sockcreate_sid; /* fscreate SID */ }; -/* - * get the subjective security ID of the current task - */ -static inline u32 current_sid(void) -{ - const struct task_security_struct *tsec = current_security(); - - return tsec->sid; -} - enum label_initialized { LABEL_INVALID, /* invalid or not initialized */ LABEL_INITIALIZED, /* initialized */ @@ -185,4 +175,14 @@ static inline struct ipc_security_struct *selinux_ipc( return ipc->security + selinux_blob_sizes.lbs_ipc; } +/* + * get the subjective security ID of the current task + */ +static inline u32 current_sid(void) +{ + const struct task_security_struct *tsec = selinux_cred(current_cred()); + + return tsec->sid; +} + #endif /* _SELINUX_OBJSEC_H_ */ -- 2.20.1