diff options
Diffstat (limited to 'include/linux/security.h')
| -rw-r--r-- | include/linux/security.h | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/include/linux/security.h b/include/linux/security.h index 4686491852a7..a585a9085e46 100644 --- a/include/linux/security.h +++ b/include/linux/security.h | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/capability.h> | 26 | #include <linux/capability.h> |
| 27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
| 28 | #include <linux/err.h> | 28 | #include <linux/err.h> |
| 29 | #include <linux/string.h> | ||
| 29 | 30 | ||
| 30 | struct linux_binprm; | 31 | struct linux_binprm; |
| 31 | struct cred; | 32 | struct cred; |
| @@ -60,6 +61,9 @@ struct mm_struct; | |||
| 60 | #define SECURITY_CAP_NOAUDIT 0 | 61 | #define SECURITY_CAP_NOAUDIT 0 |
| 61 | #define SECURITY_CAP_AUDIT 1 | 62 | #define SECURITY_CAP_AUDIT 1 |
| 62 | 63 | ||
| 64 | /* LSM Agnostic defines for sb_set_mnt_opts */ | ||
| 65 | #define SECURITY_LSM_NATIVE_LABELS 1 | ||
| 66 | |||
| 63 | struct ctl_table; | 67 | struct ctl_table; |
| 64 | struct audit_krule; | 68 | struct audit_krule; |
| 65 | struct user_namespace; | 69 | struct user_namespace; |
| @@ -306,6 +310,15 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 306 | * Parse a string of security data filling in the opts structure | 310 | * Parse a string of security data filling in the opts structure |
| 307 | * @options string containing all mount options known by the LSM | 311 | * @options string containing all mount options known by the LSM |
| 308 | * @opts binary data structure usable by the LSM | 312 | * @opts binary data structure usable by the LSM |
| 313 | * @dentry_init_security: | ||
| 314 | * Compute a context for a dentry as the inode is not yet available | ||
| 315 | * since NFSv4 has no label backed by an EA anyway. | ||
| 316 | * @dentry dentry to use in calculating the context. | ||
| 317 | * @mode mode used to determine resource type. | ||
| 318 | * @name name of the last path component used to create file | ||
| 319 | * @ctx pointer to place the pointer to the resulting context in. | ||
| 320 | * @ctxlen point to place the length of the resulting context. | ||
| 321 | * | ||
| 309 | * | 322 | * |
| 310 | * Security hooks for inode operations. | 323 | * Security hooks for inode operations. |
| 311 | * | 324 | * |
| @@ -1313,6 +1326,13 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 1313 | * @pages contains the number of pages. | 1326 | * @pages contains the number of pages. |
| 1314 | * Return 0 if permission is granted. | 1327 | * Return 0 if permission is granted. |
| 1315 | * | 1328 | * |
| 1329 | * @ismaclabel: | ||
| 1330 | * Check if the extended attribute specified by @name | ||
| 1331 | * represents a MAC label. Returns 1 if name is a MAC | ||
| 1332 | * attribute otherwise returns 0. | ||
| 1333 | * @name full extended attribute name to check against | ||
| 1334 | * LSM as a MAC label. | ||
| 1335 | * | ||
| 1316 | * @secid_to_secctx: | 1336 | * @secid_to_secctx: |
| 1317 | * Convert secid to security context. If secdata is NULL the length of | 1337 | * Convert secid to security context. If secdata is NULL the length of |
| 1318 | * the result will be returned in seclen, but no secdata will be returned. | 1338 | * the result will be returned in seclen, but no secdata will be returned. |
| @@ -1439,10 +1459,16 @@ struct security_operations { | |||
| 1439 | int (*sb_pivotroot) (struct path *old_path, | 1459 | int (*sb_pivotroot) (struct path *old_path, |
| 1440 | struct path *new_path); | 1460 | struct path *new_path); |
| 1441 | int (*sb_set_mnt_opts) (struct super_block *sb, | 1461 | int (*sb_set_mnt_opts) (struct super_block *sb, |
| 1442 | struct security_mnt_opts *opts); | 1462 | struct security_mnt_opts *opts, |
| 1463 | unsigned long kern_flags, | ||
| 1464 | unsigned long *set_kern_flags); | ||
| 1443 | int (*sb_clone_mnt_opts) (const struct super_block *oldsb, | 1465 | int (*sb_clone_mnt_opts) (const struct super_block *oldsb, |
| 1444 | struct super_block *newsb); | 1466 | struct super_block *newsb); |
| 1445 | int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts); | 1467 | int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts); |
| 1468 | int (*dentry_init_security) (struct dentry *dentry, int mode, | ||
| 1469 | struct qstr *name, void **ctx, | ||
| 1470 | u32 *ctxlen); | ||
| 1471 | |||
| 1446 | 1472 | ||
| 1447 | #ifdef CONFIG_SECURITY_PATH | 1473 | #ifdef CONFIG_SECURITY_PATH |
| 1448 | int (*path_unlink) (struct path *dir, struct dentry *dentry); | 1474 | int (*path_unlink) (struct path *dir, struct dentry *dentry); |
| @@ -1590,6 +1616,7 @@ struct security_operations { | |||
| 1590 | 1616 | ||
| 1591 | int (*getprocattr) (struct task_struct *p, char *name, char **value); | 1617 | int (*getprocattr) (struct task_struct *p, char *name, char **value); |
| 1592 | int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size); | 1618 | int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size); |
| 1619 | int (*ismaclabel) (const char *name); | ||
| 1593 | int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen); | 1620 | int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen); |
| 1594 | int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid); | 1621 | int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid); |
| 1595 | void (*release_secctx) (char *secdata, u32 seclen); | 1622 | void (*release_secctx) (char *secdata, u32 seclen); |
| @@ -1725,10 +1752,16 @@ int security_sb_mount(const char *dev_name, struct path *path, | |||
| 1725 | const char *type, unsigned long flags, void *data); | 1752 | const char *type, unsigned long flags, void *data); |
| 1726 | int security_sb_umount(struct vfsmount *mnt, int flags); | 1753 | int security_sb_umount(struct vfsmount *mnt, int flags); |
| 1727 | int security_sb_pivotroot(struct path *old_path, struct path *new_path); | 1754 | int security_sb_pivotroot(struct path *old_path, struct path *new_path); |
| 1728 | int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts); | 1755 | int security_sb_set_mnt_opts(struct super_block *sb, |
| 1756 | struct security_mnt_opts *opts, | ||
| 1757 | unsigned long kern_flags, | ||
| 1758 | unsigned long *set_kern_flags); | ||
| 1729 | int security_sb_clone_mnt_opts(const struct super_block *oldsb, | 1759 | int security_sb_clone_mnt_opts(const struct super_block *oldsb, |
| 1730 | struct super_block *newsb); | 1760 | struct super_block *newsb); |
| 1731 | int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts); | 1761 | int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts); |
| 1762 | int security_dentry_init_security(struct dentry *dentry, int mode, | ||
| 1763 | struct qstr *name, void **ctx, | ||
| 1764 | u32 *ctxlen); | ||
| 1732 | 1765 | ||
| 1733 | int security_inode_alloc(struct inode *inode); | 1766 | int security_inode_alloc(struct inode *inode); |
| 1734 | void security_inode_free(struct inode *inode); | 1767 | void security_inode_free(struct inode *inode); |
| @@ -1840,6 +1873,7 @@ void security_d_instantiate(struct dentry *dentry, struct inode *inode); | |||
| 1840 | int security_getprocattr(struct task_struct *p, char *name, char **value); | 1873 | int security_getprocattr(struct task_struct *p, char *name, char **value); |
| 1841 | int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size); | 1874 | int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size); |
| 1842 | int security_netlink_send(struct sock *sk, struct sk_buff *skb); | 1875 | int security_netlink_send(struct sock *sk, struct sk_buff *skb); |
| 1876 | int security_ismaclabel(const char *name); | ||
| 1843 | int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen); | 1877 | int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen); |
| 1844 | int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid); | 1878 | int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid); |
| 1845 | void security_release_secctx(char *secdata, u32 seclen); | 1879 | void security_release_secctx(char *secdata, u32 seclen); |
| @@ -2011,7 +2045,9 @@ static inline int security_sb_pivotroot(struct path *old_path, | |||
| 2011 | } | 2045 | } |
| 2012 | 2046 | ||
| 2013 | static inline int security_sb_set_mnt_opts(struct super_block *sb, | 2047 | static inline int security_sb_set_mnt_opts(struct super_block *sb, |
| 2014 | struct security_mnt_opts *opts) | 2048 | struct security_mnt_opts *opts, |
| 2049 | unsigned long kern_flags, | ||
| 2050 | unsigned long *set_kern_flags) | ||
| 2015 | { | 2051 | { |
| 2016 | return 0; | 2052 | return 0; |
| 2017 | } | 2053 | } |
| @@ -2035,6 +2071,16 @@ static inline int security_inode_alloc(struct inode *inode) | |||
| 2035 | static inline void security_inode_free(struct inode *inode) | 2071 | static inline void security_inode_free(struct inode *inode) |
| 2036 | { } | 2072 | { } |
| 2037 | 2073 | ||
| 2074 | static inline int security_dentry_init_security(struct dentry *dentry, | ||
| 2075 | int mode, | ||
| 2076 | struct qstr *name, | ||
| 2077 | void **ctx, | ||
| 2078 | u32 *ctxlen) | ||
| 2079 | { | ||
| 2080 | return -EOPNOTSUPP; | ||
| 2081 | } | ||
| 2082 | |||
| 2083 | |||
| 2038 | static inline int security_inode_init_security(struct inode *inode, | 2084 | static inline int security_inode_init_security(struct inode *inode, |
| 2039 | struct inode *dir, | 2085 | struct inode *dir, |
| 2040 | const struct qstr *qstr, | 2086 | const struct qstr *qstr, |
| @@ -2520,6 +2566,11 @@ static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb) | |||
| 2520 | return cap_netlink_send(sk, skb); | 2566 | return cap_netlink_send(sk, skb); |
| 2521 | } | 2567 | } |
| 2522 | 2568 | ||
| 2569 | static inline int security_ismaclabel(const char *name) | ||
| 2570 | { | ||
| 2571 | return 0; | ||
| 2572 | } | ||
| 2573 | |||
| 2523 | static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) | 2574 | static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) |
| 2524 | { | 2575 | { |
| 2525 | return -EOPNOTSUPP; | 2576 | return -EOPNOTSUPP; |
