Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp42063ybz; Tue, 21 Apr 2020 14:50:52 -0700 (PDT) X-Google-Smtp-Source: APiQypIm4jrN6VlgxiW57jgmXx1L9gFCv1Axt0ZQjzJUICy74tUXcjDdtQybvQncJxm3iUknZ+oO X-Received: by 2002:aa7:daca:: with SMTP id x10mr19821139eds.59.1587505851981; Tue, 21 Apr 2020 14:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587505851; cv=none; d=google.com; s=arc-20160816; b=Whie9899kE2pnrstTaaMXV2rUYBeBTlt40XGTDIkNOI6kFvEdP9+3riI6HBzvnAFJB JCgsmG6bqeeZai3i1vRVYeBmP+CYASYQUmvcuOEORPQO2eXPJigg8n/c5ztjM/Ja+svz 9/Ez5sZ+/+ckOHF5BGDkCUI/7bBHD+L1ix/XFywAb1YeCxSAnuIXj/U6q20i7g/6GQQ7 nXnMDS47BsZgbai6c1eaoQl33TK1PzJpHbsIYfwtTsnHLnXrl4S7ODPHxYO5XNkJkxhP q+mi3GWByic10l5MPmOLF9KGE921IEF9KU8+Gkpyt8gFrHpNwC1bsYUo+NG32mNvuF+P cxsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:content-language :content-transfer-encoding:mime-version:user-agent:date:message-id :autocrypt:subject:from:cc:to:dkim-signature; bh=wuTsmwDyCQPpSXymTxszNIYJyTBCNh7rsldOYFR8lOs=; b=nZ0txYQjs08bkbZRI9R35cZ28sBdjzs/uxkNxm7Tl/asJKSVbX4YOybdMIxDl7MUzX U/oruaZ7VbWZ/hgZuXrObVS+c8pEyPfaYHub98h+4C/MQ82MNpEjvxTvMW8q3ZUMKGRd gF7D84owQNWr3ZNxZcc2kPINHDIvWvXORYJN6+2ePq5NZgN81mNBNQMBkLTYiGEbJby9 rk0prm1mNC9grwCELHCaDamN1YBpRtNJKeI6Km1Xb1X1cyWY4v80b0vIVV/1GZglDUgI gim8CDa+fihAiUjdQCttmYgidrF7+xCd1GxZBhKntjEypUCAy1teMVFFs+4WULf4aLfh PNjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=hrKLA4Oy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w26si2329675ejb.118.2020.04.21.14.50.28; Tue, 21 Apr 2020 14:50:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=hrKLA4Oy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726310AbgDUVsk (ORCPT + 99 others); Tue, 21 Apr 2020 17:48:40 -0400 Received: from sonic301-38.consmr.mail.ne1.yahoo.com ([66.163.184.207]:45958 "EHLO sonic301-38.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbgDUVsj (ORCPT ); Tue, 21 Apr 2020 17:48:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1587505717; bh=wuTsmwDyCQPpSXymTxszNIYJyTBCNh7rsldOYFR8lOs=; h=To:Cc:From:Subject:Date:References:From:Subject; b=hrKLA4OynHJLg2bS/NDUolwl3frKrHmgSg92iV2bCjnEGWt/EUVj+ZC/GGAekS5MVNXsrvtYxlKV2wZaMY7A4u5W5fewMDf62IHcjd94L1bf4s3cNU5CjGbWWLCy/JOo5+tw1ZVVa48+zDF6OE7GRuVM1+AloYfGju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MIsMLmp QRM5EL7JCbVx9EJI7dj0ycqM637mxNKa6NgBi7zCrTx7I4BddPmMmTU9ZMZdb.Q4H0TCiuHtm.ut KRO4jW_m7r.qUEL2Z0dnlDvs9h854BZ1bCvAmwxN8tFz.fnrbMSbFdrcZCUxnRRS8sYk8DkttJmk ceMrFlFMXCRukr8wgwG6sp1DJN5BY7kee7Rlh5lBvHnzIrCOklg8MbzdpDgtcAOP1n.V_UCDJErR PLyM5j1yMbWYpwpMVrGQevC60zLkYoeV4q7siMWP1_WYQ44jJr8f4n0qFKtvHVHXCFeUnx.7ohWv xbQbsFgQKToaQvMwizSt72A8G3jErld7BYbQN1irefMVqEk5zqSDsfU3SspBSoQRJKX7MA7x0N_C 33ar9TEuK0pml_p4G35J1QqaD6ydY83mav.ENAt.qLbASM.i2Bmbyujt1xHsB9o4euia8e69sNqS 0SwyDysnG5FSSfRdplf_OIQkilrLFWcY4FE23AoN0NsJIO_z5Xr3EJc25kLCsnCVw2FxQnehNMC4 y7eXkbPbfGdiqZ6ybK273LxP9.xZzLlbpYb7FUg-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ne1.yahoo.com with HTTP; Tue, 21 Apr 2020 21:48:37 +0000 Received: by smtp415.mail.ne1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 38702d2db9a74e61f245b52e4a7fe801; Tue, 21 Apr 2020 21:48:35 +0000 (UTC) To: Linux Security Summit Program Committee , LKML , linux-doc@vger.kernel.org, Jonathan Corbet Cc: James Morris , Randy Dunlap From: Casey Schaufler Subject: [PATCH] Documentation: LSM: Correct the basic LSM description Autocrypt: addr=casey@schaufler-ca.com; keydata= mQINBFzV9HABEAC/mmv3jeJyF7lR7QhILYg1+PeBLIMZv7KCzBSc/4ZZipoWdmr77Lel/RxQ 1PrNx0UaM5r6Hj9lJmJ9eg4s/TUBSP67mTx+tsZ1RhG78/WFf9aBe8MSXxY5cu7IUwo0J/CG vdSqACKyYPV5eoTJmnMxalu8/oVUH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IbDAUJEswDAAAKCRA4pRV8jEPIEWkzEACKFUnpp+wIVHpckMfBqN8BE5dUbWJc GyQ7wXWajLtlPdw1nNw0Wrv+ob2RCT7qQlUo6GRLcvj9Fn5tR4hBvR6D3m8aR0AGHbcC62cq I7LjaSDP5j/em4oVL2SMgNTrXgE2w33JMGjAx9oBzkxmKUqprhJomPwmfDHMJ0t7y39Da724 oLPTkQDpJL1kuraM9TC5NyLe1+MyIxqM/8NujoJbWeQUgGjn9uxQAil7o/xSCjrWCP3kZDID vd5ZaHpdl8e1mTExQoKr4EWgaMjmD/a3hZ/j3KfTVNpM2cLfD/QwTMaC2fkK8ExMsz+rUl1H icmcmpptCwOSgwSpPY1Zfio6HvEJp7gmDwMgozMfwQuT9oxyFTxn1X3rn1IoYQF3P8gsziY5 qtTxy2RrgqQFm/hr8gM78RhP54UPltIE96VywviFzDZehMvuwzW//fxysIoK97Y/KBZZOQs+ /T+Bw80Pwk/dqQ8UmIt2ffHEgwCTbkSm711BejapWCfklxkMZDp16mkxSt2qZovboVjXnfuq wQ1QL4o4t1hviM7LyoflsCLnQFJh6RSBhBpKQinMJl/z0A6NYDkQi6vEGMDBWX/M2vk9Jvwa v0cEBfY3Z5oFgkh7BUORsu1V+Hn0fR/Lqq/Pyq+nTR26WzGDkolLsDr3IH0TiAVH5ZuPxyz6 abzjfg== Message-ID: <4c053d72-2d58-612f-6d6b-f04226d0181e@schaufler-ca.com> Date: Tue, 21 Apr 2020 14:48:34 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US References: <4c053d72-2d58-612f-6d6b-f04226d0181e.ref@schaufler-ca.com> X-Mailer: WebService/1.1.15739 hermes Apache-HttpAsyncClient/4.1.4 (Java/11.0.6) Content-Length: 13696 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a first pass at updating the basic documentation on Linux Security Modules (LSM), which is frighteningly out of date. Remove untrue statements about the LSM framework. Replace them with true statements where it is convenient to do so. This is the beginnig of a larger effort to bring the LSM documentation up to date. Signed-off-by: Casey Schaufler --- Documentation/security/lsm.rst | 202 ++++++++++++++--------------------------- 1 file changed, 66 insertions(+), 136 deletions(-) diff --git a/Documentation/security/lsm.rst b/Documentation/security/lsm.rst index ad4dfd020e0d..91881b6fe73d 100644 --- a/Documentation/security/lsm.rst +++ b/Documentation/security/lsm.rst @@ -35,47 +35,50 @@ desired model of security. Linus also suggested the possibility of migrating the Linux capabilities code into such a module. The Linux Security Modules (LSM) project was started by WireX to develop -such a framework. LSM is a joint development effort by several security +such a framework. LSM was a joint development effort by several security projects, including Immunix, SELinux, SGI and Janus, and several individuals, including Greg Kroah-Hartman and James Morris, to develop a -Linux kernel patch that implements this framework. The patch is -currently tracking the 2.4 series and is targeted for integration into -the 2.5 development series. This technical report provides an overview -of the framework and the example capabilities security module provided -by the LSM kernel patch. +Linux kernel patch that implements this framework. The work was +incorporated in the mainstream in December of 2003. This technical +report provides an overview of the framework and the capabilities +security module. LSM Framework ============= -The LSM kernel patch provides a general kernel framework to support +The LSM framework provides a general kernel framework to support security modules. In particular, the LSM framework is primarily focused on supporting access control modules, although future development is -likely to address other security needs such as auditing. By itself, the +likely to address other security needs such as sandboxing. By itself, the framework does not provide any additional security; it merely provides -the infrastructure to support security modules. The LSM kernel patch -also moves most of the capabilities logic into an optional security -module, with the system defaulting to the traditional superuser logic. +the infrastructure to support security modules. The LSM framework is +optional, requiring `CONFIG_SECURITY` to be enabled. The capabilities +logic is implemented as a security module. This capabilities module is discussed further in `LSM Capabilities Module <#cap>`__. -The LSM kernel patch adds security fields to kernel data structures and -inserts calls to hook functions at critical points in the kernel code to -manage the security fields and to perform access control. It also adds -functions for registering and unregistering security modules, and adds a -general :c:func:`security()` system call to support new system calls -for security-aware applications. - -The LSM security fields are simply ``void*`` pointers. For process and -program execution security information, security fields were added to +The LSM framework includes security fields in kernel data structures and +calls to hook functions at critical points in the kernel code to +manage the security fields and to perform access control. +It also adds functions for registering security modules. +An interface `/sys/kernel/security/lsm` reports a comma separated list +of security modules that are active on the system. + +The LSM security fields are simply ``void*`` pointers. +The data is referred to as a blob, which may be managed by +the framework or by the individual security modules that use it. +Security blobs that are used by more than one security module are +typically managed by the framework. +For process and +program execution security information, security fields are included in :c:type:`struct task_struct ` and -:c:type:`struct linux_binprm `. For filesystem -security information, a security field was added to :c:type:`struct +:c:type:`struct cred `. +For filesystem +security information, a security field is included in :c:type:`struct super_block `. For pipe, file, and socket security -information, security fields were added to :c:type:`struct inode -` and :c:type:`struct file `. For packet and -network device security information, security fields were added to -:c:type:`struct sk_buff ` and :c:type:`struct -net_device `. For System V IPC security information, +information, security fields are included in :c:type:`struct inode +` and :c:type:`struct file `. +For System V IPC security information, security fields were added to :c:type:`struct kern_ipc_perm ` and :c:type:`struct msg_msg `; additionally, the definitions for :c:type:`struct @@ -84,118 +87,45 @@ were moved to header files (``include/linux/msg.h`` and ``include/linux/shm.h`` as appropriate) to allow the security modules to use these definitions. -Each LSM hook is a function pointer in a global table, security_ops. -This table is a :c:type:`struct security_operations -` structure as defined by -``include/linux/security.h``. Detailed documentation for each hook is -included in this header file. At present, this structure consists of a -collection of substructures that group related hooks based on the kernel -object (e.g. task, inode, file, sk_buff, etc) as well as some top-level -hook function pointers for system operations. This structure is likely -to be flattened in the future for performance. The placement of the hook -calls in the kernel code is described by the "called:" lines in the -per-hook documentation in the header file. The hook calls can also be -easily found in the kernel code by looking for the string -"security_ops->". - -Linus mentioned per-process security hooks in his original remarks as a -possible alternative to global security hooks. However, if LSM were to -start from the perspective of per-process hooks, then the base framework -would have to deal with how to handle operations that involve multiple -processes (e.g. kill), since each process might have its own hook for -controlling the operation. This would require a general mechanism for -composing hooks in the base framework. Additionally, LSM would still -need global hooks for operations that have no process context (e.g. -network input operations). Consequently, LSM provides global security -hooks, but a security module is free to implement per-process hooks -(where that makes sense) by storing a security_ops table in each -process' security field and then invoking these per-process hooks from -the global hooks. The problem of composition is thus deferred to the -module. - -The global security_ops table is initialized to a set of hook functions -provided by a dummy security module that provides traditional superuser -logic. A :c:func:`register_security()` function (in -``security/security.c``) is provided to allow a security module to set -security_ops to refer to its own hook functions, and an -:c:func:`unregister_security()` function is provided to revert -security_ops to the dummy module hooks. This mechanism is used to set -the primary security module, which is responsible for making the final -decision for each hook. - -LSM also provides a simple mechanism for stacking additional security -modules with the primary security module. It defines -:c:func:`register_security()` and -:c:func:`unregister_security()` hooks in the :c:type:`struct -security_operations ` structure and -provides :c:func:`mod_reg_security()` and -:c:func:`mod_unreg_security()` functions that invoke these hooks -after performing some sanity checking. A security module can call these -functions in order to stack with other modules. However, the actual -details of how this stacking is handled are deferred to the module, -which can implement these hooks in any way it wishes (including always -returning an error if it does not wish to support stacking). In this -manner, LSM again defers the problem of composition to the module. - -Although the LSM hooks are organized into substructures based on kernel -object, all of the hooks can be viewed as falling into two major +For packet and +network device security information, security fields were added to +:c:type:`struct sk_buff ` and +:c:type:`struct scm_cookie `. +Unlike the other security module data, the data used here is a +32-bit integer. The security modules are required to map or otherwise +associate these values with real security attributes. + +LSM hooks are maintained in lists. A list is maintained for each +hook, and the hooks are called in the order specified by CONFIG_LSM. +Detailed documentation for each hook is +included in the `include/linux/lsm_hooks.h` header file. + +The LSM framework provides for a close approximation of +general security module stacking. It defines +security_add_hooks() to which each security module passes a +:c:type:`struct security_hooks_list `, +which are added to the lists. +The LSM framework does not provide a mechanism for removing hooks that +have been registered. The SELinux security module has implemented +a way to remove itself, however the feature has been deprecated. + +The hooks can be viewed as falling into two major categories: hooks that are used to manage the security fields and hooks that are used to perform access control. Examples of the first category -of hooks include the :c:func:`alloc_security()` and -:c:func:`free_security()` hooks defined for each kernel data -structure that has a security field. These hooks are used to allocate -and free security structures for kernel objects. The first category of -hooks also includes hooks that set information in the security field -after allocation, such as the :c:func:`post_lookup()` hook in -:c:type:`struct inode_security_ops `. -This hook is used to set security information for inodes after -successful lookup operations. An example of the second category of hooks -is the :c:func:`permission()` hook in :c:type:`struct -inode_security_ops `. This hook checks -permission when accessing an inode. +of hooks include the security_inode_alloc() and security_inode_free() +These hooks are used to allocate +and free security structures for inode objects. +An example of the second category of hooks +is the security_inode_permission() hook. +This hook checks permission when accessing an inode. LSM Capabilities Module ======================= -The LSM kernel patch moves most of the existing POSIX.1e capabilities -logic into an optional security module stored in the file -``security/capability.c``. This change allows users who do not want to -use capabilities to omit this code entirely from their kernel, instead -using the dummy module for traditional superuser logic or any other -module that they desire. This change also allows the developers of the -capabilities logic to maintain and enhance their code more freely, -without needing to integrate patches back into the base kernel. - -In addition to moving the capabilities logic, the LSM kernel patch could -move the capability-related fields from the kernel data structures into -the new security fields managed by the security modules. However, at -present, the LSM kernel patch leaves the capability fields in the kernel -data structures. In his original remarks, Linus suggested that this -might be preferable so that other security modules can be easily stacked -with the capabilities module without needing to chain multiple security -structures on the security field. It also avoids imposing extra overhead -on the capabilities module to manage the security fields. However, the -LSM framework could certainly support such a move if it is determined to -be desirable, with only a few additional changes described below. - -At present, the capabilities logic for computing process capabilities on -:c:func:`execve()` and :c:func:`set\*uid()`, checking -capabilities for a particular process, saving and checking capabilities -for netlink messages, and handling the :c:func:`capget()` and -:c:func:`capset()` system calls have been moved into the -capabilities module. There are still a few locations in the base kernel -where capability-related fields are directly examined or modified, but -the current version of the LSM patch does allow a security module to -completely replace the assignment and testing of capabilities. These few -locations would need to be changed if the capability-related fields were -moved into the security field. The following is a list of known -locations that still perform such direct examination or modification of -capability-related fields: - -- ``fs/open.c``::c:func:`sys_access()` - -- ``fs/lockd/host.c``::c:func:`nlm_bind_host()` - -- ``fs/nfsd/auth.c``::c:func:`nfsd_setuser()` - -- ``fs/proc/array.c``::c:func:`task_cap()` +The POSIX.1e capabilities logic is maintained as a security module +stored in the file ``security/commoncap.c``. The capabilities +module uses the order field of the :c:type:`lsm_info` description +to identify it as the first security module to be registered. +The capabilities security module does not use the general security +blobs, unlike other modules. The reasons are historical and are +based on overhead, complexity and performance concerns.