From patchwork Thu Feb 28 22:43:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 10834187 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 6C5F91908 for ; Thu, 28 Feb 2019 22:44:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DA25290F8 for ; Thu, 28 Feb 2019 22:44:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B9F02FB9B; Thu, 28 Feb 2019 22:44:43 +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=unavailable 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 3AC412FB81 for ; Thu, 28 Feb 2019 22:44:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730742AbfB1Wog (ORCPT ); Thu, 28 Feb 2019 17:44:36 -0500 Received: from sonic301-10.consmr.mail.bf2.yahoo.com ([74.6.129.49]:36327 "EHLO sonic301-10.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730867AbfB1Wof (ORCPT ); Thu, 28 Feb 2019 17:44:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1551393874; bh=Aom2uBgZ2TgbnkpBYLBmQEguXBd2kkH61KqQlvE1qx8=; h=From:To:Cc:Subject:Date:In-Reply-To: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1xYkKZMiuUW3msIIcv65A31MnsS0WxpjpJelgMwbL9inK GPwKZ5lgUac_RS5_PGy2qEuZ8vsn6zSnYFdsfchJIbwGPTYs4mGJlqCLF.WdtjBqgA5iHP66Rwo9 .EqYzU4rGK8vKljHZnOLQQNag.dyB2z7n8v.p2DanwZgUf9s3YwYqPYgMHleTg.jHPhTtc6_PhDJ aDDJ2EwZhMz1SDEu3ZgjNVMF6._lufdPUjYKSy8AXRHkoTNwP9bnjXYbP0wAgLCnjzok7vF3ijsA 6GKQiJuWQZ6RSDCHODBVZR7MxFTj63lmFNhUSV0P_wYwVQkn4xiHJfexK0ppoIo1acaxAptcwoXP s86R1PW.5vGom0sEvLm1i8LAda7BGAbUxazfJicDItm7hCw63jacO8i0QFEL2fft8u_Md47q.v96 .5td.XlDraikotXy7SImAbH4TixWT6x7H48kRQbDXtiNPGSmXICZ.tcBC Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.bf2.yahoo.com with HTTP; Thu, 28 Feb 2019 22:44:34 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO localhost.localdomain) ([67.169.65.224]) by smtp430.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 41bc5dec9e4ecaa87e9a199cc17828e6; Thu, 28 Feb 2019 22:44:31 +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 90/97] Netlabel: Return the labeling type on socket Date: Thu, 28 Feb 2019 14:43:49 -0800 Message-Id: <20190228224356.2608-21-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 Change netlbl_skbuff_setattr() to return the labeling type of the domain. This allows the labeling types to be compared when two LSMs want to determine how a socket should be used. Signed-off-by: Casey Schaufler --- net/netlabel/netlabel_kapi.c | 7 ++++++- security/selinux/netlabel.c | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c index 2bd765290550..1d362a38dd05 100644 --- a/net/netlabel/netlabel_kapi.c +++ b/net/netlabel/netlabel_kapi.c @@ -1278,7 +1278,8 @@ void netlbl_req_delattr(struct request_sock *req) * * Description: * Attach the correct label to the given packet using the security attributes - * specified in @secattr. Returns zero on success, negative values on failure. + * specified in @secattr. Returns the NLTYPE on success, negative values on + * failure. * */ int netlbl_skbuff_setattr(struct sk_buff *skb, @@ -1315,6 +1316,8 @@ int netlbl_skbuff_setattr(struct sk_buff *skb, default: ret_val = -ENOENT; } + if (ret_val == 0) + ret_val = entry->type; break; #if IS_ENABLED(CONFIG_IPV6) case AF_INET6: @@ -1338,6 +1341,8 @@ int netlbl_skbuff_setattr(struct sk_buff *skb, default: ret_val = -ENOENT; } + if (ret_val == 0) + ret_val = entry->type; break; #endif /* IPv6 */ default: diff --git a/security/selinux/netlabel.c b/security/selinux/netlabel.c index ca47c99f964a..b6eede4406bd 100644 --- a/security/selinux/netlabel.c +++ b/security/selinux/netlabel.c @@ -266,6 +266,8 @@ int selinux_netlbl_skbuff_setsid(struct sk_buff *skb, } rc = netlbl_skbuff_setattr(skb, family, secattr); + if (rc > 0) + rc = 0; skbuff_setsid_return: if (secattr == &secattr_storage)