mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-08 21:22:09 -04:00
BACKPORT: security: add inode_init_security_anon() LSM hook
This change adds a new LSM hook, inode_init_security_anon(), that will
be used while creating secure anonymous inodes. The hook allows/denies
its creation and assigns a security context to the inode.
The new hook accepts an optional context_inode parameter that callers
can use to provide additional contextual information to security modules
for granting/denying permission to create an anon-inode of the same type.
This context_inode's security_context can also be used to initialize the
newly created anon-inode's security_context.
Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
(cherry picked from commit 215b674b84dd052098fe6389e32a5afaff8b4d56)
Conflicts:
include/linux/lsm_hook_defs.h
(1. Added LSM hook in lsm_hook.h and removd lsm_hook_defs.h as per
98e828a0650f348be85728c69875260cf78069e6, which is not merged here)
Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
Bug: 160737021
Bug: 169683130
Change-Id: I83fe318c891f034b4dd7f3f357cc74964b55ffc8
This commit is contained in:
parent
a04582fb0f
commit
4849cd6fa3
3 changed files with 31 additions and 0 deletions
|
|
@ -215,6 +215,15 @@
|
|||
* Returns 0 if @name and @value have been successfully set,
|
||||
* -EOPNOTSUPP if no security attribute is needed, or
|
||||
* -ENOMEM on memory allocation failure.
|
||||
* @inode_init_security_anon:
|
||||
* Set up the incore security field for the new anonymous inode
|
||||
* and return whether the inode creation is permitted by the security
|
||||
* module or not.
|
||||
* @inode contains the inode structure
|
||||
* @name name of the anonymous inode class
|
||||
* @context_inode optional related inode
|
||||
* Returns 0 on success, -EACCES if the security module denies the
|
||||
* creation of this inode, or another -errno upon other errors.
|
||||
* @inode_create:
|
||||
* Check permission to create a regular file.
|
||||
* @dir contains inode structure of the parent of the new file.
|
||||
|
|
@ -1558,6 +1567,9 @@ union security_list_options {
|
|||
const struct qstr *qstr,
|
||||
const char **name, void **value,
|
||||
size_t *len);
|
||||
int (*inode_init_security_anon)(struct inode *inode,
|
||||
const struct qstr *name,
|
||||
const struct inode *context_inode);
|
||||
int (*inode_create)(struct inode *dir, struct dentry *dentry,
|
||||
umode_t mode);
|
||||
int (*inode_link)(struct dentry *old_dentry, struct inode *dir,
|
||||
|
|
@ -1892,6 +1904,7 @@ struct security_hook_heads {
|
|||
struct hlist_head inode_alloc_security;
|
||||
struct hlist_head inode_free_security;
|
||||
struct hlist_head inode_init_security;
|
||||
struct hlist_head inode_init_security_anon;
|
||||
struct hlist_head inode_create;
|
||||
struct hlist_head inode_link;
|
||||
struct hlist_head inode_unlink;
|
||||
|
|
|
|||
|
|
@ -320,6 +320,9 @@ void security_inode_free(struct inode *inode);
|
|||
int security_inode_init_security(struct inode *inode, struct inode *dir,
|
||||
const struct qstr *qstr,
|
||||
initxattrs initxattrs, void *fs_data);
|
||||
int security_inode_init_security_anon(struct inode *inode,
|
||||
const struct qstr *name,
|
||||
const struct inode *context_inode);
|
||||
int security_old_inode_init_security(struct inode *inode, struct inode *dir,
|
||||
const struct qstr *qstr, const char **name,
|
||||
void **value, size_t *len);
|
||||
|
|
@ -724,6 +727,13 @@ static inline int security_inode_init_security(struct inode *inode,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int security_inode_init_security_anon(struct inode *inode,
|
||||
const struct qstr *name,
|
||||
const struct inode *context_inode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int security_old_inode_init_security(struct inode *inode,
|
||||
struct inode *dir,
|
||||
const struct qstr *qstr,
|
||||
|
|
|
|||
|
|
@ -1014,6 +1014,14 @@ out:
|
|||
}
|
||||
EXPORT_SYMBOL(security_inode_init_security);
|
||||
|
||||
int security_inode_init_security_anon(struct inode *inode,
|
||||
const struct qstr *name,
|
||||
const struct inode *context_inode)
|
||||
{
|
||||
return call_int_hook(inode_init_security_anon, 0, inode, name,
|
||||
context_inode);
|
||||
}
|
||||
|
||||
int security_old_inode_init_security(struct inode *inode, struct inode *dir,
|
||||
const struct qstr *qstr, const char **name,
|
||||
void **value, size_t *len)
|
||||
|
|
|
|||
Loading…
Reference in a new issue