mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: "Dr. Greg" <greg@enjellic.com>
Cc: linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, jmorris@namei.org,
	Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: [PATCH v4 04/14] Add primary TSEM implementation file.
Date: Tue, 27 Aug 2024 10:51:01 -0700	[thread overview]
Message-ID: <d940241d-77f2-4f41-9695-be9dabb896cd@schaufler-ca.com> (raw)
In-Reply-To: <20240827105214.GA4769@wind.enjellic.com>

On 8/27/2024 3:52 AM, Dr. Greg wrote:
> On Mon, Aug 26, 2024 at 08:53:31AM -0700, Casey Schaufler wrote:
>
> Good morning Casey, I hope this note finds your day starting well.
>
> Greetings to others on this 'last' week of summer.
>
>> On 8/26/2024 3:37 AM, Greg Wettstein wrote:
>>> The tsem.c file is the 'master' file in the TSEM implementation. It is
>>> responsible for initializing the LSM and providing the implementation of the
>>> security event handlers.
>>> ---
>>>  security/tsem/tsem.c | 2446 ++++++++++++++++++++++++++++++++++++++++++
>>>  1 file changed, 2446 insertions(+)
>>>  create mode 100644 security/tsem/tsem.c
>>>
>>> diff --git a/security/tsem/tsem.c b/security/tsem/tsem.c
>>> new file mode 100644
>>> index 000000000000..76d65b3e62b3
>>> --- /dev/null
>>> +++ b/security/tsem/tsem.c
>>> @@ -0,0 +1,2446 @@
>>> +// SPDX-License-Identifier: GPL-2.0-only
>>> +
>>> +/*
>>> + * Copyright (C) 2024 Enjellic Systems Development, LLC
>>> + * Author: Dr. Greg Wettstein <greg@enjellic.com>
>>> + *
>>> + * This file is the primary implementation file for the tsem LSM.
>>> + *
>>> + * It implements initialization and setup functions that interpret
>>> + * kernel command-line arguments and prepares TSEM for operation.
>>> + *
>>> + * In addition it contains all of the TSEM specific security event
>>> + * handlers that are responsible for handling the LSM events that TSEM
>>> + * models.
>>> + *
>>> + * Each TSEM event handler calls the tsem_allocate_event() function to
>>> + * allocate a structure that will be used to describe the event.  The
>>> + * CELL union of this structure contains various structures that are
>>> + * used to hold these parameters.
>>> + *
>>> + * Since the event characterization parameters need to be retained for
>>> + * the lifetime of the tsem_event structure that is allocated.  In the
>>> + * case of internally modeled namespaces this lifespan is the lifetime
>>> + * of the security modeling namespace.  In the case of externally
>>> + * modeled namespaces, the lifespan is until the security event
>>> + * description is exported to an external trust orchestrator.
>>> + *
>>> + * In order to support this model, the event description structures
>>> + * are typically composed of a union over 'in' and 'out' structures.
>>> + * The 'in' structures are used to hold arguments to the event handler
>>> + * that may only be relevant for the duration of the call.  These
>>> + * values are translated into members of the 'out' structure that
>>> + * retain the values until the end of the lifetime of the tsem_event
>>> + * structure.
>>> + *
>>> + * Each TSEM event handler is responsible for allocating a tsem_event
>>> + * structure and populating the appropriate CELL structure with the
>>> + * input characteristics of the event.  The dispatch_event() function
>>> + * is called to handle the modeling of the event.  This function
>>> + * returns the permission value that is returned as the result of the
>>> + * LSM event handler.
>>> + *
>>> + * The dispatch_event() calls the tsem_event_init() function that is
>>> + * responsible for translating the input parameters into values that
>>> + * will be retained for the lifetime of the security event
>>> + * description.  The populated event description is then dispatched to
>>> + * either the tsem_model_event() or the tsem_export_event() for
>>> + * modeling by either the internal TMA or by a TMA associated with an
>>> + * external trust orchestrator.
>>> + */
>>> +
>>> + ...
>>> +
>>> +static int tsem_file_open(struct file *file)
>>> +{
>>> +	struct inode *inode = file_inode(file);
>>> +	struct tsem_event *ep;
>>> +
>>> +	if (static_branch_unlikely(&tsem_not_ready))
>>> +		return 0;
>>> +	if (bypass_event(TSEM_FILE_OPEN))
>>> +		return 0;
>>> +	if (unlikely(tsem_inode(inode)->status == TSEM_INODE_CONTROL_PLANE)) {
>>> +		if (capable(CAP_MAC_ADMIN))
>> Don't you mean CAP_MAC_OVERRIDE? CAP_MAC_ADMIN is for changes to the
>> security state of the system, where CAP_MAC_OVERRIDE is for access
>> control decision exceptions. Here (and elsewhere) you use the former
>> in access checks.
> You are clearly the mechanistic expert on capabilities so we would
> take your lead on this.
>
> Some background information to hopefully assist in a discussion on the
> types of capability checks that should be implemented.
>
> The capability checks we apply in TSEM gate the following five types
> of actions:
>
> 1.) The ability to issue TSEM control commands.
>
> 2.) The ability to register an event processing module.
>
> 3.) Access to state information on kernel based modeling agent instances.
>
> 4.) The ability to send signals to trust orchestration processes.
>
> 5.) The ability to send a signal to a different security modeling namespace.
>
> If we understand the differentiation that you suggest between
> CAP_MAC_ADMIN and CAP_MAC_OVERRIDE we would conclude the following:
>
> Checks 1, 2 and 4 would seem, in our opinion, have the ability to
> change the security state of a system.  As such it would seem
> appropriate to use CAP_MAC_ADMIN for those checks.
>
> Rather than belabor the issue now, we can entertain a subsequent
> discussion, if needed, on why we believe that actions 1, 2 and 4 can
> change the security state of the system.
>
> By your definition, check type 3 would seem to be consistent with
> CAP_MAC_OVERRIDE, since it is gating access to potentially security
> sensitive information but which does not imply the ability to change
> the security state of the system.
>
> That leaves category 5 as a possible open question.  Given the trust
> orchestration model for externally modeled namespaces, we concluded
> that the only entities that should be able to issue signals that can
> manipulate, particularly terminate a process, should only come from
> within the security modeling namespace that the target process is
> running in.  Given that, we would consider such operations as possibly
> affecting the security state of the system and thus suitable for
> CAP_MAC_ADMIN.
>
> Based on what we have always understood, and that is confirmed by 'git
> grep', the only thing at this time that is using CAP_MAC_OVERRIDE is
> SMACK.  If our analysis is correct, would you have any issues with us
> changing the type 3 checks to CAP_MAC_OVERRIDE?
>
> With respect to the check that you call out in
> tsem.c:tsem_open_file(), the capability check is to avoid a model
> deadlock situation.  If we adopt the model we discuss above, we would
> need to unequivocably allow the open if the process is carrying
> CAP_MAC_ADMIN or CAP_MAC_OVERRIDE in order to avoid a control
> deadlock.
>
> We will look forward to your thoughts on if we should proceed with the
> above changes.

