From patchwork Fri Jul 28 20:21:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 9869407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D81776035E for ; Fri, 28 Jul 2017 20:31:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7D43288E7 for ; Fri, 28 Jul 2017 20:31:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC7D0288F1; Fri, 28 Jul 2017 20:31:59 +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=-6.9 required=2.0 tests=BAYES_00,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 4599828909 for ; Fri, 28 Jul 2017 20:31:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752757AbdG1Ubj (ORCPT ); Fri, 28 Jul 2017 16:31:39 -0400 Received: from mx61.netapp.com ([216.240.31.181]:5252 "EHLO mx61.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752710AbdG1Ubi (ORCPT ); Fri, 28 Jul 2017 16:31:38 -0400 X-Greylist: delayed 567 seconds by postgrey-1.27 at vger.kernel.org; Fri, 28 Jul 2017 16:31:33 EDT X-IronPort-AV: E=Sophos;i="5.40,427,1496127600"; d="scan'208";a="11945202" Received: from vmwexchts04-prd.hq.netapp.com ([10.122.105.32]) by mx61-out.netapp.com with ESMTP; 28 Jul 2017 12:37:50 -0700 Received: from smtp1.corp.netapp.com (10.57.156.124) by VMWEXCHTS04-PRD.hq.netapp.com (10.122.105.32) with Microsoft SMTP Server id 15.0.1210.3; Fri, 28 Jul 2017 13:22:03 -0700 Received: from localhost.localdomain.localdomain (dros-16.vpn.netapp.com [10.55.79.21]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id v6SKM1la007987; Fri, 28 Jul 2017 13:22:03 -0700 (PDT) From: To: CC: , , , , Andy Adamson Subject: [PATCH Version 6 01/12] SELINUX export security_current_sid_to_context Date: Fri, 28 Jul 2017 16:21:47 -0400 Message-ID: <1501273318-14200-2-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1501273318-14200-1-git-send-email-andros@netapp.com> References: <1501273318-14200-1-git-send-email-andros@netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andy Adamson RPCSEC_GSS Version 3 label assertions require the client thread sid in string context form, and so needs this interface or one like it. Signed-off-by: Andy Adamson --- include/linux/selinux.h | 7 +++++++ security/selinux/hooks.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/selinux.h b/include/linux/selinux.h index 44f4596..e82a4ba 100644 --- a/include/linux/selinux.h +++ b/include/linux/selinux.h @@ -24,12 +24,19 @@ * selinux_is_enabled - is SELinux enabled? */ bool selinux_is_enabled(void); +int security_current_sid_to_context(char **scontext, u32 *scontext_len); #else static inline bool selinux_is_enabled(void) { return false; } + +static inline int +security_current_sid_to_context(char **scontext, u32 *scontext_len) +{ + return -EINVAL; +} #endif /* CONFIG_SECURITY_SELINUX */ #endif /* _LINUX_SELINUX_H */ diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 819fd68..ba6974b 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -6516,3 +6516,13 @@ int selinux_disable(void) return 0; } #endif + +int security_current_sid_to_context(char **scontext, u32 *scontext_len) +{ + const struct task_security_struct *ts = current_security(); + + if (!selinux_enabled) + return -EINVAL; + return security_sid_to_context(ts->sid, scontext, scontext_len); +} +EXPORT_SYMBOL_GPL(security_current_sid_to_context);