xfrm.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * SELinux support for the XFRM LSM hooks
  3. *
  4. * Author : Trent Jaeger, <jaegert@us.ibm.com>
  5. */
  6. #ifndef _SELINUX_XFRM_H_
  7. #define _SELINUX_XFRM_H_
  8. int selinux_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
  9. int selinux_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new);
  10. void selinux_xfrm_policy_free(struct xfrm_policy *xp);
  11. int selinux_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
  12. void selinux_xfrm_state_free(struct xfrm_state *x);
  13. int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir);
  14. /*
  15. * Extract the security blob from the sock (it's actually on the socket)
  16. */
  17. static inline struct inode_security_struct *get_sock_isec(struct sock *sk)
  18. {
  19. if (!sk->sk_socket)
  20. return NULL;
  21. return SOCK_INODE(sk->sk_socket)->i_security;
  22. }
  23. static inline u32 selinux_no_sk_sid(struct flowi *fl)
  24. {
  25. /* NOTE: no sock occurs on ICMP reply, forwards, ... */
  26. /* icmp_reply: authorize as kernel packet */
  27. if (fl && fl->proto == IPPROTO_ICMP) {
  28. return SECINITSID_KERNEL;
  29. }
  30. return SECINITSID_ANY_SOCKET;
  31. }
  32. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  33. int selinux_xfrm_sock_rcv_skb(u32 sid, struct sk_buff *skb);
  34. int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb);
  35. #else
  36. static inline int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb)
  37. {
  38. return 0;
  39. }
  40. static inline int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb)
  41. {
  42. return NF_ACCEPT;
  43. }
  44. #endif
  45. #endif /* _SELINUX_XFRM_H_ */