Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1719533rwi; Thu, 20 Oct 2022 16:46:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AFWCLYleBH3qyhw0eMxoxLy5L9lS8r9UeFqSGMrFKp5eCsCRpkXb9n7afaHFzZDaj1WsP X-Received: by 2002:aa7:9a09:0:b0:562:64cc:94e0 with SMTP id w9-20020aa79a09000000b0056264cc94e0mr16359631pfj.60.1666309574716; Thu, 20 Oct 2022 16:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666309574; cv=none; d=google.com; s=arc-20160816; b=ErCGyrFK0AW8KJ+SD0mGh0FOVZkaI6FFZYj44lSihYrM8zj5zga13G+5+xgA0UfOie a8rTtjbeC5UHpI05bCF3nt2A+H8HaG/FqBxDam8ozdENZnyhdpED5eIl1ZBulmDRC1h7 5WyGBeb1kYBl2nzJK9BS3orJxQGu7Mxtl95kGTHINtHU/ZVOq3oztcLQNNKhNJkFKRaV 2koGRXrJO35xVkNAS6G3q2TsPWKSattMPYvPWuyurJtbK78+KIq879YTO/5bEaJC2j1m tnK/su5mFiVu7yzBrntYWxLlypqfnIgaVAXPUcVMylXnyqD9pVAbtSH0jhuXnDmUFrAp 3PqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Ct7M+eQn+1sXkf2JlGtv/zGo5O7AhhVZoEOq681KO4I=; b=o/kls/f9ahIU/iBZkzihuGaXaFNE3xFXzrwSIjetVXFTbdIj30/PH837SX5t/gYe+p Wiyz9fhoepf4yFKed72Wdpq/Y31o/px/iihTpsOqvLlULTcM6hqZKRy61HKhDRJn35T2 q6yRWrO19MwzwxmlclunOWA1OqmSipcQIH/BCa3ROIlsdF+tcACtuaT6Y5KyFvYYO3yi f1wlnj5kdtCsun1fpZwln+gsy1k9PyDWlReL+T+moGluC3VElmLUKbYrKqHjzXPapFG0 dJLxF9G+XDcwHTpqbB+jUvhybeZc8znJu80scba4BkYOo4ZEYGOTRF63cpyAKRxyS5l3 fw5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=XJmUiW6r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020a170903125000b0016f9420a15asi26200208plh.168.2022.10.20.16.46.02; Thu, 20 Oct 2022 16:46:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=XJmUiW6r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229456AbiJTXmP (ORCPT + 99 others); Thu, 20 Oct 2022 19:42:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbiJTXmL (ORCPT ); Thu, 20 Oct 2022 19:42:11 -0400 Received: from sonic306-28.consmr.mail.ne1.yahoo.com (sonic306-28.consmr.mail.ne1.yahoo.com [66.163.189.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFD5116D88B for ; Thu, 20 Oct 2022 16:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1666309330; bh=Ct7M+eQn+1sXkf2JlGtv/zGo5O7AhhVZoEOq681KO4I=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=XJmUiW6rhdzJKiAexE8m1tQxbk48VjkEUm5BKgiMF0LDJwCzYhGksG6Ph/Vdwdauh8YnUKWkeft8gmdi5LpJWTI54eoIh/fmsKzfiegtPKwRBhVqM33qGslEPkmnSpqYSUgyiEVCMQYNp9P88PnCibZ18JKag5brlfvESSROreN39oQCLd97gbpie8GtPrETi96vkN7QOdpKAjld6s6eRGs8NGV0px5a3LPYuewGPfUnOG0SZDK2CZW7f8g7+yFbovIEp5u7xNzepLRblAIGded2lUOp2sKKzOGOpmfjy0G23Lgv3ki8blkg8P0VgMd20EqH61ubYZL4hQMucCCGlg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1666309330; bh=R/3JbMN9lfHknive0qn6sbuvnm/GqGh1VGmM3zN3yJx=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=USX4h9tBzG978n0IM+oZbuWrsq0Fq0YGj2pRgqivqvsD7jTODfUq5EOK5lLVEb2RHuClTEeArF/1kydv1BreD2lJkBlvgW9bmZs2rZmHyWq4IgEzFSZrxFHu1bM5HimkxYRkhuRlJjzDrp4oyebm+Y6LSE5oNyPnD66zmMDXhZC31kWZDLH2BM9GIsXCv5jVllfUw6tU1B8yf1ER4vxia2y21tFTpGcfY6rJzrKpLsHKA+gWYFF4/ZVkZnqIhW7SPcjYp4IovL9GmT5PacArUy+4dhbGjrY1jD7Kil1NA0O77nSr81QIq9Syhw4My//+WW3XqtQg0ohCDjYCHQ0xnQ== X-YMail-OSG: IEVbw1YVM1lqZ_LzZ4UpMqXtNV8WoDJX7Eo0kYY34UcqisNoIH7LsWa_7kS6vnJ 1v7CZXjW_noROX74Oc.w.avDj6ZVVh08Iuh6cOLfHW5uONl_vHl18kyz5LOQHwUx5AXyMVs2SxrN zurVxX73AvlCx2kQ5o_xhebjWspBMU.wvJFCprW_eU4Rp4Omyxz3jkkns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BdmGver.07NSEWahbM0rFT.Ce..w-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ne1.yahoo.com with HTTP; Thu, 20 Oct 2022 23:42:10 +0000 Received: by hermes--production-gq1-754cb59848-nlbwv (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 96be409d95bde475d58f7a617539a8b3; Thu, 20 Oct 2022 23:42:06 +0000 (UTC) Message-ID: Date: Thu, 20 Oct 2022 16:42:04 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [PATCH v38 04/39] LSM: Maintain a table of LSM attribute data Content-Language: en-US To: Tetsuo Handa , casey.schaufler@intel.com, paul@paul-moore.com, linux-security-module@vger.kernel.org Cc: linux-audit@redhat.com, jmorris@namei.org, selinux@vger.kernel.org, keescook@chromium.org, john.johansen@canonical.com, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org, casey@schaufler-ca.com References: <20220927195421.14713-1-casey@schaufler-ca.com> <20220927195421.14713-5-casey@schaufler-ca.com> <9907d724-4668-cd50-7454-1a8ca86542b0@I-love.SAKURA.ne.jp> From: Casey Schaufler In-Reply-To: <9907d724-4668-cd50-7454-1a8ca86542b0@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.20754 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/13/2022 3:04 AM, Tetsuo Handa wrote: > On 2022/09/28 4:53, Casey Schaufler wrote: >> @@ -483,6 +491,16 @@ void __init security_add_hooks(struct security_hook_list *hooks, int count, >> { >> int i; >> >> + /* >> + * A security module may call security_add_hooks() more >> + * than once. Landlock is one such case. >> + */ >> + if (lsm_id == 0 || lsm_idlist[lsm_id - 1] != lsmid) >> + lsm_idlist[lsm_id++] = lsmid; >> + >> + if (lsm_id > LSMID_ENTRIES) >> + panic("%s Too many LSMs registered.\n", __func__); > I'm not happy with LSMID_ENTRIES. This is a way towards forever forbidding LKM-based LSMs. I don't see any way given the locking issues that we're ever going to mix built in security modules and loaded security modules on the same hook lists. The SELinux module deletion code is sufficiently scary that it is being removed. That does not mean that I think loadable modules are impossible, I think it means that their management is going to have to be separate, the same way the BPF programs are handled. The only way that I see a unified hook list is for all the LSMs to be implemented as loadable modules, and I can't see that happening in my lifetime. I can see an LSM like BPF, as I mentioned before, that manages loaded modules. Over the years I've seen several designs that might work. I'm encouraged (and not a little bit frightened) by the success of the BPF work. Converting the array[LSMID_ENTRIES] implementation to a hlist like the hooks have used would not be that big a project and I don't see that making such a change would be a show-stopper for implementing loadable modules. I think that a lot of other issues would be more significant. I will, on the other hand, listen to compelling arguments. It is not the intention of this code to lock out loadable modules. If I thought it would I would not have proposed it. > I'm fine with using UAPI-visible constants for switching /proc/ files. > But TOMOYO does not need such constant because TOMOYO does not use /proc/ files. > > Also, lsm_self_attr() will be limited for LSM modules which use /proc/ files, and > therefore I think prctl() will be already there. While the proposed set of attributes map to those in /proc/.../attr there is no reason to assume they will be limited to those. I can see providing several of the Smack attributes currently manipulated in smackfs, such as relabel-self. If we are providing SELinux specific values like keycreate there's no reason we can't provide Smack or TOMOYO specific values as well. > >> + >> for (i = 0; i < count; i++) { >> hooks[i].lsmid = lsmid; >> hlist_add_tail_rcu(&hooks[i].list, hooks[i].head);