From patchwork Thu Feb 28 22:43:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 10834141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2D9C1390 for ; Thu, 28 Feb 2019 22:44:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D31B52FA84 for ; Thu, 28 Feb 2019 22:44:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C74802FB96; Thu, 28 Feb 2019 22:44:27 +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,DKIM_SIGNED, DKIM_VALID,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 5C8102FA84 for ; Thu, 28 Feb 2019 22:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729976AbfB1Wo0 (ORCPT ); Thu, 28 Feb 2019 17:44:26 -0500 Received: from sonic302-10.consmr.mail.bf2.yahoo.com ([74.6.135.49]:43999 "EHLO sonic302-10.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729874AbfB1Wo0 (ORCPT ); Thu, 28 Feb 2019 17:44:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1551393864; bh=HtMHoChzx596drToVKA+SEbhFoEB1xjjcsaTIP+e+fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject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L9zziNDTa.fDj4o_rzFqM7101kA NpuvFlctp0rTO_Z7mnRZTYZHzOmueHl8N_ES9tokbtGrb4pmFd7miDareHE6MT3cMAf7zsqyKEIw acbSMFCjwBRUab9RTAU2QHx4R4ps5bPTeT7RRXAjroOasclUTG2m31P2nazLVU0yhmJxV3Djp7Er lSu4MpXPqKM9upHJvX5Px3IcLmuMNXmeQ36IiZJa7KQ1cQW8Gq2PwVv33czU5bbRlPNwu0GOFW_0 HIN0GBfAKGHpm7k5idlNT_jQGugsxbog7gsrITa8ERFAKkOEhVCLqlPNLCodCh._KdznqCdEUjQ8 lIQsas2ShDYZAMvMdf2v.5nOI.MrskRBCDokgCbv2hYAdX9Nsx5kA8u5vQMaQM0i_ESY2_CtTOp1 IM.FVgZlxPgAXKxrS_lyeLbiMVLdgIJbQmuQ6b_g43LaOOEsZcqms9gc- Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.bf2.yahoo.com with HTTP; Thu, 28 Feb 2019 22:44:24 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO localhost.localdomain) ([67.169.65.224]) by smtp415.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 46c3ca42412e81058eafbaa96f791691; Thu, 28 Feb 2019 22:44:19 +0000 (UTC) From: Casey Schaufler To: jmorris@namei.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Cc: keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, paul@paul-moore.com Subject: [PATCH 82/97] Smack: Fix setting of the CIPSO MLS_CAT flags Date: Thu, 28 Feb 2019 14:43:41 -0800 Message-Id: <20190228224356.2608-13-casey@schaufler-ca.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190228224356.2608-1-casey@schaufler-ca.com> References: <20190228224356.2608-1-casey@schaufler-ca.com> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Don't tell CIPSO that a netlabel created by Smack has categories set whenit doesn't. Signed-off-by: Casey Schaufler --- security/smack/smack_access.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c index 0764bb85daee..5fe5c6799b27 100644 --- a/security/smack/smack_access.c +++ b/security/smack/smack_access.c @@ -494,8 +494,8 @@ int smk_netlbl_mls(int level, char *catset, struct netlbl_lsm_secattr *sap, int cat; int rc; int byte; + bool has = false; - sap->flags |= NETLBL_SECATTR_MLS_CAT; sap->attr.mls.lvl = level; sap->attr.mls.cat = NULL; @@ -503,6 +503,7 @@ int smk_netlbl_mls(int level, char *catset, struct netlbl_lsm_secattr *sap, for (m = 0x80; m != 0; m >>= 1, cat++) { if ((m & *cp) == 0) continue; + has = true; rc = netlbl_catmap_setbit(&sap->attr.mls.cat, cat, GFP_KERNEL); if (rc < 0) { @@ -511,6 +512,9 @@ int smk_netlbl_mls(int level, char *catset, struct netlbl_lsm_secattr *sap, } } + if (has) + sap->flags |= NETLBL_SECATTR_MLS_CAT; + return 0; }