aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/security.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/security.h')
-rw-r--r--include/linux/security.h131
1 files changed, 68 insertions, 63 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index 50737c70e78e..f5c4a51eb42e 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -46,7 +46,8 @@ struct audit_krule;
46 */ 46 */
47extern int cap_capable(struct task_struct *tsk, int cap); 47extern int cap_capable(struct task_struct *tsk, int cap);
48extern int cap_settime(struct timespec *ts, struct timezone *tz); 48extern int cap_settime(struct timespec *ts, struct timezone *tz);
49extern int cap_ptrace(struct task_struct *parent, struct task_struct *child); 49extern int cap_ptrace_may_access(struct task_struct *child, unsigned int mode);
50extern int cap_ptrace_traceme(struct task_struct *parent);
50extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 51extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
51extern int cap_capset_check(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 52extern int cap_capset_check(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
52extern void cap_capset_set(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 53extern void cap_capset_set(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
@@ -79,6 +80,7 @@ struct xfrm_selector;
79struct xfrm_policy; 80struct xfrm_policy;
80struct xfrm_state; 81struct xfrm_state;
81struct xfrm_user_sec_ctx; 82struct xfrm_user_sec_ctx;
83struct seq_file;
82 84
83extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb); 85extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
84extern int cap_netlink_recv(struct sk_buff *skb, int cap); 86extern int cap_netlink_recv(struct sk_buff *skb, int cap);
@@ -100,9 +102,7 @@ extern unsigned long mmap_min_addr;
100#define LSM_SETID_FS 8 102#define LSM_SETID_FS 8
101 103
102/* forward declares to avoid warnings */ 104/* forward declares to avoid warnings */
103struct nfsctl_arg;
104struct sched_param; 105struct sched_param;
105struct swap_info_struct;
106struct request_sock; 106struct request_sock;
107 107
108/* bprm_apply_creds unsafe reasons */ 108/* bprm_apply_creds unsafe reasons */
@@ -289,10 +289,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
289 * Update module state after a successful pivot. 289 * Update module state after a successful pivot.
290 * @old_path contains the path for the old root. 290 * @old_path contains the path for the old root.
291 * @new_path contains the path for the new root. 291 * @new_path contains the path for the new root.
292 * @sb_get_mnt_opts:
293 * Get the security relevant mount options used for a superblock
294 * @sb the superblock to get security mount options from
295 * @opts binary data structure containing all lsm mount data
296 * @sb_set_mnt_opts: 292 * @sb_set_mnt_opts:
297 * Set the security relevant mount options used for a superblock 293 * Set the security relevant mount options used for a superblock
298 * @sb the superblock to set security mount options for 294 * @sb the superblock to set security mount options for
@@ -1161,15 +1157,23 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1161 * @alter contains the flag indicating whether changes are to be made. 1157 * @alter contains the flag indicating whether changes are to be made.
1162 * Return 0 if permission is granted. 1158 * Return 0 if permission is granted.
1163 * 1159 *
1164 * @ptrace: 1160 * @ptrace_may_access:
1165 * Check permission before allowing the @parent process to trace the 1161 * Check permission before allowing the current process to trace the
1166 * @child process. 1162 * @child process.
1167 * Security modules may also want to perform a process tracing check 1163 * Security modules may also want to perform a process tracing check
1168 * during an execve in the set_security or apply_creds hooks of 1164 * during an execve in the set_security or apply_creds hooks of
1169 * binprm_security_ops if the process is being traced and its security 1165 * binprm_security_ops if the process is being traced and its security
1170 * attributes would be changed by the execve. 1166 * attributes would be changed by the execve.
1171 * @parent contains the task_struct structure for parent process. 1167 * @child contains the task_struct structure for the target process.
1172 * @child contains the task_struct structure for child process. 1168 * @mode contains the PTRACE_MODE flags indicating the form of access.
1169 * Return 0 if permission is granted.
1170 * @ptrace_traceme:
1171 * Check that the @parent process has sufficient permission to trace the
1172 * current process before allowing the current process to present itself
1173 * to the @parent process for tracing.
1174 * The parent process will still have to undergo the ptrace_may_access
1175 * checks before it is allowed to trace this one.
1176 * @parent contains the task_struct structure for debugger process.
1173 * Return 0 if permission is granted. 1177 * Return 0 if permission is granted.
1174 * @capget: 1178 * @capget:
1175 * Get the @effective, @inheritable, and @permitted capability sets for 1179 * Get the @effective, @inheritable, and @permitted capability sets for
@@ -1240,11 +1244,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1240 * @pages contains the number of pages. 1244 * @pages contains the number of pages.
1241 * Return 0 if permission is granted. 1245 * Return 0 if permission is granted.
1242 * 1246 *
1243 * @register_security:
1244 * allow module stacking.
1245 * @name contains the name of the security module being stacked.
1246 * @ops contains a pointer to the struct security_operations of the module to stack.
1247 *
1248 * @secid_to_secctx: 1247 * @secid_to_secctx:
1249 * Convert secid to security context. 1248 * Convert secid to security context.
1250 * @secid contains the security ID. 1249 * @secid contains the security ID.
@@ -1295,7 +1294,8 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1295struct security_operations { 1294struct security_operations {
1296 char name[SECURITY_NAME_MAX + 1]; 1295 char name[SECURITY_NAME_MAX + 1];
1297 1296
1298 int (*ptrace) (struct task_struct *parent, struct task_struct *child); 1297 int (*ptrace_may_access) (struct task_struct *child, unsigned int mode);
1298 int (*ptrace_traceme) (struct task_struct *parent);
1299 int (*capget) (struct task_struct *target, 1299 int (*capget) (struct task_struct *target,
1300 kernel_cap_t *effective, 1300 kernel_cap_t *effective,
1301 kernel_cap_t *inheritable, kernel_cap_t *permitted); 1301 kernel_cap_t *inheritable, kernel_cap_t *permitted);
@@ -1328,6 +1328,7 @@ struct security_operations {
1328 void (*sb_free_security) (struct super_block *sb); 1328 void (*sb_free_security) (struct super_block *sb);
1329 int (*sb_copy_data) (char *orig, char *copy); 1329 int (*sb_copy_data) (char *orig, char *copy);
1330 int (*sb_kern_mount) (struct super_block *sb, void *data); 1330 int (*sb_kern_mount) (struct super_block *sb, void *data);
1331 int (*sb_show_options) (struct seq_file *m, struct super_block *sb);
1331 int (*sb_statfs) (struct dentry *dentry); 1332 int (*sb_statfs) (struct dentry *dentry);
1332 int (*sb_mount) (char *dev_name, struct path *path, 1333 int (*sb_mount) (char *dev_name, struct path *path,
1333 char *type, unsigned long flags, void *data); 1334 char *type, unsigned long flags, void *data);
@@ -1343,8 +1344,6 @@ struct security_operations {
1343 struct path *new_path); 1344 struct path *new_path);
1344 void (*sb_post_pivotroot) (struct path *old_path, 1345 void (*sb_post_pivotroot) (struct path *old_path,
1345 struct path *new_path); 1346 struct path *new_path);
1346 int (*sb_get_mnt_opts) (const struct super_block *sb,
1347 struct security_mnt_opts *opts);
1348 int (*sb_set_mnt_opts) (struct super_block *sb, 1347 int (*sb_set_mnt_opts) (struct super_block *sb,
1349 struct security_mnt_opts *opts); 1348 struct security_mnt_opts *opts);
1350 void (*sb_clone_mnt_opts) (const struct super_block *oldsb, 1349 void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
@@ -1370,7 +1369,7 @@ struct security_operations {
1370 struct inode *new_dir, struct dentry *new_dentry); 1369 struct inode *new_dir, struct dentry *new_dentry);
1371 int (*inode_readlink) (struct dentry *dentry); 1370 int (*inode_readlink) (struct dentry *dentry);
1372 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd); 1371 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1373 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd); 1372 int (*inode_permission) (struct inode *inode, int mask);
1374 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr); 1373 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1375 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry); 1374 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1376 void (*inode_delete) (struct inode *inode); 1375 void (*inode_delete) (struct inode *inode);
@@ -1472,10 +1471,6 @@ struct security_operations {
1472 int (*netlink_send) (struct sock *sk, struct sk_buff *skb); 1471 int (*netlink_send) (struct sock *sk, struct sk_buff *skb);
1473 int (*netlink_recv) (struct sk_buff *skb, int cap); 1472 int (*netlink_recv) (struct sk_buff *skb, int cap);
1474 1473
1475 /* allow module stacking */
1476 int (*register_security) (const char *name,
1477 struct security_operations *ops);
1478
1479 void (*d_instantiate) (struct dentry *dentry, struct inode *inode); 1474 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1480 1475
1481 int (*getprocattr) (struct task_struct *p, char *name, char **value); 1476 int (*getprocattr) (struct task_struct *p, char *name, char **value);
@@ -1565,15 +1560,10 @@ struct security_operations {
1565extern int security_init(void); 1560extern int security_init(void);
1566extern int security_module_enable(struct security_operations *ops); 1561extern int security_module_enable(struct security_operations *ops);
1567extern int register_security(struct security_operations *ops); 1562extern int register_security(struct security_operations *ops);
1568extern int mod_reg_security(const char *name, struct security_operations *ops);
1569extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1570 struct dentry *parent, void *data,
1571 const struct file_operations *fops);
1572extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1573extern void securityfs_remove(struct dentry *dentry);
1574 1563
1575/* Security operations */ 1564/* Security operations */
1576int security_ptrace(struct task_struct *parent, struct task_struct *child); 1565int security_ptrace_may_access(struct task_struct *child, unsigned int mode);
1566int security_ptrace_traceme(struct task_struct *parent);
1577int security_capget(struct task_struct *target, 1567int security_capget(struct task_struct *target,
1578 kernel_cap_t *effective, 1568 kernel_cap_t *effective,
1579 kernel_cap_t *inheritable, 1569 kernel_cap_t *inheritable,
@@ -1606,6 +1596,7 @@ int security_sb_alloc(struct super_block *sb);
1606void security_sb_free(struct super_block *sb); 1596void security_sb_free(struct super_block *sb);
1607int security_sb_copy_data(char *orig, char *copy); 1597int security_sb_copy_data(char *orig, char *copy);
1608int security_sb_kern_mount(struct super_block *sb, void *data); 1598int security_sb_kern_mount(struct super_block *sb, void *data);
1599int security_sb_show_options(struct seq_file *m, struct super_block *sb);
1609int security_sb_statfs(struct dentry *dentry); 1600int security_sb_statfs(struct dentry *dentry);
1610int security_sb_mount(char *dev_name, struct path *path, 1601int security_sb_mount(char *dev_name, struct path *path,
1611 char *type, unsigned long flags, void *data); 1602 char *type, unsigned long flags, void *data);
@@ -1617,8 +1608,6 @@ void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *d
1617void security_sb_post_addmount(struct vfsmount *mnt, struct path *mountpoint); 1608void security_sb_post_addmount(struct vfsmount *mnt, struct path *mountpoint);
1618int security_sb_pivotroot(struct path *old_path, struct path *new_path); 1609int security_sb_pivotroot(struct path *old_path, struct path *new_path);
1619void security_sb_post_pivotroot(struct path *old_path, struct path *new_path); 1610void security_sb_post_pivotroot(struct path *old_path, struct path *new_path);
1620int security_sb_get_mnt_opts(const struct super_block *sb,
1621 struct security_mnt_opts *opts);
1622int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts); 1611int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts);
1623void security_sb_clone_mnt_opts(const struct super_block *oldsb, 1612void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1624 struct super_block *newsb); 1613 struct super_block *newsb);
@@ -1641,7 +1630,7 @@ int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1641 struct inode *new_dir, struct dentry *new_dentry); 1630 struct inode *new_dir, struct dentry *new_dentry);
1642int security_inode_readlink(struct dentry *dentry); 1631int security_inode_readlink(struct dentry *dentry);
1643int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd); 1632int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1644int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd); 1633int security_inode_permission(struct inode *inode, int mask);
1645int security_inode_setattr(struct dentry *dentry, struct iattr *attr); 1634int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1646int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry); 1635int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1647void security_inode_delete(struct inode *inode); 1636void security_inode_delete(struct inode *inode);
@@ -1755,9 +1744,15 @@ static inline int security_init(void)
1755 return 0; 1744 return 0;
1756} 1745}
1757 1746
1758static inline int security_ptrace(struct task_struct *parent, struct task_struct *child) 1747static inline int security_ptrace_may_access(struct task_struct *child,
1748 unsigned int mode)
1759{ 1749{
1760 return cap_ptrace(parent, child); 1750 return cap_ptrace_may_access(child, mode);
1751}
1752
1753static inline int security_ptrace_traceme(struct task_struct *parent)
1754{
1755 return cap_ptrace_traceme(parent);
1761} 1756}
1762 1757
1763static inline int security_capget(struct task_struct *target, 1758static inline int security_capget(struct task_struct *target,
@@ -1881,6 +1876,12 @@ static inline int security_sb_kern_mount(struct super_block *sb, void *data)
1881 return 0; 1876 return 0;
1882} 1877}
1883 1878
1879static inline int security_sb_show_options(struct seq_file *m,
1880 struct super_block *sb)
1881{
1882 return 0;
1883}
1884
1884static inline int security_sb_statfs(struct dentry *dentry) 1885static inline int security_sb_statfs(struct dentry *dentry)
1885{ 1886{
1886 return 0; 1887 return 0;
@@ -1927,12 +1928,6 @@ static inline int security_sb_pivotroot(struct path *old_path,
1927static inline void security_sb_post_pivotroot(struct path *old_path, 1928static inline void security_sb_post_pivotroot(struct path *old_path,
1928 struct path *new_path) 1929 struct path *new_path)
1929{ } 1930{ }
1930static inline int security_sb_get_mnt_opts(const struct super_block *sb,
1931 struct security_mnt_opts *opts)
1932{
1933 security_init_mnt_opts(opts);
1934 return 0;
1935}
1936 1931
1937static inline int security_sb_set_mnt_opts(struct super_block *sb, 1932static inline int security_sb_set_mnt_opts(struct super_block *sb,
1938 struct security_mnt_opts *opts) 1933 struct security_mnt_opts *opts)
@@ -2032,8 +2027,7 @@ static inline int security_inode_follow_link(struct dentry *dentry,
2032 return 0; 2027 return 0;
2033} 2028}
2034 2029
2035static inline int security_inode_permission(struct inode *inode, int mask, 2030static inline int security_inode_permission(struct inode *inode, int mask)
2036 struct nameidata *nd)
2037{ 2031{
2038 return 0; 2032 return 0;
2039} 2033}
@@ -2425,25 +2419,6 @@ static inline int security_netlink_recv(struct sk_buff *skb, int cap)
2425 return cap_netlink_recv(skb, cap); 2419 return cap_netlink_recv(skb, cap);
2426} 2420}
2427 2421
2428static inline struct dentry *securityfs_create_dir(const char *name,
2429 struct dentry *parent)
2430{
2431 return ERR_PTR(-ENODEV);
2432}
2433
2434static inline struct dentry *securityfs_create_file(const char *name,
2435 mode_t mode,
2436 struct dentry *parent,
2437 void *data,
2438 const struct file_operations *fops)
2439{
2440 return ERR_PTR(-ENODEV);
2441}
2442
2443static inline void securityfs_remove(struct dentry *dentry)
2444{
2445}
2446
2447static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) 2422static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2448{ 2423{
2449 return -EOPNOTSUPP; 2424 return -EOPNOTSUPP;
@@ -2807,5 +2782,35 @@ static inline void security_audit_rule_free(void *lsmrule)
2807#endif /* CONFIG_SECURITY */ 2782#endif /* CONFIG_SECURITY */
2808#endif /* CONFIG_AUDIT */ 2783#endif /* CONFIG_AUDIT */
2809 2784
2785#ifdef CONFIG_SECURITYFS
2786
2787extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2788 struct dentry *parent, void *data,
2789 const struct file_operations *fops);
2790extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2791extern void securityfs_remove(struct dentry *dentry);
2792
2793#else /* CONFIG_SECURITYFS */
2794
2795static inline struct dentry *securityfs_create_dir(const char *name,
2796 struct dentry *parent)
2797{
2798 return ERR_PTR(-ENODEV);
2799}
2800
2801static inline struct dentry *securityfs_create_file(const char *name,
2802 mode_t mode,
2803 struct dentry *parent,
2804 void *data,
2805 const struct file_operations *fops)
2806{
2807 return ERR_PTR(-ENODEV);
2808}
2809
2810static inline void securityfs_remove(struct dentry *dentry)
2811{}
2812
2813#endif
2814
2810#endif /* ! __LINUX_SECURITY_H */ 2815#endif /* ! __LINUX_SECURITY_H */
2811 2816