mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
fs/vfs/security: pass last path component to LSM on inode creation
SELinux would like to implement a new labeling behavior of newly created inodes. We currently label new inodes based on the parent and the creating process. This new behavior would also take into account the name of the new object when deciding the new label. This is not the (supposed) full path, just the last component of the path. This is very useful because creating /etc/shadow is different than creating /etc/passwd but the kernel hooks are unable to differentiate these operations. We currently require that userspace realize it is doing some difficult operation like that and than userspace jumps through SELinux hoops to get things set up correctly. This patch does not implement new behavior, that is obviously contained in a seperate SELinux patch, but it does pass the needed name down to the correct LSM hook. If no such name exists it is fine to pass NULL. Signed-off-by: Eric Paris <[email protected]>
This commit is contained in:
parent
821404434f
commit
2a7dba391e
39 changed files with 136 additions and 94 deletions
|
|
@ -110,7 +110,7 @@ extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
|
|||
extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int);
|
||||
|
||||
/* ialloc.c */
|
||||
extern struct inode * ext2_new_inode (struct inode *, int);
|
||||
extern struct inode * ext2_new_inode (struct inode *, int, const struct qstr *);
|
||||
extern void ext2_free_inode (struct inode *);
|
||||
extern unsigned long ext2_count_free_inodes (struct super_block *);
|
||||
extern void ext2_check_inodes_bitmap (struct super_block *);
|
||||
|
|
|
|||
|
|
@ -429,7 +429,8 @@ found:
|
|||
return group;
|
||||
}
|
||||
|
||||
struct inode *ext2_new_inode(struct inode *dir, int mode)
|
||||
struct inode *ext2_new_inode(struct inode *dir, int mode,
|
||||
const struct qstr *qstr)
|
||||
{
|
||||
struct super_block *sb;
|
||||
struct buffer_head *bitmap_bh = NULL;
|
||||
|
|
@ -585,7 +586,7 @@ got:
|
|||
if (err)
|
||||
goto fail_free_drop;
|
||||
|
||||
err = ext2_init_security(inode,dir);
|
||||
err = ext2_init_security(inode, dir, qstr);
|
||||
if (err)
|
||||
goto fail_free_drop;
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, st
|
|||
|
||||
dquot_initialize(dir);
|
||||
|
||||
inode = ext2_new_inode(dir, mode);
|
||||
inode = ext2_new_inode(dir, mode, &dentry->d_name);
|
||||
if (IS_ERR(inode))
|
||||
return PTR_ERR(inode);
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_
|
|||
|
||||
dquot_initialize(dir);
|
||||
|
||||
inode = ext2_new_inode (dir, mode);
|
||||
inode = ext2_new_inode (dir, mode, &dentry->d_name);
|
||||
err = PTR_ERR(inode);
|
||||
if (!IS_ERR(inode)) {
|
||||
init_special_inode(inode, inode->i_mode, rdev);
|
||||
|
|
@ -159,7 +159,7 @@ static int ext2_symlink (struct inode * dir, struct dentry * dentry,
|
|||
|
||||
dquot_initialize(dir);
|
||||
|
||||
inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO);
|
||||
inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO, &dentry->d_name);
|
||||
err = PTR_ERR(inode);
|
||||
if (IS_ERR(inode))
|
||||
goto out;
|
||||
|
|
@ -230,7 +230,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
|
|||
|
||||
inode_inc_link_count(dir);
|
||||
|
||||
inode = ext2_new_inode (dir, S_IFDIR | mode);
|
||||
inode = ext2_new_inode(dir, S_IFDIR | mode, &dentry->d_name);
|
||||
err = PTR_ERR(inode);
|
||||
if (IS_ERR(inode))
|
||||
goto out_dir;
|
||||
|
|
|
|||
|
|
@ -116,9 +116,11 @@ exit_ext2_xattr(void)
|
|||
# endif /* CONFIG_EXT2_FS_XATTR */
|
||||
|
||||
#ifdef CONFIG_EXT2_FS_SECURITY
|
||||
extern int ext2_init_security(struct inode *inode, struct inode *dir);
|
||||
extern int ext2_init_security(struct inode *inode, struct inode *dir,
|
||||
const struct qstr *qstr);
|
||||
#else
|
||||
static inline int ext2_init_security(struct inode *inode, struct inode *dir)
|
||||
static inline int ext2_init_security(struct inode *inode, struct inode *dir,
|
||||
const struct qstr *qstr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,14 +47,15 @@ ext2_xattr_security_set(struct dentry *dentry, const char *name,
|
|||
}
|
||||
|
||||
int
|
||||
ext2_init_security(struct inode *inode, struct inode *dir)
|
||||
ext2_init_security(struct inode *inode, struct inode *dir,
|
||||
const struct qstr *qstr)
|
||||
{
|
||||
int err;
|
||||
size_t len;
|
||||
void *value;
|
||||
char *name;
|
||||
|
||||
err = security_inode_init_security(inode, dir, &name, &value, &len);
|
||||
err = security_inode_init_security(inode, dir, qstr, &name, &value, &len);
|
||||
if (err) {
|
||||
if (err == -EOPNOTSUPP)
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue