diff options
Diffstat (limited to 'include/linux/security.h')
| -rw-r--r-- | include/linux/security.h | 239 |
1 files changed, 203 insertions, 36 deletions
diff --git a/include/linux/security.h b/include/linux/security.h index 6bc2aad494ff..9f56fb8a4a6c 100644 --- a/include/linux/security.h +++ b/include/linux/security.h | |||
| @@ -31,6 +31,8 @@ | |||
| 31 | #include <linux/msg.h> | 31 | #include <linux/msg.h> |
| 32 | #include <linux/sched.h> | 32 | #include <linux/sched.h> |
| 33 | #include <linux/key.h> | 33 | #include <linux/key.h> |
| 34 | #include <linux/xfrm.h> | ||
| 35 | #include <net/flow.h> | ||
| 34 | 36 | ||
| 35 | struct ctl_table; | 37 | struct ctl_table; |
| 36 | 38 | ||
| @@ -88,6 +90,7 @@ extern int cap_netlink_recv(struct sk_buff *skb, int cap); | |||
| 88 | struct nfsctl_arg; | 90 | struct nfsctl_arg; |
| 89 | struct sched_param; | 91 | struct sched_param; |
| 90 | struct swap_info_struct; | 92 | struct swap_info_struct; |
| 93 | struct request_sock; | ||
| 91 | 94 | ||
| 92 | /* bprm_apply_creds unsafe reasons */ | 95 | /* bprm_apply_creds unsafe reasons */ |
| 93 | #define LSM_UNSAFE_SHARE 1 | 96 | #define LSM_UNSAFE_SHARE 1 |
| @@ -812,9 +815,19 @@ struct swap_info_struct; | |||
| 812 | * which is used to copy security attributes between local stream sockets. | 815 | * which is used to copy security attributes between local stream sockets. |
| 813 | * @sk_free_security: | 816 | * @sk_free_security: |
| 814 | * Deallocate security structure. | 817 | * Deallocate security structure. |
| 815 | * @sk_getsid: | 818 | * @sk_clone_security: |
| 816 | * Retrieve the LSM-specific sid for the sock to enable caching of network | 819 | * Clone/copy security structure. |
| 820 | * @sk_getsecid: | ||
| 821 | * Retrieve the LSM-specific secid for the sock to enable caching of network | ||
| 817 | * authorizations. | 822 | * authorizations. |
| 823 | * @sock_graft: | ||
| 824 | * Sets the socket's isec sid to the sock's sid. | ||
| 825 | * @inet_conn_request: | ||
| 826 | * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid. | ||
| 827 | * @inet_csk_clone: | ||
| 828 | * Sets the new child socket's sid to the openreq sid. | ||
| 829 | * @req_classify_flow: | ||
| 830 | * Sets the flow's sid to the openreq sid. | ||
| 818 | * | 831 | * |
| 819 | * Security hooks for XFRM operations. | 832 | * Security hooks for XFRM operations. |
| 820 | * | 833 | * |
| @@ -823,9 +836,10 @@ struct swap_info_struct; | |||
| 823 | * used by the XFRM system. | 836 | * used by the XFRM system. |
| 824 | * @sec_ctx contains the security context information being provided by | 837 | * @sec_ctx contains the security context information being provided by |
| 825 | * the user-level policy update program (e.g., setkey). | 838 | * the user-level policy update program (e.g., setkey). |
| 826 | * Allocate a security structure to the xp->security field. | 839 | * @sk refers to the sock from which to derive the security context. |
| 827 | * The security field is initialized to NULL when the xfrm_policy is | 840 | * Allocate a security structure to the xp->security field; the security |
| 828 | * allocated. | 841 | * field is initialized to NULL when the xfrm_policy is allocated. Only |
| 842 | * one of sec_ctx or sock can be specified. | ||
| 829 | * Return 0 if operation was successful (memory to allocate, legal context) | 843 | * Return 0 if operation was successful (memory to allocate, legal context) |
| 830 | * @xfrm_policy_clone_security: | 844 | * @xfrm_policy_clone_security: |
| 831 | * @old contains an existing xfrm_policy in the SPD. | 845 | * @old contains an existing xfrm_policy in the SPD. |
| @@ -844,9 +858,14 @@ struct swap_info_struct; | |||
| 844 | * Database by the XFRM system. | 858 | * Database by the XFRM system. |
| 845 | * @sec_ctx contains the security context information being provided by | 859 | * @sec_ctx contains the security context information being provided by |
| 846 | * the user-level SA generation program (e.g., setkey or racoon). | 860 | * the user-level SA generation program (e.g., setkey or racoon). |
| 847 | * Allocate a security structure to the x->security field. The | 861 | * @polsec contains the security context information associated with a xfrm |
| 848 | * security field is initialized to NULL when the xfrm_state is | 862 | * policy rule from which to take the base context. polsec must be NULL |
| 849 | * allocated. | 863 | * when sec_ctx is specified. |
| 864 | * @secid contains the secid from which to take the mls portion of the context. | ||
| 865 | * Allocate a security structure to the x->security field; the security | ||
| 866 | * field is initialized to NULL when the xfrm_state is allocated. Set the | ||
| 867 | * context to correspond to either sec_ctx or polsec, with the mls portion | ||
| 868 | * taken from secid in the latter case. | ||
| 850 | * Return 0 if operation was successful (memory to allocate, legal context). | 869 | * Return 0 if operation was successful (memory to allocate, legal context). |
| 851 | * @xfrm_state_free_security: | 870 | * @xfrm_state_free_security: |
| 852 | * @x contains the xfrm_state. | 871 | * @x contains the xfrm_state. |
| @@ -857,13 +876,27 @@ struct swap_info_struct; | |||
| 857 | * @xfrm_policy_lookup: | 876 | * @xfrm_policy_lookup: |
| 858 | * @xp contains the xfrm_policy for which the access control is being | 877 | * @xp contains the xfrm_policy for which the access control is being |
| 859 | * checked. | 878 | * checked. |
| 860 | * @sk_sid contains the sock security label that is used to authorize | 879 | * @fl_secid contains the flow security label that is used to authorize |
| 861 | * access to the policy xp. | 880 | * access to the policy xp. |
| 862 | * @dir contains the direction of the flow (input or output). | 881 | * @dir contains the direction of the flow (input or output). |
| 863 | * Check permission when a sock selects a xfrm_policy for processing | 882 | * Check permission when a flow selects a xfrm_policy for processing |
| 864 | * XFRMs on a packet. The hook is called when selecting either a | 883 | * XFRMs on a packet. The hook is called when selecting either a |
| 865 | * per-socket policy or a generic xfrm policy. | 884 | * per-socket policy or a generic xfrm policy. |
| 866 | * Return 0 if permission is granted. | 885 | * Return 0 if permission is granted. |
| 886 | * @xfrm_state_pol_flow_match: | ||
| 887 | * @x contains the state to match. | ||
| 888 | * @xp contains the policy to check for a match. | ||
| 889 | * @fl contains the flow to check for a match. | ||
| 890 | * Return 1 if there is a match. | ||
| 891 | * @xfrm_flow_state_match: | ||
| 892 | * @fl contains the flow key to match. | ||
| 893 | * @xfrm points to the xfrm_state to match. | ||
| 894 | * Return 1 if there is a match. | ||
| 895 | * @xfrm_decode_session: | ||
| 896 | * @skb points to skb to decode. | ||
| 897 | * @secid points to the flow key secid to set. | ||
| 898 | * @ckall says if all xfrms used should be checked for same secid. | ||
| 899 | * Return 0 if ckall is zero or all xfrms used have the same secid. | ||
| 867 | * | 900 | * |
| 868 | * Security hooks affecting all Key Management operations | 901 | * Security hooks affecting all Key Management operations |
| 869 | * | 902 | * |
| @@ -1308,8 +1341,8 @@ struct security_operations { | |||
| 1308 | int (*unix_may_send) (struct socket * sock, struct socket * other); | 1341 | int (*unix_may_send) (struct socket * sock, struct socket * other); |
| 1309 | 1342 | ||
| 1310 | int (*socket_create) (int family, int type, int protocol, int kern); | 1343 | int (*socket_create) (int family, int type, int protocol, int kern); |
| 1311 | void (*socket_post_create) (struct socket * sock, int family, | 1344 | int (*socket_post_create) (struct socket * sock, int family, |
| 1312 | int type, int protocol, int kern); | 1345 | int type, int protocol, int kern); |
| 1313 | int (*socket_bind) (struct socket * sock, | 1346 | int (*socket_bind) (struct socket * sock, |
| 1314 | struct sockaddr * address, int addrlen); | 1347 | struct sockaddr * address, int addrlen); |
| 1315 | int (*socket_connect) (struct socket * sock, | 1348 | int (*socket_connect) (struct socket * sock, |
| @@ -1332,18 +1365,31 @@ struct security_operations { | |||
| 1332 | int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid); | 1365 | int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid); |
| 1333 | int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority); | 1366 | int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority); |
| 1334 | void (*sk_free_security) (struct sock *sk); | 1367 | void (*sk_free_security) (struct sock *sk); |
| 1335 | unsigned int (*sk_getsid) (struct sock *sk, struct flowi *fl, u8 dir); | 1368 | void (*sk_clone_security) (const struct sock *sk, struct sock *newsk); |
| 1369 | void (*sk_getsecid) (struct sock *sk, u32 *secid); | ||
| 1370 | void (*sock_graft)(struct sock* sk, struct socket *parent); | ||
| 1371 | int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb, | ||
| 1372 | struct request_sock *req); | ||
| 1373 | void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req); | ||
| 1374 | void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl); | ||
| 1336 | #endif /* CONFIG_SECURITY_NETWORK */ | 1375 | #endif /* CONFIG_SECURITY_NETWORK */ |
| 1337 | 1376 | ||
| 1338 | #ifdef CONFIG_SECURITY_NETWORK_XFRM | 1377 | #ifdef CONFIG_SECURITY_NETWORK_XFRM |
| 1339 | int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx); | 1378 | int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, |
| 1379 | struct xfrm_user_sec_ctx *sec_ctx, struct sock *sk); | ||
| 1340 | int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new); | 1380 | int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new); |
| 1341 | void (*xfrm_policy_free_security) (struct xfrm_policy *xp); | 1381 | void (*xfrm_policy_free_security) (struct xfrm_policy *xp); |
| 1342 | int (*xfrm_policy_delete_security) (struct xfrm_policy *xp); | 1382 | int (*xfrm_policy_delete_security) (struct xfrm_policy *xp); |
| 1343 | int (*xfrm_state_alloc_security) (struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); | 1383 | int (*xfrm_state_alloc_security) (struct xfrm_state *x, |
| 1384 | struct xfrm_user_sec_ctx *sec_ctx, struct xfrm_sec_ctx *polsec, | ||
| 1385 | u32 secid); | ||
| 1344 | void (*xfrm_state_free_security) (struct xfrm_state *x); | 1386 | void (*xfrm_state_free_security) (struct xfrm_state *x); |
| 1345 | int (*xfrm_state_delete_security) (struct xfrm_state *x); | 1387 | int (*xfrm_state_delete_security) (struct xfrm_state *x); |
| 1346 | int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 sk_sid, u8 dir); | 1388 | int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir); |
| 1389 | int (*xfrm_state_pol_flow_match)(struct xfrm_state *x, | ||
| 1390 | struct xfrm_policy *xp, struct flowi *fl); | ||
| 1391 | int (*xfrm_flow_state_match)(struct flowi *fl, struct xfrm_state *xfrm); | ||
| 1392 | int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall); | ||
| 1347 | #endif /* CONFIG_SECURITY_NETWORK_XFRM */ | 1393 | #endif /* CONFIG_SECURITY_NETWORK_XFRM */ |
| 1348 | 1394 | ||
| 1349 | /* key management security hooks */ | 1395 | /* key management security hooks */ |
| @@ -2778,13 +2824,13 @@ static inline int security_socket_create (int family, int type, | |||
| 2778 | return security_ops->socket_create(family, type, protocol, kern); | 2824 | return security_ops->socket_create(family, type, protocol, kern); |
| 2779 | } | 2825 | } |
| 2780 | 2826 | ||
| 2781 | static inline void security_socket_post_create(struct socket * sock, | 2827 | static inline int security_socket_post_create(struct socket * sock, |
| 2782 | int family, | 2828 | int family, |
| 2783 | int type, | 2829 | int type, |
| 2784 | int protocol, int kern) | 2830 | int protocol, int kern) |
| 2785 | { | 2831 | { |
| 2786 | security_ops->socket_post_create(sock, family, type, | 2832 | return security_ops->socket_post_create(sock, family, type, |
| 2787 | protocol, kern); | 2833 | protocol, kern); |
| 2788 | } | 2834 | } |
| 2789 | 2835 | ||
| 2790 | static inline int security_socket_bind(struct socket * sock, | 2836 | static inline int security_socket_bind(struct socket * sock, |
| @@ -2885,9 +2931,36 @@ static inline void security_sk_free(struct sock *sk) | |||
| 2885 | return security_ops->sk_free_security(sk); | 2931 | return security_ops->sk_free_security(sk); |
| 2886 | } | 2932 | } |
| 2887 | 2933 | ||
| 2888 | static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir) | ||
