|
151 | 151 | * @name name of the last path component used to create file |
152 | 152 | * @ctx pointer to place the pointer to the resulting context in. |
153 | 153 | * @ctxlen point to place the length of the resulting context. |
| 154 | + * @dentry_create_files_as: |
| 155 | + * Compute a context for a dentry as the inode is not yet available |
| 156 | + * and set that context in passed in creds so that new files are |
| 157 | + * created using that context. Context is calculated using the |
| 158 | + * passed in creds and not the creds of the caller. |
| 159 | + * @dentry dentry to use in calculating the context. |
| 160 | + * @mode mode used to determine resource type. |
| 161 | + * @name name of the last path component used to create file |
| 162 | + * @old creds which should be used for context calculation |
| 163 | + * @new creds to modify |
154 | 164 | * |
155 | 165 | * |
156 | 166 | * Security hooks for inode operations. |
|
401 | 411 | * @inode contains a pointer to the inode. |
402 | 412 | * @secid contains a pointer to the location where result will be saved. |
403 | 413 | * In case of failure, @secid will be set to zero. |
| 414 | + * @inode_copy_up: |
| 415 | + * A file is about to be copied up from lower layer to upper layer of |
| 416 | + * overlay filesystem. Security module can prepare a set of new creds |
| 417 | + * and modify as need be and return new creds. Caller will switch to |
| 418 | + * new creds temporarily to create new file and release newly allocated |
| 419 | + * creds. |
| 420 | + * @src indicates the union dentry of file that is being copied up. |
| 421 | + * @new pointer to pointer to return newly allocated creds. |
| 422 | + * Returns 0 on success or a negative error code on error. |
| 423 | + * @inode_copy_up_xattr: |
| 424 | + * Filter the xattrs being copied up when a unioned file is copied |
| 425 | + * up from a lower layer to the union/overlay layer. |
| 426 | + * @name indicates the name of the xattr. |
| 427 | + * Returns 0 to accept the xattr, 1 to discard the xattr, -EOPNOTSUPP if |
| 428 | + * security module does not know about attribute or a negative error code |
| 429 | + * to abort the copy up. Note that the caller is responsible for reading |
| 430 | + * and writing the xattrs as this hook is merely a filter. |
404 | 431 | * |
405 | 432 | * Security hooks for file operations |
406 | 433 | * |
@@ -1358,6 +1385,10 @@ union security_list_options { |
1358 | 1385 | int (*dentry_init_security)(struct dentry *dentry, int mode, |
1359 | 1386 | const struct qstr *name, void **ctx, |
1360 | 1387 | u32 *ctxlen); |
| 1388 | + int (*dentry_create_files_as)(struct dentry *dentry, int mode, |
| 1389 | + struct qstr *name, |
| 1390 | + const struct cred *old, |
| 1391 | + struct cred *new); |
1361 | 1392 |
|
1362 | 1393 |
|
1363 | 1394 | #ifdef CONFIG_SECURITY_PATH |
@@ -1425,6 +1456,8 @@ union security_list_options { |
1425 | 1456 | int (*inode_listsecurity)(struct inode *inode, char *buffer, |
1426 | 1457 | size_t buffer_size); |
1427 | 1458 | void (*inode_getsecid)(struct inode *inode, u32 *secid); |
| 1459 | + int (*inode_copy_up)(struct dentry *src, struct cred **new); |
| 1460 | + int (*inode_copy_up_xattr)(const char *name); |
1428 | 1461 |
|
1429 | 1462 | int (*file_permission)(struct file *file, int mask); |
1430 | 1463 | int (*file_alloc_security)(struct file *file); |
@@ -1655,6 +1688,7 @@ struct security_hook_heads { |
1655 | 1688 | struct list_head sb_clone_mnt_opts; |
1656 | 1689 | struct list_head sb_parse_opts_str; |
1657 | 1690 | struct list_head dentry_init_security; |
| 1691 | + struct list_head dentry_create_files_as; |
1658 | 1692 | #ifdef CONFIG_SECURITY_PATH |
1659 | 1693 | struct list_head path_unlink; |
1660 | 1694 | struct list_head path_mkdir; |
@@ -1695,6 +1729,8 @@ struct security_hook_heads { |
1695 | 1729 | struct list_head inode_setsecurity; |
1696 | 1730 | struct list_head inode_listsecurity; |
1697 | 1731 | struct list_head inode_getsecid; |
| 1732 | + struct list_head inode_copy_up; |
| 1733 | + struct list_head inode_copy_up_xattr; |
1698 | 1734 | struct list_head file_permission; |
1699 | 1735 | struct list_head file_alloc_security; |
1700 | 1736 | struct list_head file_free_security; |
|
0 commit comments