History

vfs: Add LSM hooks for the new mount API

Add LSM hooks for use by the new mount API and filesystem context code. This includes: (1) Hooks to handle allocation, duplication and freeing of the security record attached to a filesystem context. (2) A hook to snoop source specifications. There may be multiple of these if the filesystem supports it. They will to be local files/devices if fs_context::source_is_dev is true and will be something else, possibly remote server specifications, if false. (3) A hook to snoop superblock configuration options in key[=val] form. If the LSM decides it wants to handle it, it can suppress the option being passed to the filesystem. Note that 'val' may include commas and binary data with the fsopen patch. (4) A hook to perform validation and allocation after the configuration has been done but before the superblock is allocated and set up. (5) A hook to transfer the security from the context to a newly created superblock. (6) A hook to rule on whether a path point can be used as a mountpoint. These are intended to replace: security_sb_copy_data security_sb_kern_mount security_sb_mount security_sb_set_mnt_opts security_sb_clone_mnt_opts security_sb_parse_opts_str [AV -- some of the methods being replaced are already gone, some of the methods are not added for the lack of need]

David Howells committed 8 years ago

Commit da2441f1 parent 31d921c3 files · +29 −0Browse files

Showing the changes to include (2 of 3 files). Show all

Unified · Split

2 files
  1. include/linux/lsm_hooks.h +14 −0
  2. include/linux/security.h +10 −0
include/linux/lsm_hooks.h+14−0
@@ -76,6 +76,17 @@ · 75 unmodified lines
76 * changes on the process such as clearing out non-inheritable signal76 * changes on the process such as clearing out non-inheritable signal
77 * state. This is called immediately after commit_creds().77 * state. This is called immediately after commit_creds().
78 *78 *
79 * Security hooks for mount using fs_context.
80 * [See also Documentation/filesystems/mounting.txt]
81 *
82 * @fs_context_parse_param:
83 * Userspace provided a parameter to configure a superblock. The LSM may
84 * reject it with an error and may use it for itself, in which case it
85 * should return 0; otherwise it should return -ENOPARAM to pass it on to
86 * the filesystem.
87 * @fc indicates the filesystem context.
88 * @param The parameter
89 *
79 * Security hooks for filesystem operations.90 * Security hooks for filesystem operations.
80 *91 *
81 * @sb_alloc_security:92 * @sb_alloc_security:
@@ -1459,6 +1470,8 @@ union security_list_options { · 1377 unmodified lines
1459 void (*bprm_committing_creds)(struct linux_binprm *bprm);1470 void (*bprm_committing_creds)(struct linux_binprm *bprm);
1460 void (*bprm_committed_creds)(struct linux_binprm *bprm);1471 void (*bprm_committed_creds)(struct linux_binprm *bprm);
1461 1472
1473 int (*fs_context_parse_param)(struct fs_context *fc, struct fs_parameter *param);
1474
1462 int (*sb_alloc_security)(struct super_block *sb);1475 int (*sb_alloc_security)(struct super_block *sb);
1463 void (*sb_free_security)(struct super_block *sb);1476 void (*sb_free_security)(struct super_block *sb);
1464 void (*sb_free_mnt_opts)(void *mnt_opts);1477 void (*sb_free_mnt_opts)(void *mnt_opts);
@@ -1800,6 +1813,7 @@ struct security_hook_heads { · 335 unmodified lines
1800 struct hlist_head bprm_check_security;1813 struct hlist_head bprm_check_security;
1801 struct hlist_head bprm_committing_creds;1814 struct hlist_head bprm_committing_creds;
1802 struct hlist_head bprm_committed_creds;1815 struct hlist_head bprm_committed_creds;
1816 struct hlist_head fs_context_parse_param;
1803 struct hlist_head sb_alloc_security;1817 struct hlist_head sb_alloc_security;
1804 struct hlist_head sb_free_security;1818 struct hlist_head sb_free_security;
1805 struct hlist_head sb_free_mnt_opts;1819 struct hlist_head sb_free_mnt_opts;
include/linux/security.h+10−0
@@ -53,6 +53,9 @@ struct msg_msg; · 52 unmodified lines
53struct xattr;53struct xattr;
54struct xfrm_sec_ctx;54struct xfrm_sec_ctx;
55struct mm_struct;55struct mm_struct;
56struct fs_context;
57struct fs_parameter;
58enum fs_value_type;
56 59
57/* If capable should audit the security request */60/* If capable should audit the security request */
58#define SECURITY_CAP_NOAUDIT 061#define SECURITY_CAP_NOAUDIT 0
@@ -220,6 +223,7 @@ int security_bprm_set_creds(struct linux_binprm *bprm); · 161 unmodified lines
220int security_bprm_check(struct linux_binprm *bprm);223int security_bprm_check(struct linux_binprm *bprm);
221void security_bprm_committing_creds(struct linux_binprm *bprm);224void security_bprm_committing_creds(struct linux_binprm *bprm);
222void security_bprm_committed_creds(struct linux_binprm *bprm);225void security_bprm_committed_creds(struct linux_binprm *bprm);
226int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
223int security_sb_alloc(struct super_block *sb);227int security_sb_alloc(struct super_block *sb);
224void security_sb_free(struct super_block *sb);228void security_sb_free(struct super_block *sb);
225void security_free_mnt_opts(void **mnt_opts);229void security_free_mnt_opts(void **mnt_opts);
@@ -517,6 +521,12 @@ static inline void security_bprm_committed_creds(struct linux_binprm *bprm) · 291 unmodified lines
517{521{
518}522}
519 523
524static inline int security_fs_context_parse_param(struct fs_context *fc,
525 struct fs_parameter *param)
526{
527 return -ENOPARAM;
528}
529
520static inline int security_sb_alloc(struct super_block *sb)530static inline int security_sb_alloc(struct super_block *sb)
521{531{
522 return 0;532 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t