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
7676 * changes on the process such as clearing out non-inheritable signal
7777 * state. This is called immediately after commit_creds().
7878 *
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+ *
7990 * Security hooks for filesystem operations.
8091 *
8192 * @sb_alloc_security:
@@ -1459,6 +1470,8 @@ union security_list_options { · 1377 unmodified lines
14591470 void (*bprm_committing_creds)(struct linux_binprm *bprm);
14601471 void (*bprm_committed_creds)(struct linux_binprm *bprm);
14611472
1473+ int (*fs_context_parse_param)(struct fs_context *fc, struct fs_parameter *param);
1474+
14621475 int (*sb_alloc_security)(struct super_block *sb);
14631476 void (*sb_free_security)(struct super_block *sb);
14641477 void (*sb_free_mnt_opts)(void *mnt_opts);
@@ -1800,6 +1813,7 @@ struct security_hook_heads { · 335 unmodified lines
18001813 struct hlist_head bprm_check_security;
18011814 struct hlist_head bprm_committing_creds;
18021815 struct hlist_head bprm_committed_creds;
1816+ struct hlist_head fs_context_parse_param;
18031817 struct hlist_head sb_alloc_security;
18041818 struct hlist_head sb_free_security;
18051819 struct hlist_head sb_free_mnt_opts;
include/linux/security.h+10−0
@@ -53,6 +53,9 @@ struct msg_msg; · 52 unmodified lines
5353 struct xattr;
5454 struct xfrm_sec_ctx;
5555 struct mm_struct;
56+struct fs_context;
57+struct fs_parameter;
58+enum fs_value_type;
5659
5760 /* If capable should audit the security request */
5861 #define SECURITY_CAP_NOAUDIT 0
@@ -220,6 +223,7 @@ int security_bprm_set_creds(struct linux_binprm *bprm); · 161 unmodified lines
220223 int security_bprm_check(struct linux_binprm *bprm);
221224 void security_bprm_committing_creds(struct linux_binprm *bprm);
222225 void security_bprm_committed_creds(struct linux_binprm *bprm);
226+int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
223227 int security_sb_alloc(struct super_block *sb);
224228 void security_sb_free(struct super_block *sb);
225229 void 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
517521 {
518522 }
519523
524+static inline int security_fs_context_parse_param(struct fs_context *fc,
525+ struct fs_parameter *param)
526+{
527+ return -ENOPARAM;
528+}
529+
520530 static inline int security_sb_alloc(struct super_block *sb)
521531 {
522532 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