[PATCH v39 34/42] LSM: Add mount opts blob size tracking
Casey Schaufler
casey at schaufler-ca.com
Fri Dec 15 22:16:28 UTC 2023
Add mount option data to the blob size accounting in anticipation
of using a shared mnt_opts blob.
Signed-off-by: Casey Schaufler <casey at schaufler-ca.com>
---
include/linux/lsm_hooks.h | 1 +
security/security.c | 2 ++
security/selinux/hooks.c | 1 +
security/smack/smack_lsm.c | 1 +
4 files changed, 5 insertions(+)
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
index 4deb1a4d2d1a..59085248809a 100644
--- a/include/linux/lsm_hooks.h
+++ b/include/linux/lsm_hooks.h
@@ -81,6 +81,7 @@ struct lsm_blob_sizes {
int lbs_msg_msg;
int lbs_task;
int lbs_xattr_count; /* number of xattr slots in new_xattrs array */
+ int lbs_mnt_opts;
bool lbs_secmark; /* expressed desire for secmark use */
};
diff --git a/security/security.c b/security/security.c
index 8576121fadb9..fd429f67d2da 100644
--- a/security/security.c
+++ b/security/security.c
@@ -232,6 +232,7 @@ static void __init lsm_set_blob_sizes(struct lsm_blob_sizes *needed)
lsm_set_blob_size(&needed->lbs_task, &blob_sizes.lbs_task);
lsm_set_blob_size(&needed->lbs_xattr_count,
&blob_sizes.lbs_xattr_count);
+ lsm_set_blob_size(&needed->lbs_mnt_opts, &blob_sizes.lbs_mnt_opts);
if (needed->lbs_secmark) {
if (!blob_sizes.lbs_secmark)
blob_sizes.lbs_secmark = true;
@@ -453,6 +454,7 @@ static void __init ordered_lsm_init(void)
init_debug("superblock blob size = %d\n", blob_sizes.lbs_superblock);
init_debug("task blob size = %d\n", blob_sizes.lbs_task);
init_debug("xattr slots = %d\n", blob_sizes.lbs_xattr_count);
+ init_debug("mnt_opts blob size = %d\n", blob_sizes.lbs_mnt_opts);
/*
* Create any kmem_caches needed for blobs
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 3e590f632f59..e0f6f2093708 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -6970,6 +6970,7 @@ struct lsm_blob_sizes selinux_blob_sizes __ro_after_init = {
.lbs_sock = sizeof(struct sk_security_struct),
.lbs_superblock = sizeof(struct superblock_security_struct),
.lbs_xattr_count = SELINUX_INODE_INIT_XATTRS,
+ .lbs_mnt_opts = sizeof(struct selinux_mnt_opts),
.lbs_secmark = true,
};
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index c93e81facf1b..573d5bffb9e1 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -5064,6 +5064,7 @@ struct lsm_blob_sizes smack_blob_sizes __ro_after_init = {
.lbs_sock = sizeof(struct socket_smack),
.lbs_superblock = sizeof(struct superblock_smack),
.lbs_xattr_count = SMACK_INODE_INIT_XATTRS,
+ .lbs_mnt_opts = sizeof(struct smack_mnt_opts),
.lbs_secmark = true,
};
--
2.41.0
More information about the Linux-security-module-archive
mailing list