Re: [PATCH v1 3/8] LSM: Identify the process attributes for each module

From: Greg KH
Date: Wed Oct 26 2022 - 01:59:07 EST


On Tue, Oct 25, 2022 at 11:45:14AM -0700, Casey Schaufler wrote:
> Add an integer member "features" to the struct lsm_id which
> identifies the API related data associated with each security
> module. The initial set of features maps to information that
> has traditionaly been available in /proc/self/attr.
>
> Signed-off-by: Casey Schaufler <casey@xxxxxxxxxxxxxxxx>
> ---
> include/linux/lsm_hooks.h | 1 +
> include/uapi/linux/lsm.h | 14 ++++++++++++++
> security/apparmor/lsm.c | 1 +
> security/selinux/hooks.c | 2 ++
> security/smack/smack_lsm.c | 1 +
> 5 files changed, 19 insertions(+)
>
> diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
> index dd4b4d95a172..46b2aa6a677e 100644
> --- a/include/linux/lsm_hooks.h
> +++ b/include/linux/lsm_hooks.h
> @@ -1608,6 +1608,7 @@ struct security_hook_heads {
> struct lsm_id {
> const char *lsm; /* Name of the LSM */
> int id; /* LSM ID */
> + int features; /* Set of LSM features */

Again, be explicit about size please. And documentation.

> };
>
> /*
> diff --git a/include/uapi/linux/lsm.h b/include/uapi/linux/lsm.h
> index d5bcbb9375df..61e13b1b9ece 100644
> --- a/include/uapi/linux/lsm.h
> +++ b/include/uapi/linux/lsm.h
> @@ -29,4 +29,18 @@
> #define LSM_ID_BPF 42
> #define LSM_ID_LANDLOCK 43
>
> +/*
> + * LSM_ATTR_XXX values identify the /proc/.../attr entry that the
> + * context represents. Not all security modules provide all of these
> + * values. Some security modules provide none of them.
> + */
> +/* clang-format off */

Why this comment? That shouldn't be in uapi files. Or any header
files.

> +#define LSM_ATTR_CURRENT (1UL << 0)
> +#define LSM_ATTR_EXEC (1UL << 1)
> +#define LSM_ATTR_FSCREATE (1UL << 2)
> +#define LSM_ATTR_KEYCREATE (1UL << 3)
> +#define LSM_ATTR_PREV (1UL << 4)
> +#define LSM_ATTR_SOCKCREATE (1UL << 5)
> +/* clang-format on */

Again, please drop.

Where is it documented what these attributes actually mean?

thanks,

greg k-h