diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/exec.c | 10 | ||||
-rw-r--r-- | fs/file_table.c | 2 | ||||
-rw-r--r-- | fs/inode.c | 24 | ||||
-rw-r--r-- | fs/namei.c | 8 |
4 files changed, 37 insertions, 7 deletions
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/proc_fs.h> | 45 | #include <linux/proc_fs.h> |
46 | #include <linux/mount.h> | 46 | #include <linux/mount.h> |
47 | #include <linux/security.h> | 47 | #include <linux/security.h> |
48 | #include <linux/ima.h> | ||
48 | #include <linux/syscalls.h> | 49 | #include <linux/syscalls.h> |
49 | #include <linux/tsacct_kern.h> | 50 | #include <linux/tsacct_kern.h> |
50 | #include <linux/cn_proc.h> | 51 | #include <linux/cn_proc.h> |
@@ -127,6 +128,9 @@ SYSCALL_DEFINE1(uselib, const char __user *, library) | |||
127 | MAY_READ | MAY_EXEC | MAY_OPEN); | 128 | MAY_READ | MAY_EXEC | MAY_OPEN); |
128 | if (error) | 129 | if (error) |
129 | goto exit; | 130 | goto exit; |
131 | error = ima_path_check(&nd.path, MAY_READ | MAY_EXEC | MAY_OPEN); | ||
132 | if (error) | ||
133 | goto exit; | ||
130 | 134 | ||
131 | file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); | 135 | file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
132 | error = PTR_ERR(file); | 136 | error = PTR_ERR(file); |
@@ -674,6 +678,9 @@ struct file *open_exec(const char *name) | |||
674 | err = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_OPEN); | 678 | err = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_OPEN); |
675 | if (err) | 679 | if (err) |
676 | goto out_path_put; | 680 | goto out_path_put; |
681 | err = ima_path_check(&nd.path, MAY_EXEC | MAY_OPEN); | ||
682 | if (err) | ||
683 | goto out_path_put; | ||
677 | 684 | ||
678 | file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); | 685 | file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); |
679 | if (IS_ERR(file)) | 686 | if (IS_ERR(file)) |
@@ -1168,6 +1175,9 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1168 | retval = security_bprm_check(bprm); | 1175 | retval = security_bprm_check(bprm); |
1169 | if (retval) | 1176 | if (retval) |
1170 | return retval; | 1177 | return retval; |
1178 | retval = ima_bprm_check(bprm); | ||
1179 | if (retval) | ||
1180 | return retval; | ||
1171 | 1181 | ||
1172 | /* kernel module loader fixup */ | 1182 | /* kernel module loader fixup */ |
1173 | /* so we don't try to load run modprobe in kernel space. */ | 1183 | /* so we don't try to load run modprobe in kernel space. */ |
diff --git a/fs/file_table.c b/fs/file_table.c index bbeeac6efa1a..da806aceae3f 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
15 | #include <linux/security.h> | 15 | #include <linux/security.h> |
16 | #include <linux/ima.h> | ||
16 | #include <linux/eventpoll.h> | 17 | #include <linux/eventpoll.h> |
17 | #include <linux/rcupdate.h> | 18 | #include <linux/rcupdate.h> |
18 | #include <linux/mount.h> | 19 | #include <linux/mount.h> |
@@ -279,6 +280,7 @@ void __fput(struct file *file) | |||
279 | if (file->f_op && file->f_op->release) | 280 | if (file->f_op && file->f_op->release) |
280 | file->f_op->release(inode, file); | 281 | file->f_op->release(inode, file); |
281 | security_file_free(file); | 282 | security_file_free(file); |
283 | ima_file_free(file); | ||
282 | if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL)) | 284 | if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL)) |
283 | cdev_put(inode->i_cdev); | 285 | cdev_put(inode->i_cdev); |
284 | fops_put(file->f_op); | 286 | fops_put(file->f_op); |
diff --git a/fs/inode.c b/fs/inode.c index 913ab2d9a5d1..40e37c026565 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/hash.h> | 17 | #include <linux/hash.h> |
18 | #include <linux/swap.h> | 18 | #include <linux/swap.h> |
19 | #include <linux/security.h> | 19 | #include <linux/security.h> |
20 | #include <linux/ima.h> | ||
20 | #include <linux/pagemap.h> | 21 | #include <linux/pagemap.h> |
21 | #include <linux/cdev.h> | 22 | #include <linux/cdev.h> |
22 | #include <linux/bootmem.h> | 23 | #include <linux/bootmem.h> |
@@ -147,13 +148,13 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode) | |||
147 | inode->i_cdev = NULL; | 148 | inode->i_cdev = NULL; |
148 | inode->i_rdev = 0; | 149 | inode->i_rdev = 0; |
149 | inode->dirtied_when = 0; | 150 | inode->dirtied_when = 0; |
150 | if (security_inode_alloc(inode)) { | 151 | |
151 | if (inode->i_sb->s_op->destroy_inode) | 152 | if (security_inode_alloc(inode)) |
152 | inode->i_sb->s_op->destroy_inode(inode); | 153 | goto out_free_inode; |
153 | else | 154 | |
154 | kmem_cache_free(inode_cachep, (inode)); | 155 | /* allocate and initialize an i_integrity */ |
155 | return NULL; | 156 | if (ima_inode_alloc(inode)) |
156 | } | 157 | goto out_free_security; |
157 | 158 | ||
158 | spin_lock_init(&inode->i_lock); | 159 | spin_lock_init(&inode->i_lock); |
159 | lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key); | 160 | lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key); |
@@ -189,6 +190,15 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode) | |||
189 | inode->i_mapping = mapping; | 190 | inode->i_mapping = mapping; |
190 | 191 | ||
191 | return inode; | 192 | return inode; |
193 | |||
194 | out_free_security: | ||
195 | security_inode_free(inode); | ||
196 | out_free_inode: | ||
197 | if (inode->i_sb->s_op->destroy_inode) | ||
198 | inode->i_sb->s_op->destroy_inode(inode); | ||
199 | else | ||
200 | kmem_cache_free(inode_cachep, (inode)); | ||
201 | return NULL; | ||
192 | } | 202 | } |
193 | EXPORT_SYMBOL(inode_init_always); | 203 | EXPORT_SYMBOL(inode_init_always); |
194 | 204 | ||
diff --git a/fs/namei.c b/fs/namei.c index bbc15c237558..199317642ad6 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/fsnotify.h> | 24 | #include <linux/fsnotify.h> |
25 | #include <linux/personality.h> | 25 | #include <linux/personality.h> |
26 | #include <linux/security.h> | 26 | #include <linux/security.h> |
27 | #include <linux/ima.h> | ||
27 | #include <linux/syscalls.h> | 28 | #include <linux/syscalls.h> |
28 | #include <linux/mount.h> | 29 | #include <linux/mount.h> |
29 | #include <linux/audit.h> | 30 | #include <linux/audit.h> |
@@ -850,6 +851,8 @@ static int __link_path_walk(const char *name, struct nameidata *nd) | |||
850 | if (err == -EAGAIN) | 851 | if (err == -EAGAIN) |
851 | err = inode_permission(nd->path.dentry->d_inode, | 852 | err = inode_permission(nd->path.dentry->d_inode, |
852 | MAY_EXEC); | 853 | MAY_EXEC); |
854 | if (!err) | ||
855 | err = ima_path_check(&nd->path, MAY_EXEC); | ||
853 | if (err) | 856 | if (err) |
854 | break; | 857 | break; |
855 | 858 | ||
@@ -1509,6 +1512,11 @@ int may_open(struct path *path, int acc_mode, int flag) | |||
1509 | error = inode_permission(inode, acc_mode); | 1512 | error = inode_permission(inode, acc_mode); |
1510 | if (error) | 1513 | if (error) |
1511 | return error; | 1514 | return error; |
1515 | |||
1516 | error = ima_path_check(path, | ||
1517 | acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC)); | ||
1518 | if (error) | ||
1519 | return error; | ||
1512 | /* | 1520 | /* |
1513 | * An append-only file must be opened in append mode for writing. | 1521 | * An append-only file must be opened in append mode for writing. |
1514 | */ | 1522 | */ |