From patchwork Thu Feb 28 22:43:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 10834175 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 BE7191880 for ; Thu, 28 Feb 2019 22:44:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACF512FB90 for ; Thu, 28 Feb 2019 22:44:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A15D92FB99; Thu, 28 Feb 2019 22:44:42 +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 481262FA84 for ; Thu, 28 Feb 2019 22:44:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731153AbfB1Wol (ORCPT ); Thu, 28 Feb 2019 17:44:41 -0500 Received: from sonic301-10.consmr.mail.bf2.yahoo.com ([74.6.129.49]:34078 "EHLO sonic301-10.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731171AbfB1Wol (ORCPT ); Thu, 28 Feb 2019 17:44:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1551393879; bh=oscz6Vi68MsyXM6MI+oD21a/mpleHcjgHRDeaBmng10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject; b=d2T4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88gyqg5KqDzAyU9xPsNucdf tMM04LNhIK4qXhnhytDWZTM4bhyuPeAkPjvGw7IC_HsD9_VRDAZaBKN9OGeN4HCeutllQWyWN34V oqy0J.YrksBpxPG3968Bj8aKlVKkGRU_q7orqa_YqnRSYmYDJazdfCjZor40fEqFVaF8L90GpvwY vFIhYx8IkaDL3rndkfoqqpQQPiVW9yeFl2IsHnMm5OhS7..Slb5MoKcNCQPS2vC1Ap_FsUdrgd3V QXWBH9wLIqGWMiMrwZqg1zYiyrtnfOIW86ItOffUsIU2EUJqp3KHwn8DMX53Y9RL7YF76lAuNGpN Ov1h_DRR5Asjv0cjXMztDMzBdv4icM.p7S.1kjSoKx.gyYAk707WOQ9WaaYNkZmMTIF1VpZJDsOo qxT1ssqcpN0MjYOTMsi4SAPfcYw46KrrlyeFGIl7TGp.Xs9ZG6uaZAHU- Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.bf2.yahoo.com with HTTP; Thu, 28 Feb 2019 22:44:39 +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:38 +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 95/97] LSM: Avoid network conflicts in SELinux and Smack Date: Thu, 28 Feb 2019 14:43:54 -0800 Message-Id: <20190228224356.2608-26-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 Add calls to security_reconcile_netlbl() in SELinux and Smack to ensure that only packets that are acceptable to all active security modules get sent. Signed-off-by: Casey Schaufler --- security/selinux/hooks.c | 3 +++ security/smack/smack_netfilter.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 84bfcf7ca08b..4a8996b7b477 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -5400,6 +5400,9 @@ static unsigned int selinux_ip_output(struct sk_buff *skb, sid = SECINITSID_KERNEL; if (selinux_netlbl_skbuff_setsid(skb, family, sid) != 0) return NF_DROP; + /* verify that this IP option works with other security modules */ + if (sk && security_reconcile_netlbl(sk)) + return NF_DROP; return NF_ACCEPT; } diff --git a/security/smack/smack_netfilter.c b/security/smack/smack_netfilter.c index 7d202dde75b6..55cc38ae07f5 100644 --- a/security/smack/smack_netfilter.c +++ b/security/smack/smack_netfilter.c @@ -89,6 +89,8 @@ static unsigned int smack_ipv4_output(void *priv, return NF_DROP; ssp->smk_set = rc; } + if (security_reconcile_netlbl(sk)) + return NF_DROP; return NF_ACCEPT; }