Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3389333ybp; Sun, 6 Oct 2019 10:51:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxwSNoRk6LuQzTeO1YbsP8cTsm/cOmyr1YKCn6pRkElTT7/rsy/T5VDwFJ+tnsc/pd4j8i X-Received: by 2002:a17:907:40bc:: with SMTP id nu20mr20643337ejb.309.1570384310051; Sun, 06 Oct 2019 10:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384310; cv=none; d=google.com; s=arc-20160816; b=Zug9IeUYlVasUvcxtDrVfHkeHFa/QKPzvPs5svwocqxKX/0KnRokFnKFhYP8lMvDU9 jgBW4DzXamybItA4xfKF2iFwW1q2JpLoRgrUzkKQ4bAuGDM03twe/+UwsDh2EsM3QApZ nbj+r1z7VyZGCSXD/R5Npxofay+26JzV+GmQV9czkTUvqBn6BZEYEjFxlbOnQMfEzYXn JcWwBB1mlhoX2PUadM86SOCNb65hI6zyvjQSKII2FUbf7h5gqKSHsmOrYuGLysSbnUqR Vukchu6JcgIFCkS9alLMdaMVUs9epKG08zOuFO0SQmODsXccouwbO4OoI329cU/0apIc d97w== 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=ayvPO2K1j2F2CVmDynBeO4mCNbg9LpWfxCRDWMwByEQ=; b=e1omiA0G5b5scshvPuTk3e0vP6f9sY8yUfkBlJE3QKShsM02whE5iP9aNoxcwsbID2 F0pVal204JSlcsleDNny8+1G/0K0HKLWI8E2qGhnUS2hLattoWOqreefmsYW9YC70ceC jsINrSdCsFdVar5LFbNOL4v2Z8Uh6fEe9r1MQEdhvAcuwPvy6P6H/XwgMA6pIlXa1eYw 6ZanyKR383yS80nDf9LyTmszvNRoIHobTsNt9aVP8Uo90QsL8aK11Ad6HRTGsv1KCCWK E1hq4dn3aoENJskstK2Twv610Yp7id0iam/e0kY5DF7oHFe9/am1PN9ZzLvMGZy2Oao4 H5vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Q/p9H02V"; 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 a16si6167639ejb.54.2019.10.06.10.51.26; Sun, 06 Oct 2019 10:51:50 -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="Q/p9H02V"; 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 S1730907AbfJFRse (ORCPT + 99 others); Sun, 6 Oct 2019 13:48:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:43330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730545AbfJFRnY (ORCPT ); Sun, 6 Oct 2019 13:43:24 -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 C50B72087E; Sun, 6 Oct 2019 17:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383803; bh=F8RTzDc+fECkTRNigXyurxf3VNTlrsOpbjYpgckPm38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q/p9H02V3J4l2ajVCpMia0Y7rG3w/ztBGzZH2z1OcQmHCVcyW2w0+/Yrn9zRHx4tZ rRaOhI2rrNsQxExzmZaoYKyaW4ZAuQcqbiWdc9GeQZKTulfVprzF+Cx5xT6HaQyRsB Hf7hf4HbXPJ1Rg0CnVEG+3miPHr1CrpQN3FFb09M= 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.3 102/166] selinux: fix residual uses of current_security() for the SELinux blob Date: Sun, 6 Oct 2019 19:21:08 +0200 Message-Id: <20191006171222.124230285@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171212.850660298@linuxfoundation.org> References: <20191006171212.850660298@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 74dd46de01b6a..e755174647866 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