1 /* SPDX-License-Identifier: GPL-2.0 */
3 * SELinux support for the XFRM LSM hooks
5 * Author : Trent Jaeger, <jaegert@us.ibm.com>
6 * Updated : Venkat Yekkirala, <vyekkirala@TrustedCS.com>
8 #ifndef _SELINUX_XFRM_H_
9 #define _SELINUX_XFRM_H_
13 int selinux_xfrm_policy_alloc(struct xfrm_sec_ctx
**ctxp
,
14 struct xfrm_user_sec_ctx
*uctx
,
16 int selinux_xfrm_policy_clone(struct xfrm_sec_ctx
*old_ctx
,
17 struct xfrm_sec_ctx
**new_ctxp
);
18 void selinux_xfrm_policy_free(struct xfrm_sec_ctx
*ctx
);
19 int selinux_xfrm_policy_delete(struct xfrm_sec_ctx
*ctx
);
20 int selinux_xfrm_state_alloc(struct xfrm_state
*x
,
21 struct xfrm_user_sec_ctx
*uctx
);
22 int selinux_xfrm_state_alloc_acquire(struct xfrm_state
*x
,
23 struct xfrm_sec_ctx
*polsec
, u32 secid
);
24 void selinux_xfrm_state_free(struct xfrm_state
*x
);
25 int selinux_xfrm_state_delete(struct xfrm_state
*x
);
26 int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx
*ctx
, u32 fl_secid
, u8 dir
);
27 int selinux_xfrm_state_pol_flow_match(struct xfrm_state
*x
,
28 struct xfrm_policy
*xp
,
29 const struct flowi
*fl
);
31 #ifdef CONFIG_SECURITY_NETWORK_XFRM
32 extern atomic_t selinux_xfrm_refcount
;
34 static inline int selinux_xfrm_enabled(void)
36 return (atomic_read(&selinux_xfrm_refcount
) > 0);
39 int selinux_xfrm_sock_rcv_skb(u32 sk_sid
, struct sk_buff
*skb
,
40 struct common_audit_data
*ad
);
41 int selinux_xfrm_postroute_last(u32 sk_sid
, struct sk_buff
*skb
,
42 struct common_audit_data
*ad
, u8 proto
);
43 int selinux_xfrm_decode_session(struct sk_buff
*skb
, u32
*sid
, int ckall
);
44 int selinux_xfrm_skb_sid(struct sk_buff
*skb
, u32
*sid
);
46 static inline void selinux_xfrm_notify_policyload(void)
50 down_read(&net_rwsem
);
52 rt_genid_bump_all(net
);
56 static inline int selinux_xfrm_enabled(void)
61 static inline int selinux_xfrm_sock_rcv_skb(u32 sk_sid
, struct sk_buff
*skb
,
62 struct common_audit_data
*ad
)
67 static inline int selinux_xfrm_postroute_last(u32 sk_sid
, struct sk_buff
*skb
,
68 struct common_audit_data
*ad
,
74 static inline int selinux_xfrm_decode_session(struct sk_buff
*skb
, u32
*sid
,
81 static inline void selinux_xfrm_notify_policyload(void)
85 static inline int selinux_xfrm_skb_sid(struct sk_buff
*skb
, u32
*sid
)
92 #endif /* _SELINUX_XFRM_H_ */