@@ -112,7 +112,7 @@ LSM_HOOK(int, 0, inode_alloc_security, struct inode *inode)
LSM_HOOK(void, LSM_RET_VOID, inode_free_security, struct inode *inode)
LSM_HOOK(int, 0, inode_init_security, struct inode *inode,
struct inode *dir, const struct qstr *qstr, const char **name,
- void **value, size_t *len)
+ void **value, size_t *len, struct xattr *lsm_xattrs)
LSM_HOOK(int, 0, inode_init_security_anon, struct inode *inode,
const struct qstr *name, const struct inode *context_inode)
LSM_HOOK(int, 0, inode_create, struct inode *dir, struct dentry *dentry,
@@ -230,6 +230,7 @@
* @name will be set to the allocated name suffix (e.g. selinux).
* @value will be set to the allocated attribute value.
* @len will be set to the length of the value.
+ * @lsm_xattrs contains the full array of xattrs allocated by LSMs.
* Returns 0 if @name and @value have been successfully set,
* -EOPNOTSUPP if no security attribute is needed, or
* -ENOMEM on memory allocation failure.
@@ -1036,7 +1036,7 @@ int security_inode_init_security(struct inode *inode, struct inode *dir,
if (!initxattrs)
return call_int_hook(inode_init_security, -EOPNOTSUPP, inode,
- dir, qstr, NULL, NULL, NULL);
+ dir, qstr, NULL, NULL, NULL, NULL);
/* Determine at run-time the max number of xattr structs to allocate. */
hlist_for_each_entry(P, &security_hook_heads.inode_init_security, list)
@@ -1056,7 +1056,8 @@ int security_inode_init_security(struct inode *inode, struct inode *dir,
ret = P->hook.inode_init_security(inode, dir, qstr,
&lsm_xattr->name,
&lsm_xattr->value,
- &lsm_xattr->value_len);
+ &lsm_xattr->value_len,
+ new_xattrs);
if (ret && ret != -EOPNOTSUPP)
goto out;
@@ -1112,7 +1113,7 @@ int security_old_inode_init_security(struct inode *inode, struct inode *dir,
hlist_for_each_entry(P, &security_hook_heads.inode_init_security,
list) {
ret = P->hook.inode_init_security(inode, dir, qstr,
- name, value, len);
+ name, value, len, NULL);
if (ret && ret != -EOPNOTSUPP)
return ret;
@@ -2917,7 +2917,8 @@ static int selinux_dentry_create_files_as(struct dentry *dentry, int mode,
static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
const struct qstr *qstr,
const char **name,
- void **value, size_t *len)
+ void **value, size_t *len,
+ struct xattr *lsm_xattrs)
{
const struct task_security_struct *tsec = selinux_cred(current_cred());
struct superblock_security_struct *sbsec;
@@ -965,12 +965,14 @@ static int smack_inode_alloc_security(struct inode *inode)
* @name: where to put the attribute name
* @value: where to put the attribute value
* @len: where to put the length of the attribute
+ * @lsm_xattrs: unused
*
* Returns 0 if it all works out, -ENOMEM if there's no memory
*/
static int smack_inode_init_security(struct inode *inode, struct inode *dir,
const struct qstr *qstr, const char **name,
- void **value, size_t *len)
+ void **value, size_t *len,
+ struct xattr *lsm_xattrs)
{
struct inode_smack *issp = smack_inode(inode);
struct smack_known *skp = smk_of_current();
In preparation for moving EVM to the LSM infrastructure, this patch adds the full array of xattrs allocated by LSMs as a new parameter of the inode_init_security hook. It will be used by EVM to calculate the HMAC on all xattrs. This solution has been preferred to directly replacing the xattr name, value and len with the full array, as LSMs would have had to scan it to find an empty slot. Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> --- include/linux/lsm_hook_defs.h | 2 +- include/linux/lsm_hooks.h | 1 + security/security.c | 7 ++++--- security/selinux/hooks.c | 3 ++- security/smack/smack_lsm.c | 4 +++- 5 files changed, 11 insertions(+), 6 deletions(-)