diff options
Diffstat (limited to 'include/linux/security.h')
| -rw-r--r-- | include/linux/security.h | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/include/linux/security.h b/include/linux/security.h index 1f2ab6353c00..1f16eea2017b 100644 --- a/include/linux/security.h +++ b/include/linux/security.h | |||
| @@ -28,10 +28,12 @@ | |||
| 28 | #include <linux/resource.h> | 28 | #include <linux/resource.h> |
| 29 | #include <linux/sem.h> | 29 | #include <linux/sem.h> |
| 30 | #include <linux/shm.h> | 30 | #include <linux/shm.h> |
| 31 | #include <linux/mm.h> /* PAGE_ALIGN */ | ||
| 31 | #include <linux/msg.h> | 32 | #include <linux/msg.h> |
| 32 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
| 33 | #include <linux/key.h> | 34 | #include <linux/key.h> |
| 34 | #include <linux/xfrm.h> | 35 | #include <linux/xfrm.h> |
| 36 | #include <linux/gfp.h> | ||
| 35 | #include <net/flow.h> | 37 | #include <net/flow.h> |
| 36 | 38 | ||
| 37 | /* Maximum number of letters for an LSM name string */ | 39 | /* Maximum number of letters for an LSM name string */ |
| @@ -65,6 +67,9 @@ extern int cap_inode_setxattr(struct dentry *dentry, const char *name, | |||
| 65 | extern int cap_inode_removexattr(struct dentry *dentry, const char *name); | 67 | extern int cap_inode_removexattr(struct dentry *dentry, const char *name); |
| 66 | extern int cap_inode_need_killpriv(struct dentry *dentry); | 68 | extern int cap_inode_need_killpriv(struct dentry *dentry); |
| 67 | extern int cap_inode_killpriv(struct dentry *dentry); | 69 | extern int cap_inode_killpriv(struct dentry *dentry); |
| 70 | extern int cap_file_mmap(struct file *file, unsigned long reqprot, | ||
| 71 | unsigned long prot, unsigned long flags, | ||
| 72 | unsigned long addr, unsigned long addr_only); | ||
| 68 | extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags); | 73 | extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags); |
| 69 | extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, | 74 | extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, |
| 70 | unsigned long arg4, unsigned long arg5); | 75 | unsigned long arg4, unsigned long arg5); |
| @@ -91,6 +96,7 @@ extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb); | |||
| 91 | extern int cap_netlink_recv(struct sk_buff *skb, int cap); | 96 | extern int cap_netlink_recv(struct sk_buff *skb, int cap); |
| 92 | 97 | ||
| 93 | extern unsigned long mmap_min_addr; | 98 | extern unsigned long mmap_min_addr; |
| 99 | extern unsigned long dac_mmap_min_addr; | ||
| 94 | /* | 100 | /* |
| 95 | * Values used in the task_security_ops calls | 101 | * Values used in the task_security_ops calls |
| 96 | */ | 102 | */ |
| @@ -115,6 +121,21 @@ struct request_sock; | |||
| 115 | #define LSM_UNSAFE_PTRACE 2 | 121 | #define LSM_UNSAFE_PTRACE 2 |
| 116 | #define LSM_UNSAFE_PTRACE_CAP 4 | 122 | #define LSM_UNSAFE_PTRACE_CAP 4 |
| 117 | 123 | ||
| 124 | /* | ||
| 125 | * If a hint addr is less than mmap_min_addr change hint to be as | ||
| 126 | * low as possible but still greater than mmap_min_addr | ||
| 127 | */ | ||
| 128 | static inline unsigned long round_hint_to_min(unsigned long hint) | ||
| 129 | { | ||
| 130 | hint &= PAGE_MASK; | ||
| 131 | if (((void *)hint != NULL) && | ||
| 132 | (hint < mmap_min_addr)) | ||
| 133 | return PAGE_ALIGN(mmap_min_addr); | ||
| 134 | return hint; | ||
| 135 | } | ||
| 136 | extern int mmap_min_addr_handler(struct ctl_table *table, int write, struct file *filp, | ||
| 137 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
| 138 | |||
| 118 | #ifdef CONFIG_SECURITY | 139 | #ifdef CONFIG_SECURITY |
| 119 | 140 | ||
| 120 | struct security_mnt_opts { | 141 | struct security_mnt_opts { |
| @@ -880,11 +901,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) | |||
| 880 | * @sock contains the listening socket structure. | 901 | * @sock contains the listening socket structure. |
| 881 | * @newsock contains the newly created server socket for connection. | 902 | * @newsock contains the newly created server socket for connection. |
| 882 | * Return 0 if permission is granted. | 903 | * Return 0 if permission is granted. |
| 883 | * @socket_post_accept: | ||
| 884 | * This hook allows a security module to copy security | ||
| 885 | * information into the newly created socket's inode. | ||
| 886 | * @sock contains the listening socket structure. | ||
| 887 | * @newsock contains the newly created server socket for connection. | ||
| 888 | * @socket_sendmsg: | 904 | * @socket_sendmsg: |
| 889 | * Check permission before transmitting a message to another socket. | 905 | * Check permission before transmitting a message to another socket. |
| 890 | * @sock contains the socket structure. | 906 | * @sock contains the socket structure. |
| @@ -1554,8 +1570,6 @@ struct security_operations { | |||
| 1554 | struct sockaddr *address, int addrlen); | 1570 | struct sockaddr *address, int addrlen); |
| 1555 | int (*socket_listen) (struct socket *sock, int backlog); | 1571 | int (*socket_listen) (struct socket *sock, int backlog); |
| 1556 | int (*socket_accept) (struct socket *sock, struct socket *newsock); | 1572 | int (*socket_accept) (struct socket *sock, struct socket *newsock); |
| 1557 | void (*socket_post_accept) (struct socket *sock, | ||
| 1558 | struct socket *newsock); | ||
| 1559 | int (*socket_sendmsg) (struct socket *sock, | 1573 | int (*socket_sendmsg) (struct socket *sock, |
| 1560 | struct msghdr *msg, int size); | 1574 | struct msghdr *msg, int size); |
| 1561 | int (*socket_recvmsg) (struct socket *sock, | 1575 | int (*socket_recvmsg) (struct socket *sock, |
| @@ -2203,7 +2217,7 @@ static inline int security_file_mmap(struct file *file, unsigned long reqprot, | |||
| 2203 | unsigned long addr, | 2217 | unsigned long addr, |
| 2204 | unsigned long addr_only) | 2218 | unsigned long addr_only) |
| 2205 | { | 2219 | { |
| 2206 | return 0; | 2220 | return cap_file_mmap(file, reqprot, prot, flags, addr, addr_only); |
| 2207 | } | 2221 | } |
| 2208 | 2222 | ||
| 2209 | static inline int security_file_mprotect(struct vm_area_struct *vma, | 2223 | static inline int security_file_mprotect(struct vm_area_struct *vma, |
| @@ -2537,7 +2551,6 @@ int security_socket_bind(struct socket *sock, struct sockaddr *address, int addr | |||
| 2537 | int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen); | 2551 | int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen); |
| 2538 | int security_socket_listen(struct socket *sock, int backlog); | 2552 | int security_socket_listen(struct socket *sock, int backlog); |
| 2539 | int security_socket_accept(struct socket *sock, struct socket *newsock); | 2553 | int security_socket_accept(struct socket *sock, struct socket *newsock); |
| 2540 | void security_socket_post_accept(struct socket *sock, struct socket *newsock); | ||
| 2541 | int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size); | 2554 | int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size); |
| 2542 | int security_socket_recvmsg(struct socket *sock, struct msghdr *msg, | 2555 | int security_socket_recvmsg(struct socket *sock, struct msghdr *msg, |
| 2543 | int size, int flags); | 2556 | int size, int flags); |
| @@ -2616,11 +2629,6 @@ static inline int security_socket_accept(struct socket *sock, | |||
| 2616 | return 0; | 2629 | return 0; |
| 2617 | } | 2630 | } |
| 2618 | 2631 | ||
| 2619 | static inline void security_socket_post_accept(struct socket *sock, | ||
| 2620 | struct socket *newsock) | ||
| 2621 | { | ||
| 2622 | } | ||
| 2623 | |||
| 2624 | static inline int security_socket_sendmsg(struct socket *sock, | 2632 | static inline int security_socket_sendmsg(struct socket *sock, |
| 2625 | struct msghdr *msg, int size) | 2633 | struct msghdr *msg, int size) |
| 2626 | { | 2634 | { |
| @@ -2966,5 +2974,28 @@ static inline void securityfs_remove(struct dentry *dentry) | |||
| 2966 | 2974 | ||
| 2967 | #endif | 2975 | #endif |
| 2968 | 2976 | ||
| 2977 | #ifdef CONFIG_SECURITY | ||
| 2978 | |||
| 2979 | static inline char *alloc_secdata(void) | ||
| 2980 | { | ||
| 2981 | return (char *)get_zeroed_page(GFP_KERNEL); | ||
| 2982 | } | ||
| 2983 | |||
| 2984 | static inline void free_secdata(void *secdata) | ||
| 2985 | { | ||
| 2986 | free_page((unsigned long)secdata); | ||
| 2987 | } | ||
| 2988 | |||
| 2989 | #else | ||
| 2990 | |||
| 2991 | static inline char *alloc_secdata(void) | ||
| 2992 | { | ||
| 2993 | return (char *)1; | ||
| 2994 | } | ||
| 2995 | |||
| 2996 | static inline void free_secdata(void *secdata) | ||
| 2997 | { } | ||
| 2998 | #endif /* CONFIG_SECURITY */ | ||
| 2999 | |||
| 2969 | #endif /* ! __LINUX_SECURITY_H */ | 3000 | #endif /* ! __LINUX_SECURITY_H */ |
| 2970 | 3001 | ||
