From: Paul Moore <paul@paul-moore.com>
To: Fan Wu <wufan@linux.microsoft.com>,
corbet@lwn.net, zohar@linux.ibm.com, jmorris@namei.org,
serge@hallyn.com, tytso@mit.edu, ebiggers@kernel.org,
axboe@kernel.dk, agk@redhat.com, snitzer@kernel.org,
eparis@redhat.com
Cc: linux-doc@vger.kernel.org, linux-integrity@vger.kernel.org,
linux-security-module@vger.kernel.org,
linux-fscrypt@vger.kernel.org, linux-block@vger.kernel.org,
dm-devel@redhat.com, audit@vger.kernel.org,
roberto.sassu@huawei.com, linux-kernel@vger.kernel.org,
Deven Bowers <deven.desai@linux.microsoft.com>,
Fan Wu <wufan@linux.microsoft.com>
Subject: Re: [PATCH RFC v11 4/19] ipe: add LSM hooks on execution and kernel read
Date: Mon, 23 Oct 2023 23:52:24 -0400 [thread overview]
Message-ID: <46922873bd020f8cd443b7fca59ef802.paul@paul-moore.com> (raw)
In-Reply-To: <1696457386-3010-5-git-send-email-wufan@linux.microsoft.com>
On Oct 4, 2023 Fan Wu <wufan@linux.microsoft.com> wrote:
>
> IPE's initial goal is to control both execution and the loading of
> kernel modules based on the system's definition of trust. It
> accomplishes this by plugging into the security hooks for
> bprm_check_security, file_mprotect, mmap_file, kernel_load_data,
> and kernel_read_data.
>
> Signed-off-by: Deven Bowers <deven.desai@linux.microsoft.com>
> Signed-off-by: Fan Wu <wufan@linux.microsoft.com>
> ---
> v2:
> + Split evaluation loop, access control hooks,
> and evaluation loop from policy parser and userspace
> interface to pass mailing list character limit
>
> v3:
> + Move ipe_load_properties to patch 04.
> + Remove useless 0-initializations
> + Prefix extern variables with ipe_
> + Remove kernel module parameters, as these are
> exposed through sysctls.
> + Add more prose to the IPE base config option
> help text.
> + Use GFP_KERNEL for audit_log_start.
> + Remove unnecessary caching system.
> + Remove comments from headers
> + Use rcu_access_pointer for rcu-pointer null check
> + Remove usage of reqprot; use prot only.
> + Move policy load and activation audit event to 03/12
>
> v4:
> + Remove sysctls in favor of securityfs nodes
> + Re-add kernel module parameters, as these are now
> exposed through securityfs.
> + Refactor property audit loop to a separate function.
>
> v5:
> + fix minor grammatical errors
> + do not group rule by curly-brace in audit record,
> reconstruct the exact rule.
>
> v6:
> + No changes
>
> v7:
> + Further split lsm creation, the audit system, the evaluation loop
> and access control hooks into separate commits.
>
> v8:
> + Rename hook functions to follow the lsmname_hook_name convention
> + Remove ipe_hook enumeration, can be derived from correlation with
> syscall audit record.
>
> v9:
> + Minor changes for adapting to the new parser
>
> v10:
> + Remove @reqprot part
>
> v11:
> + Fix code style issues
> ---
> security/ipe/Makefile | 1 +
> security/ipe/eval.c | 14 ++++
> security/ipe/eval.h | 3 +
> security/ipe/hooks.c | 183 ++++++++++++++++++++++++++++++++++++++++++
> security/ipe/hooks.h | 25 ++++++
> security/ipe/ipe.c | 6 ++
> 6 files changed, 232 insertions(+)
> create mode 100644 security/ipe/hooks.c
> create mode 100644 security/ipe/hooks.h
...
> diff --git a/security/ipe/hooks.c b/security/ipe/hooks.c
> new file mode 100644
> index 000000000000..6164a9b53361
> --- /dev/null
> +++ b/security/ipe/hooks.c
> @@ -0,0 +1,183 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) Microsoft Corporation. All rights reserved.
> + */
...
> +/**
> + * ipe_kernel_read_file - ipe security hook function for kernel read.
> + * @file: Supplies a pointer to the file structure being read in from disk.
> + * @id: Supplies the enumeration identifying the purpose of the read.
> + * @contents: Unused.
> + *
> + * This LSM hook is called when a file is being read in from disk from
> + * the kernel.
> + *
> + * Return:
> + * 0 - OK
> + * !0 - Error
> + */
> +int ipe_kernel_read_file(struct file *file, enum kernel_read_file_id id,
> + bool contents)
> +{
> + enum ipe_op_type op;
> + struct ipe_eval_ctx ctx = IPE_EVAL_CTX_INIT;
> +
> + switch (id) {
> + case READING_FIRMWARE:
> + op = IPE_OP_FIRMWARE;
> + break;
> + case READING_MODULE:
> + op = IPE_OP_KERNEL_MODULE;
> + break;
> + case READING_KEXEC_INITRAMFS:
> + op = IPE_OP_KEXEC_INITRAMFS;
> + break;
> + case READING_KEXEC_IMAGE:
> + op = IPE_OP_KEXEC_IMAGE;
> + break;
> + case READING_POLICY:
> + op = IPE_OP_IMA_POLICY;
> + break;
> + case READING_X509_CERTIFICATE:
> + op = IPE_OP_IMA_X509;
> + break;
> + default:
> + op = IPE_OP_INVALID;
> + WARN(op == IPE_OP_INVALID, "no rule setup for enum %d", id);
I'm not sure you need to test @op above since you set @op on the line
above, just use true/1 to simplify things. It also seems like it
might be helpful to provice some context for the enum above in the
WARN() message. For example:
WARN(1, "no rule setup for kernel_read_file %d", id);
> + }
> +
> + build_eval_ctx(&ctx, file, op);
> + return ipe_evaluate_event(&ctx);
> +}
> +
> +/**
> + * ipe_kernel_load_data - ipe security hook function for kernel load data.
> + * @id: Supplies the enumeration identifying the purpose of the read.
> + * @contents: Unused.
> + *
> + * This LSM hook is called when a buffer is being read in from disk.
> + *
> + * Return:
> + * * 0 - OK
> + * * !0 - Error
> + */
> +int ipe_kernel_load_data(enum kernel_load_data_id id, bool contents)
> +{
> + enum ipe_op_type op;
> + struct ipe_eval_ctx ctx = IPE_EVAL_CTX_INIT;
> +
> + switch (id) {
> + case LOADING_FIRMWARE:
> + op = IPE_OP_FIRMWARE;
> + break;
> + case LOADING_MODULE:
> + op = IPE_OP_KERNEL_MODULE;
> + break;
> + case LOADING_KEXEC_INITRAMFS:
> + op = IPE_OP_KEXEC_INITRAMFS;
> + break;
> + case LOADING_KEXEC_IMAGE:
> + op = IPE_OP_KEXEC_IMAGE;
> + break;
> + case LOADING_POLICY:
> + op = IPE_OP_IMA_POLICY;
> + break;
> + case LOADING_X509_CERTIFICATE:
> + op = IPE_OP_IMA_X509;
> + break;
> + default:
> + op = IPE_OP_INVALID;
> + WARN(op == IPE_OP_INVALID, "no rule setup for enum %d", id);
See my comments in ipe_kernel_read_file(), they also apply here.
> + }
> +
> + build_eval_ctx(&ctx, NULL, op);
> + return ipe_evaluate_event(&ctx);
> +}
--
paul-moore.com
next prev parent reply other threads:[~2023-10-24 3:52 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-04 22:09 [RFC PATCH v11 00/19] Integrity Policy Enforcement LSM (IPE) Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 01/19] security: add ipe lsm Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 02/19] ipe: add policy parser Fan Wu
2023-10-24 3:52 ` [PATCH RFC v11 2/19] " Paul Moore
2023-10-25 22:45 ` Fan Wu
2023-10-26 21:36 ` Paul Moore
2023-10-04 22:09 ` [RFC PATCH v11 03/19] ipe: add evaluation loop Fan Wu
2023-10-24 3:52 ` [PATCH RFC v11 3/19] " Paul Moore
2023-10-26 0:15 ` Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 04/19] ipe: add LSM hooks on execution and kernel read Fan Wu
2023-10-24 3:52 ` Paul Moore [this message]
2023-10-04 22:09 ` [RFC PATCH v11 05/19] ipe: introduce 'boot_verified' as a trust provider Fan Wu
2023-10-24 3:52 ` [PATCH RFC v11 5/19] " Paul Moore
2023-10-26 21:33 ` Fan Wu
2023-10-26 22:12 ` Paul Moore
2023-11-02 22:46 ` Fan Wu
2023-11-03 22:15 ` Paul Moore
2023-11-03 22:30 ` Paul Moore
2023-10-04 22:09 ` [RFC PATCH v11 06/19] security: add new securityfs delete function Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 07/19] ipe: add userspace interface Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 08/19] uapi|audit|ipe: add ipe auditing support Fan Wu
2023-10-24 3:52 ` [PATCH RFC v11 8/19] " Paul Moore
2023-11-02 22:55 ` Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 09/19] ipe: add permissive toggle Fan Wu
2023-10-24 3:52 ` [PATCH RFC v11 9/19] " Paul Moore
2023-11-02 22:56 ` Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 10/19] block|security: add LSM blob to block_device Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 11/19] dm verity: set DM_TARGET_SINGLETON feature flag Fan Wu
2023-10-24 3:52 ` [PATCH RFC " Paul Moore
2023-11-02 0:40 ` Paul Moore
2023-10-04 22:09 ` [RFC PATCH v11 12/19] dm: add finalize hook to target_type Fan Wu
2023-10-24 3:52 ` [PATCH RFC " Paul Moore
2023-11-02 0:41 ` Paul Moore
2023-10-04 22:09 ` [RFC PATCH v11 13/19] dm verity: consume root hash digest and signature data via LSM hook Fan Wu
2023-10-24 3:52 ` [PATCH RFC " Paul Moore
2023-11-02 0:41 ` Paul Moore
2023-10-04 22:09 ` [RFC PATCH v11 14/19] ipe: add support for dm-verity as a trust provider Fan Wu
2023-10-24 3:52 ` [PATCH RFC " Paul Moore
2023-11-02 22:40 ` Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 15/19] fsverity: consume builtin signature via LSM hook Fan Wu
2023-10-05 2:27 ` Eric Biggers
2023-10-05 2:49 ` Fan Wu
2023-10-24 3:52 ` [PATCH RFC " Paul Moore
2023-11-02 0:40 ` Paul Moore
2023-11-02 2:53 ` Eric Biggers
2023-11-02 15:42 ` Paul Moore
2023-11-02 19:33 ` Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 16/19] ipe: enable support for fs-verity as a trust provider Fan Wu
2023-10-04 23:58 ` Randy Dunlap
2023-10-05 2:45 ` Fan Wu
2023-10-24 3:52 ` [PATCH RFC " Paul Moore
2023-10-04 22:09 ` [RFC PATCH v11 17/19] scripts: add boot policy generation program Fan Wu
2023-10-24 3:52 ` [PATCH RFC " Paul Moore
2023-11-02 23:09 ` Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 18/19] ipe: kunit test for parser Fan Wu
2023-10-24 3:52 ` [PATCH RFC " Paul Moore
2023-11-02 23:11 ` Fan Wu
2023-10-04 22:09 ` [RFC PATCH v11 19/19] documentation: add ipe documentation Fan Wu
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=46922873bd020f8cd443b7fca59ef802.paul@paul-moore.com \
--to=paul@paul-moore.com \
--cc=agk@redhat.com \
--cc=audit@vger.kernel.org \
--cc=axboe@kernel.dk \
--cc=corbet@lwn.net \
--cc=deven.desai@linux.microsoft.com \
--cc=dm-devel@redhat.com \
--cc=ebiggers@kernel.org \
--cc=eparis@redhat.com \
--cc=jmorris@namei.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=roberto.sassu@huawei.com \
--cc=serge@hallyn.com \
--cc=snitzer@kernel.org \
--cc=tytso@mit.edu \
--cc=wufan@linux.microsoft.com \
--cc=zohar@linux.ibm.com \
/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