22 #ifndef __LINUX_SECURITY_H
23 #define __LINUX_SECURITY_H
26 #include <linux/capability.h>
27 #include <linux/slab.h>
57 #define SECURITY_NAME_MAX 10
60 #define SECURITY_CAP_NOAUDIT 0
61 #define SECURITY_CAP_AUDIT 1
91 unsigned long prot,
unsigned long flags);
94 unsigned long arg4,
unsigned long arg5);
121 #define mmap_min_addr 0UL
122 #define dac_mmap_min_addr 0UL
129 #define LSM_SETID_ID 1
132 #define LSM_SETID_RE 2
135 #define LSM_SETID_RES 4
138 #define LSM_SETID_FS 8
145 #define LSM_UNSAFE_SHARE 1
146 #define LSM_UNSAFE_PTRACE 2
147 #define LSM_UNSAFE_PTRACE_CAP 4
148 #define LSM_UNSAFE_NO_NEW_PRIVS 8
152 void __user *
buffer,
size_t *lenp, loff_t *ppos);
157 const struct xattr *xattr_array,
void *fs_data);
159 #ifdef CONFIG_SECURITY
169 opts->mnt_opts =
NULL;
170 opts->mnt_opts_flags =
NULL;
171 opts->num_mnt_opts = 0;
178 for (i = 0; i < opts->num_mnt_opts; i++)
179 kfree(opts->mnt_opts[i]);
180 kfree(opts->mnt_opts);
181 opts->mnt_opts =
NULL;
182 kfree(opts->mnt_opts_flags);
183 opts->mnt_opts_flags =
NULL;
184 opts->num_mnt_opts = 0;
1380 struct security_operations {
1388 int (*capset) (
struct cred *
new,
1389 const struct cred *old,
1394 int cap,
int audit);
1409 int (*sb_copy_data) (
char *orig,
char *copy);
1414 int (*sb_mount) (
const char *dev_name,
struct path *
path,
1417 int (*sb_pivotroot) (
struct path *old_path,
1418 struct path *new_path);
1425 #ifdef CONFIG_SECURITY_PATH
1433 const char *old_name);
1434 int (*path_link) (
struct dentry *old_dentry,
struct path *new_dir,
1435 struct dentry *new_dentry);
1436 int (*path_rename) (
struct path *old_dir,
struct dentry *old_dentry,
1437 struct path *new_dir,
struct dentry *new_dentry);
1443 int (*inode_alloc_security) (
struct inode *
inode);
1444 void (*inode_free_security) (
struct inode *
inode);
1445 int (*inode_init_security) (
struct inode *
inode,
struct inode *
dir,
1448 int (*inode_create) (
struct inode *
dir,
1450 int (*inode_link) (
struct dentry *old_dentry,
1451 struct inode *
dir,
struct dentry *new_dentry);
1453 int (*inode_symlink) (
struct inode *
dir,
1459 int (*inode_rename) (
struct inode *old_dir,
struct dentry *old_dentry,
1460 struct inode *new_dir,
struct dentry *new_dentry);
1475 int (*inode_getsecurity) (
const struct inode *
inode,
const char *
name,
void **
buffer,
bool alloc);
1478 void (*inode_getsecid) (
const struct inode *
inode,
u32 *secid);
1485 int (*mmap_addr) (
unsigned long addr);
1487 unsigned long reqprot,
unsigned long prot,
1488 unsigned long flags);
1490 unsigned long reqprot,
1491 unsigned long prot);
1501 int (*task_create) (
unsigned long clone_flags);
1505 int (*cred_prepare)(
struct cred *
new,
const struct cred *old,
1507 void (*cred_transfer)(
struct cred *
new,
const struct cred *old);
1508 int (*kernel_act_as)(
struct cred *
new,
u32 secid);
1509 int (*kernel_create_files_as)(
struct cred *
new,
struct inode *
inode);
1510 int (*kernel_module_request)(
char *kmod_name);
1511 int (*task_fix_setuid) (
struct cred *
new,
const struct cred *old,
1521 struct rlimit *new_rlim);
1529 unsigned long arg3,
unsigned long arg4,
1530 unsigned long arg5);
1539 int (*msg_queue_alloc_security) (
struct msg_queue *msq);
1541 int (*msg_queue_associate) (
struct msg_queue *msq,
int msqflg);
1555 char __user *shmaddr,
int shmflg);
1559 int (*sem_associate) (
struct sem_array *sma,
int semflg);
1562 struct sembuf *sops,
unsigned nsops,
int alter);
1570 int (*secid_to_secctx) (
u32 secid,
char **secdata,
u32 *seclen);
1571 int (*secctx_to_secid) (
const char *secdata,
u32 seclen,
u32 *secid);
1572 void (*release_secctx) (
char *secdata,
u32 seclen);
1574 int (*inode_notifysecctx)(
struct inode *
inode,
void *
ctx,
u32 ctxlen);
1576 int (*inode_getsecctx)(
struct inode *
inode,
void **
ctx,
u32 *ctxlen);
1578 #ifdef CONFIG_SECURITY_NETWORK
1605 void (*sk_clone_security) (
const struct sock *
sk,
struct sock *newsk);
1612 int (*secmark_relabel_packet) (
u32 secid);
1613 void (*secmark_refcount_inc) (
void);
1614 void (*secmark_refcount_dec) (
void);
1617 void (*tun_dev_post_create)(
struct sock *
sk);
1621 #ifdef CONFIG_SECURITY_NETWORK_XFRM
1643 int (*key_permission) (key_ref_t key_ref,
1654 void (*audit_rule_free) (
void *lsmrule);
1713 void **
value,
size_t *len);
1716 struct dentry *new_dentry);
1719 const char *old_name);
1724 struct inode *new_dir,
struct dentry *new_dentry);
1748 unsigned long flags);
1751 unsigned long prot);
1778 struct rlimit *new_rlim);
1786 unsigned long arg4,
unsigned long arg5);
1810 unsigned nsops,
int alter);
1860 return cap_capget(target, effective, inheritable, permitted);
1864 const struct cred *old,
1869 return cap_capset(
new, old, effective, inheritable, permitted);
1980 struct path *new_path)
2035 struct dentry *new_dentry)
2048 const char *old_name)
2074 struct dentry *old_dentry,
2075 struct inode *new_dir,
2076 struct dentry *new_dentry)
2186 unsigned long flags)
2197 unsigned long reqprot,
2254 const struct cred *old,
2261 const struct cred *old)
2271 struct inode *inode)
2282 const struct cred *old,
2440 char __user *shmaddr,
int shmflg)
2464 struct sembuf *sops,
unsigned nsops,
2518 #ifdef CONFIG_SECURITY_NETWORK
2520 int security_unix_stream_connect(
struct sock *
sock,
struct sock *
other,
struct sock *newsk);
2532 int security_socket_getsockname(
struct socket *
sock);
2533 int security_socket_getpeername(
struct socket *
sock);
2534 int security_socket_getsockopt(
struct socket *
sock,
int level,
int optname);
2535 int security_socket_setsockopt(
struct socket *
sock,
int level,
int optname);
2536 int security_socket_shutdown(
struct socket *
sock,
int how);
2538 int security_socket_getpeersec_stream(
struct socket *
sock,
char __user *optval,
2539 int __user *optlen,
unsigned len);
2542 void security_sk_free(
struct sock *
sk);
2543 void security_sk_clone(
const struct sock *
sk,
struct sock *newsk);
2544 void security_sk_classify_flow(
struct sock *
sk,
struct flowi *
fl);
2546 void security_sock_graft(
struct sock*
sk,
struct socket *parent);
2547 int security_inet_conn_request(
struct sock *
sk,
2549 void security_inet_csk_clone(
struct sock *newsk,
2551 void security_inet_conn_established(
struct sock *
sk,
2553 int security_secmark_relabel_packet(
u32 secid);
2554 void security_secmark_refcount_inc(
void);
2555 void security_secmark_refcount_dec(
void);
2556 int security_tun_dev_create(
void);
2557 void security_tun_dev_post_create(
struct sock *
sk);
2558 int security_tun_dev_attach(
struct sock *
sk);
2561 static inline int security_unix_stream_connect(
struct sock *
sock,
2568 static inline int security_unix_may_send(
struct socket *
sock,
2574 static inline int security_socket_create(
int family,
int type,
2580 static inline int security_socket_post_create(
struct socket *
sock,
2588 static inline int security_socket_bind(
struct socket *
sock,
2595 static inline int security_socket_connect(
struct socket *
sock,
2607 static inline int security_socket_accept(
struct socket *
sock,
2613 static inline int security_socket_sendmsg(
struct socket *
sock,
2619 static inline int security_socket_recvmsg(
struct socket *
sock,
2626 static inline int security_socket_getsockname(
struct socket *
sock)
2631 static inline int security_socket_getpeername(
struct socket *
sock)
2636 static inline int security_socket_getsockopt(
struct socket *
sock,
2637 int level,
int optname)
2642 static inline int security_socket_setsockopt(
struct socket *
sock,
2643 int level,
int optname)
2648 static inline int security_socket_shutdown(
struct socket *
sock,
int how)
2652 static inline int security_sock_rcv_skb(
struct sock *
sk,
2658 static inline int security_socket_getpeersec_stream(
struct socket *
sock,
char __user *optval,
2659 int __user *optlen,
unsigned len)
2674 static inline void security_sk_free(
struct sock *
sk)
2678 static inline void security_sk_clone(
const struct sock *
sk,
struct sock *newsk)
2682 static inline void security_sk_classify_flow(
struct sock *
sk,
struct flowi *
fl)
2690 static inline void security_sock_graft(
struct sock *
sk,
struct socket *parent)
2694 static inline int security_inet_conn_request(
struct sock *
sk,
2700 static inline void security_inet_csk_clone(
struct sock *newsk,
2705 static inline void security_inet_conn_established(
struct sock *
sk,
2710 static inline int security_secmark_relabel_packet(
u32 secid)
2715 static inline void security_secmark_refcount_inc(
void)
2719 static inline void security_secmark_refcount_dec(
void)
2723 static inline int security_tun_dev_create(
void)
2728 static inline void security_tun_dev_post_create(
struct sock *
sk)
2732 static inline int security_tun_dev_attach(
struct sock *
sk)
2738 #ifdef CONFIG_SECURITY_NETWORK_XFRM
2745 int security_xfrm_state_alloc_acquire(
struct xfrm_state *
x,
2747 int security_xfrm_state_delete(
struct xfrm_state *
x);
2748 void security_xfrm_state_free(
struct xfrm_state *
x);
2750 int security_xfrm_state_pol_flow_match(
struct xfrm_state *
x,
2753 int security_xfrm_decode_session(
struct sk_buff *
skb,
u32 *secid);
2768 static inline void security_xfrm_policy_free(
struct xfrm_sec_ctx *
ctx)
2772 static inline int security_xfrm_policy_delete(
struct xfrm_sec_ctx *
ctx)
2777 static inline int security_xfrm_state_alloc(
struct xfrm_state *
x,
2783 static inline int security_xfrm_state_alloc_acquire(
struct xfrm_state *
x,
2789 static inline void security_xfrm_state_free(
struct xfrm_state *
x)
2793 static inline int security_xfrm_state_delete(
struct xfrm_state *
x)
2803 static inline int security_xfrm_state_pol_flow_match(
struct xfrm_state *
x,
2809 static inline int security_xfrm_decode_session(
struct sk_buff *
skb,
u32 *secid)
2814 static inline void security_skb_classify_flow(
struct sk_buff *
skb,
struct flowi *
fl)
2820 #ifdef CONFIG_SECURITY_PATH
2826 int security_path_truncate(
struct path *
path);
2828 const char *old_name);
2829 int security_path_link(
struct dentry *old_dentry,
struct path *new_dir,
2830 struct dentry *new_dentry);
2831 int security_path_rename(
struct path *old_dir,
struct dentry *old_dentry,
2832 struct path *new_dir,
struct dentry *new_dentry);
2835 int security_path_chroot(
struct path *
path);
2837 static inline int security_path_unlink(
struct path *dir,
struct dentry *
dentry)
2842 static inline int security_path_mkdir(
struct path *dir,
struct dentry *
dentry,
2848 static inline int security_path_rmdir(
struct path *dir,
struct dentry *
dentry)
2853 static inline int security_path_mknod(
struct path *dir,
struct dentry *
dentry,
2859 static inline int security_path_truncate(
struct path *
path)
2864 static inline int security_path_symlink(
struct path *dir,
struct dentry *
dentry,
2865 const char *old_name)
2870 static inline int security_path_link(
struct dentry *old_dentry,
2871 struct path *new_dir,
2872 struct dentry *new_dentry)
2877 static inline int security_path_rename(
struct path *old_dir,
2878 struct dentry *old_dentry,
2879 struct path *new_dir,
2880 struct dentry *new_dentry)
2895 static inline int security_path_chroot(
struct path *
path)
2902 #ifdef CONFIG_SECURITY
2905 void security_key_free(
struct key *
key);
2906 int security_key_permission(key_ref_t key_ref,
2908 int security_key_getsecurity(
struct key *
key,
char **
_buffer);
2912 static inline int security_key_alloc(
struct key *
key,
2914 unsigned long flags)
2919 static inline void security_key_free(
struct key *
key)
2923 static inline int security_key_permission(key_ref_t key_ref,
2930 static inline int security_key_getsecurity(
struct key *
key,
char **
_buffer)
2940 #ifdef CONFIG_SECURITY
2941 int security_audit_rule_init(
u32 field,
u32 op,
char *rulestr,
void **lsmrule);
2942 int security_audit_rule_known(
struct audit_krule *krule);
2945 void security_audit_rule_free(
void *lsmrule);
2949 static inline int security_audit_rule_init(
u32 field,
u32 op,
char *rulestr,
2955 static inline int security_audit_rule_known(
struct audit_krule *krule)
2966 static inline void security_audit_rule_free(
void *lsmrule)
2972 #ifdef CONFIG_SECURITYFS
3002 #ifdef CONFIG_SECURITY
3004 static inline char *alloc_secdata(
void)
3009 static inline void free_secdata(
void *secdata)
3016 static inline char *alloc_secdata(
void)
3021 static inline void free_secdata(
void *secdata)
3025 #ifdef CONFIG_SECURITY_YAMA
3031 unsigned long arg4,
unsigned long arg5);
3049 unsigned long arg3,
unsigned long arg4,