aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/security.h
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-10-01 12:55:53 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2006-10-01 12:55:53 -0400
commit8a84fc15ae5cafcc366dd85cf8e1ab2040679abc (patch)
tree5d8dce194c9667fa92e9ec9f545cec867a9a1e0d /include/linux/security.h
parent28b79ff9661b22e4c41c0d00d4ab8503e810f13d (diff)
parent82965addad66fce61a92c5f03104ea90b0b87124 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Manually resolve conflict in include/mtd/Kbuild Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'include/linux/security.h')
-rw-r--r--include/linux/security.h240
1 files changed, 204 insertions, 36 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index 6bc2aad494ff..9b5fea81f55e 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
35struct ctl_table; 37struct ctl_table;
36 38
@@ -88,6 +90,7 @@ extern int cap_netlink_recv(struct sk_buff *skb, int cap);
88struct nfsctl_arg; 90struct nfsctl_arg;
89struct sched_param; 91struct sched_param;
90struct swap_info_struct; 92struct swap_info_struct;
93struct 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 */
@@ -1549,6 +1595,7 @@ static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1549 1595
1550static inline int security_inode_alloc (struct inode *inode) 1596static inline int security_inode_alloc (struct inode *inode)
1551{ 1597{
1598 inode->i_security = NULL;
1552 return security_ops->inode_alloc_security (inode); 1599 return security_ops->inode_alloc_security (inode);
1553} 1600}
1554 1601
@@ -2778,13 +2825,13 @@ static inline int security_socket_create (int family, int type,
2778 return security_ops->socket_create(family, type, protocol, kern); 2825 return security_ops->socket_create(family, type, protocol, kern);
2779} 2826}
2780 2827
2781static inline void security_socket_post_create(struct socket * sock, 2828static inline int security_socket_post_create(struct socket * sock,
2782 int family, 2829 int family,
2783 int type, 2830 int type,
2784 int protocol, int kern) 2831 int protocol, int kern)
2785{ 2832{
2786 security_ops->socket_post_create(sock, family, type, 2833 return security_ops->socket_post_create(sock, family, type,
2787 protocol, kern); 2834 protocol, kern);
2788} 2835}
2789 2836
2790static inline int security_socket_bind(struct socket * sock, 2837static inline int security_socket_bind(struct socket * sock,
@@ -2885,9 +2932,36 @@ static inline void security_sk_free(struct sock *sk)
2885 return security_ops->sk_free_security(sk); 2932 return security_ops->sk_free_security(sk);
2886} 2933}
2887 2934
2888static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir) 2935static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2936{
2937 return security_ops->sk_clone_security(sk, newsk);
2938}
2939
2940static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
2889{ 2941{
2890 return security_ops->sk_getsid(sk, fl, dir); 2942 security_ops->sk_getsecid(sk, &fl->secid);
2943}
2944
2945static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2946{
2947 security_ops->req_classify_flow(req, fl);
2948}
2949
2950static inline void security_sock_graft(struct sock* sk, struct socket *parent)
2951{
2952 security_ops->sock_graft(sk, parent);
2953}
2954
2955static inline int security_inet_conn_request(struct sock *sk,
2956 struct sk_buff *skb, struct request_sock *req)
2957{
2958 return security_ops->inet_conn_request(sk, skb, req);
2959}
2960
2961static inline void security_inet_csk_clone(struct sock *newsk,
2962 const struct request_sock *req)
2963{
2964 security_ops->inet_csk_clone(newsk, req);
2891} 2965}
2892#else /* CONFIG_SECURITY_NETWORK */ 2966#else /* CONFIG_SECURITY_NETWORK */
2893static inline int security_unix_stream_connect(struct socket * sock, 2967static inline int security_unix_stream_connect(struct socket * sock,
@@ -2909,11 +2983,12 @@ static inline int security_socket_create (int family, int type,
2909 return 0; 2983 return 0;
2910} 2984}
2911 2985
2912static inline void security_socket_post_create(struct socket * sock, 2986static inline int security_socket_post_create(struct socket * sock,
2913 int family, 2987 int family,
2914 int type, 2988 int type,
2915 int protocol, int kern) 2989 int protocol, int kern)
2916{ 2990{
2991 return 0;
2917} 2992}
2918 2993
2919static inline int security_socket_bind(struct socket * sock, 2994static inline int security_socket_bind(struct socket * sock,
@@ -3011,16 +3086,43 @@ static inline void security_sk_free(struct sock *sk)
3011{ 3086{
3012} 3087}
3013 3088
3014static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir) 3089static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
3090{
3091}
3092
3093static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
3094{
3095}
3096
3097static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
3098{
3099}
3100
3101static inline void security_sock_graft(struct sock* sk, struct socket *parent)
3102{
3103}
3104
3105static inline int security_inet_conn_request(struct sock *sk,
3106 struct sk_buff *skb, struct request_sock *req)
3015{ 3107{
3016 return 0; 3108 return 0;
3017} 3109}
3110
3111static inline void security_inet_csk_clone(struct sock *newsk,
3112 const struct request_sock *req)
3113{
3114}
3018#endif /* CONFIG_SECURITY_NETWORK */ 3115#endif /* CONFIG_SECURITY_NETWORK */
3019 3116
3020#ifdef CONFIG_SECURITY_NETWORK_XFRM 3117#ifdef CONFIG_SECURITY_NETWORK_XFRM
3021static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) 3118static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3022{ 3119{
3023 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx); 3120 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx, NULL);
3121}
3122
3123static inline int security_xfrm_sock_policy_alloc(struct xfrm_policy *xp, struct sock *sk)
3124{
3125 return security_ops->xfrm_policy_alloc_security(xp, NULL, sk);
3024} 3126}
3025 3127
3026static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) 3128static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
@@ -3038,9 +3140,18 @@ static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3038 return security_ops->xfrm_policy_delete_security(xp); 3140 return security_ops->xfrm_policy_delete_security(xp);
3039} 3141}
3040 3142
3041static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx) 3143static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3144 struct xfrm_user_sec_ctx *sec_ctx)
3042{ 3145{
3043 return security_ops->xfrm_state_alloc_security(x, sec_ctx); 3146 return security_ops->xfrm_state_alloc_security(x, sec_ctx, NULL, 0);
3147}
3148
3149static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3150 struct xfrm_sec_ctx *polsec, u32 secid)
3151{
3152 if (!polsec)
3153 return 0;
3154 return security_ops->xfrm_state_alloc_security(x, NULL, polsec, secid);
3044} 3155}
3045 3156
3046static inline int security_xfrm_state_delete(struct xfrm_state *x) 3157static inline int security_xfrm_state_delete(struct xfrm_state *x)
@@ -3053,9 +3164,32 @@ static inline void security_xfrm_state_free(struct xfrm_state *x)
3053 security_ops->xfrm_state_free_security(x); 3164 security_ops->xfrm_state_free_security(x);
3054} 3165}
3055 3166
3056static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir) 3167static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3168{
3169 return security_ops->xfrm_policy_lookup(xp, fl_secid, dir);
3170}
3171
3172static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3173 struct xfrm_policy *xp, struct flowi *fl)
3057{ 3174{
3058 return security_ops->xfrm_policy_lookup(xp, sk_sid, dir); 3175 return security_ops->xfrm_state_pol_flow_match(x, xp, fl);
3176}
3177
3178static inline int security_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm)
3179{
3180 return security_ops->xfrm_flow_state_match(fl, xfrm);
3181}
3182
3183static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3184{
3185 return security_ops->xfrm_decode_session(skb, secid, 1);
3186}
3187
3188static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3189{
3190 int rc = security_ops->xfrm_decode_session(skb, &fl->secid, 0);
3191
3192 BUG_ON(rc);
3059} 3193}
3060#else /* CONFIG_SECURITY_NETWORK_XFRM */ 3194#else /* CONFIG_SECURITY_NETWORK_XFRM */
3061static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) 3195static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
@@ -3063,6 +3197,11 @@ static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm
3063 return 0; 3197 return 0;
3064} 3198}
3065 3199
3200static inline int security_xfrm_sock_policy_alloc(struct xfrm_policy *xp, struct sock *sk)
3201{
3202 return 0;
3203}
3204
3066static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) 3205static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3067{ 3206{
3068 return 0; 3207 return 0;
@@ -3077,7 +3216,14 @@ static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3077 return 0; 3216 return 0;
3078} 3217}
3079 3218
3080static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx) 3219static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3220 struct xfrm_user_sec_ctx *sec_ctx)
3221{
3222 return 0;
3223}
3224
3225static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3226 struct xfrm_sec_ctx *polsec, u32 secid)
3081{ 3227{
3082 return 0; 3228 return 0;
3083} 3229}
@@ -3091,10 +3237,32 @@ static inline int security_xfrm_state_delete(struct xfrm_state *x)
3091 return 0; 3237 return 0;
3092} 3238}
3093 3239
3094static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir) 3240static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir)
3241{
3242 return 0;
3243}
3244
3245static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3246 struct xfrm_policy *xp, struct flowi *fl)
3247{
3248 return 1;
3249}
3250
3251static inline int security_xfrm_flow_state_match(struct flowi *fl,
3252 struct xfrm_state *xfrm)
3253{
3254 return 1;
3255}
3256
3257static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3095{ 3258{
3096 return 0; 3259 return 0;
3097} 3260}
3261
3262static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
3263{
3264}
3265
3098#endif /* CONFIG_SECURITY_NETWORK_XFRM */ 3266#endif /* CONFIG_SECURITY_NETWORK_XFRM */
3099 3267
3100#ifdef CONFIG_KEYS 3268#ifdef CONFIG_KEYS