It seems you were right all along, that none of these capability checks
really fit with CAP_MAC_OVERRIDE. Thank you for the clarification. 

>
> Have a good day.
>
> As always,
> Dr. Greg
>
> The Quixote Project - Flailing at the Travails of Cybersecurity
>               https://github.com/Quixote-Project

  reply	other threads:[~2024-08-27 17:51 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-26 10:37 [PATCH v4 00/14] Implement Trusted Security Event Modeling Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 01/14] Update MAINTAINERS file Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 02/14] Add TSEM specific documentation Greg Wettstein
2025-01-14  1:29   ` [PATCH v4 2/14] " Paul Moore
2025-01-17  4:47     ` Dr. Greg
2025-01-17 18:10       ` Casey Schaufler
2025-01-18 19:03         ` Dr. Greg
2025-01-21 18:09           ` Casey Schaufler
2025-01-26 18:40             ` Dr. Greg
2025-01-28 22:23       ` Paul Moore
2025-01-31 17:11         ` Dr. Greg
2025-02-25 12:01         ` Dr. Greg
2025-02-25 15:48           ` Casey Schaufler
2025-02-27 12:12             ` Dr. Greg
2025-02-27 16:47               ` Casey Schaufler
2025-03-03 10:14                 ` Dr. Greg
2025-03-03 16:23                   ` Casey Schaufler
2025-02-05 12:00     ` Dr. Greg
2025-02-05 19:58       ` Casey Schaufler
2025-02-06 12:45         ` Dr. Greg
2025-02-06 15:48       ` Paul Moore
2025-02-07 10:20         ` Dr. Greg
2025-02-07 17:42           ` Casey Schaufler
2025-02-08  0:29           ` Paul Moore
2025-02-17 12:53             ` Dr. Greg
2025-02-17 23:09               ` Paul Moore
2024-08-26 10:37 ` [PATCH v4 03/14] TSEM global declarations Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 04/14] Add primary TSEM implementation file Greg Wettstein
2024-08-26 15:53   ` Casey Schaufler
2024-08-27 10:52     ` Dr. Greg
2024-08-27 17:51       ` Casey Schaufler [this message]
2024-08-26 10:37 ` [PATCH v4 05/14] Add root domain trust implementation Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 06/14] Implement TSEM control plane Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 07/14] Add namespace implementation Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 08/14] Add security event description export facility Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 09/14] Add event processing implementation Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 10/14] Implement security event mapping Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 11/14] Implement the internal Trusted Modeling Agent Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 12/14] Implement configuration and methods for default model Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 13/14] Implement infrastructure for loadable security models Greg Wettstein
2024-08-26 10:37 ` [PATCH v4 14/14] Activate the configuration and build of the TSEM LSM Greg Wettstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d940241d-77f2-4f41-9695-be9dabb896cd@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=greg@enjellic.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®