From patchwork Wed Aug 7 22:42:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 11082821 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 4AE9C1399 for ; Wed, 7 Aug 2019 22:43:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E6FC28A16 for ; Wed, 7 Aug 2019 22:43:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FEFE28ADE; Wed, 7 Aug 2019 22:43:00 +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 5184E28A16 for ; Wed, 7 Aug 2019 22:42:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389317AbfHGWm5 (ORCPT ); Wed, 7 Aug 2019 18:42:57 -0400 Received: from sonic310-23.consmr.mail.bf2.yahoo.com ([74.6.135.197]:36020 "EHLO sonic310-23.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388945AbfHGWm5 (ORCPT ); Wed, 7 Aug 2019 18:42:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1565217776; bh=SMs4nli59t3K7f0fj8Nh2Asd3jA9nd4Esaxdw91qRlo=; h=From:To:Cc:Subject:Date:In-Reply-To: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k3SA56QhjDX3Uhu74pJuhYnLGDjG75SSMEcEx010rj CM_GgoEP6nzQ8KDmh8VxCU1.7N6X93z0HAYS1O7yPFH8qjIaQBXgkh0bNBcJ.FmLcNw4l2t5sK8Z P5LaKnRmCnM3tdfp5AFAEUDogN5tROuCLL9EGkafiJqe4zqcHU0CrMRrUZIdYuQz3JgdD1tRLZMB t54q9cPfluVGKn_6UEwdeub5JPamldzZeNWbcv6KZnIR2yBcKtxse4lQlLyzTSEzvQSrdGBP9EcC ZiGJ7YGRoOaiJhP.NDcG_P1TbxcK3rPqE1PRMBbPY5r3r_v8qihaXDHVOB0GQYpFhVd4tDC_uMQI 6b17ev3h2O4OpUqqZWnKTdAxq05rBWfGqH_Pv_PZybI8P0wvIXaFZGbnoRIsdXIrPQpRhE9s.HqE vdIWLx2gm.LF0FSC4Z7iZzLjOmYjX8QUgjkllOBvQe1kNJ_liQT_zEFm_BVYUq2DOdRxPNJyWJ7o nyQDAVd4JcLh068dTOEGviDIMSuNH7JQWPBLahO3uxSwdTrG0GTrRh_HBZFr17DtbzUR1NzpV_pL S4ahrHrxKREpu7Q00xocKo.HECCFrt7kY4QcfWkxRKZlOX5EX3pVM7lkai0YmxOFUBf9H8jzY6Cd 7eeY5OrY- Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.bf2.yahoo.com with HTTP; Wed, 7 Aug 2019 22:42:56 +0000 Received: by smtp429.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 824faaf1f4a5ffbf9b87c6192a4b2124; Wed, 07 Aug 2019 22:42:51 +0000 (UTC) From: Casey Schaufler To: casey.schaufler@intel.com, jmorris@namei.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Cc: casey@schaufler-ca.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, paul@paul-moore.com, sds@tycho.nsa.gov Subject: [PATCH v7 01/16] LSM: Single hook called in secmark refcounting Date: Wed, 7 Aug 2019 15:42:30 -0700 Message-Id: <20190807224245.10798-3-casey@schaufler-ca.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190807224245.10798-1-casey@schaufler-ca.com> References: <20190807224245.10798-1-casey@schaufler-ca.com> MIME-Version: 1.0 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Restrict the secmark_refcount_dec and secmark_refcount_inc interfaces to a single module. The secmark is too small to share, and this allows the modules a way to detect if the secmark is theirs to use. Signed-off-by: Casey Schaufler --- security/security.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/security/security.c b/security/security.c index e9f579483d12..0467f194d87d 100644 --- a/security/security.c +++ b/security/security.c @@ -2564,13 +2564,25 @@ EXPORT_SYMBOL(security_secmark_relabel_packet); void security_secmark_refcount_inc(void) { - call_void_hook(secmark_refcount_inc); + struct security_hook_list *hp; + + hlist_for_each_entry(hp, &security_hook_heads.secmark_refcount_inc, + list) { + hp->hook.secmark_refcount_inc(); + break; + } } EXPORT_SYMBOL(security_secmark_refcount_inc); void security_secmark_refcount_dec(void) { - call_void_hook(secmark_refcount_dec); + struct security_hook_list *hp; + + hlist_for_each_entry(hp, &security_hook_heads.secmark_refcount_dec, + list) { + hp->hook.secmark_refcount_dec(); + break; + } } EXPORT_SYMBOL(security_secmark_refcount_dec);