The 'v5' NetLabel secid support patch
Subsystems (5)
v5 cover The 'v5' NetLabel secid support patch
This is the latest NetLabel secid support patch, the changes from the last (v4) version include:
* feedback from yesterday (10/4) regarding moving to SECINITSID_UNLABELED for the NetLabel TE information when there is nothing else available
* changes to allow NetLabel to send error messages back to the peer as required by the CIPSO specifications (my fault for not catching this sooner)
* bug fixes
This patch is based against the following (in order):
* David Miller's net-2.6 git tree from about an hour ago
* The RFC patch I posted earlier today to use SECINITSID_UNLABELED in the non secid case (I haven't heard anything on this, if there is still no comment I will be pushing this to netdev this evening)
* Venkat's nine secid patches from Sunday (10/1)
* Venkat's small update from earlier this week
--
paul moore
linux security @ hp
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
RFC v5 1/1 NetLabel: secid reconciliation support
This patch provides the missing NetLabel support to the secid reconciliation patchset.
This includes a change to the security_skb_flow_in() LSM hook to indicate if the hook is in the forwarding path and a change to netlbl_skbuff_err() to carry the forwarding information to the lower protocol level. This was required to meet the CIPSO specifications regarding handling permission denied errors.
--- include/linux/security.h | 10 +- include/net/netlabel.h | 6 - include/net/xfrm.h | 4 net/netlabel/netlabel_kapi.c | 5 - security/selinux/hooks.c | 140 +++++++++++++++++++--------- security/selinux/include/objsec.h | 1 security/selinux/include/selinux_netlabel.h | 34 ++---- security/selinux/ss/services.c | 109 ++++----------------- 8 files changed, 150 insertions(+), 159 deletions(-)
include/linux/security.h +6 -4
@@ -1384,7 +1384,7 @@ struct security_operations {void (*inet_csk_clone)(struct sock *newsk,const struct request_sock *req);void (*inet_conn_established)(struct sock *sk,struct sk_buff *skb);void (*req_classify_flow)(const struct request_sock *req,struct flowi *fl); -int (*skb_flow_in)(struct sk_buff *skb,unsigned short family); +int (*skb_flow_in)(struct sk_buff *skb,unsigned short family,u32 fwd);int (*skb_flow_out)(struct sk_buff *skb,u32 nf_secid);#endif /* CONFIG_SECURITY_NETWORK */
@@ -2962,9 +2962,10 @@ static inline void security_req_classify }static inline int security_skb_flow_in (struct sk_buff *skb, -unsigned short family) +unsigned short family, +u32 fwd) { -return security_ops->skb_flow_in (skb, family); +return security_ops->skb_flow_in (skb, family, fwd); } static inline int security_skb_flow_out(struct sk_buff *skb,
@@ -3131,7 +3132,8 @@ static inline void security_req_classify }static inline int security_skb_flow_in (struct sk_buff *skb, -unsigned short family) +unsigned short family, +u32 fwd) {return 1 ; }
include/net/netlabel.h +4 -2
@@ -237,7 +237,7 @@ int netlbl_socket_getattr(const struct s struct netlbl_lsm_secattr *secattr);int netlbl_skbuff_getattr (const struct sk_buff *skb,struct netlbl_lsm_secattr *secattr); -void netlbl_skbuff_err (struct sk_buff *skb,int error); +void netlbl_skbuff_err (struct sk_buff *skb,int error,u32 gateway);#else static inline int netlbl_socket_setattr (const struct socket *sock,const struct netlbl_lsm_secattr *secattr)
@@ -263,7 +263,9 @@ static inline int netlbl_skbuff_getattr(return -ENOSYS ; } -static inline void netlbl_skbuff_err (struct sk_buff *skb,int error) +static inline void netlbl_skbuff_err (struct sk_buff *skb, +int error, +u32 gateway) {return ; }
include/net/xfrm.h +3 -1
@@ -685,7 +685,9 @@ static inline int xfrm_policy_check(stru__xfrm_policy_check (sk, dir, skb, family);if (ret) - ret =security_skb_flow_in (skb, family); + ret =security_skb_flow_in (skb, + family, + dir ==XFRM_POLICY_FWD ?1 :0 );return ret; }
net/netlabel/netlabel_kapi.c +3 -2
@@ -159,6 +159,7 @@ int netlbl_skbuff_getattr(const struct s* netlbl_skbuff_err - Handle a LSM error on a sk_buff * @skb: the packet * @error: the error code +* @gateway: true if the packet is being forwarded and not consumed locally * * Description: * Deal with a LSM problem when handling the packet in @skb, typically this is
@@ -166,10 +167,10 @@ int netlbl_skbuff_getattr(const struct s* according to the packet's labeling protocol. * */ -void netlbl_skbuff_err (struct sk_buff *skb,int error) +void netlbl_skbuff_err (struct sk_buff *skb,int error,u32 gateway) {if (CIPSO_V4_OPTEXIST (skb)) -cipso_v4_error (skb, error,0 ); +cipso_v4_error (skb, error, gateway); }/**
security/selinux/hooks.c +99 -41
234 lines not on this page · raw message
security/selinux/include/objsec.h +0 -1
@@ -102,7 +102,6 @@ struct sk_security_struct {u32 sid;/* SID of this object */ u32 peer_sid;/* SID of peer */ #ifdef CONFIG_NETLABEL -u16 sclass;/* sock security class */ enum {/* NetLabel state */ NLBL_UNSET =0 , NLBL_REQUIRE,
security/selinux/include/selinux_netlabel.h +13 -21
@@ -42,17 +42,16 @@ int selinux_netlbl_socket_post_create(stint sock_family, u32 sid);void selinux_netlbl_sock_graft (struct sock *sk,struct socket *sock); -u32 selinux_netlbl_inet_conn_request (struct sk_buff *skb,u32 sock_sid); -int selinux_netlbl_sock_rcv_skb (struct sk_security_struct *sksec, +int selinux_netlbl_sock_rcv_skb (u32 sock_sid, +u16 sock_class,struct sk_buff *skb,struct avc_audit_data *ad); -u32 selinux_netlbl_socket_getpeersec_stream (struct socket *sock); -u32 selinux_netlbl_socket_getpeersec_dgram (struct sk_buff *skb);void selinux_netlbl_sk_security_init (struct sk_security_struct *ssec,int family);void selinux_netlbl_sk_clone_security (struct sk_security_struct *ssec,struct sk_security_struct *newssec);int selinux_netlbl_inode_permission (struct inode *inode,int mask); +int selinux_netlbl_skb_sid (struct sk_buff *skb,u32 base_sid,u32 *sid);#else static inline void selinux_netlbl_cache_invalidate (void ) {
@@ -72,29 +71,14 @@ static inline void selinux_netlbl_sock_greturn ; } -static inline u32 selinux_netlbl_inet_conn_request (struct sk_buff *skb, -u32 sock_sid) -{ -return SECSID_NULL ; -} - -static inline int selinux_netlbl_sock_rcv_skb (struct sk_security_struct *sksec, +static inline int selinux_netlbl_sock_rcv_skb (u32 sock_sid, +u16 sock_class,struct sk_buff *skb,struct avc_audit_data *ad) {return 0 ; } -static inline u32 selinux_netlbl_socket_getpeersec_stream (struct socket *sock) -{ -return SECSID_NULL ; -} - -static inline u32 selinux_netlbl_socket_getpeersec_dgram (struct sk_buff *skb) -{ -return SECSID_NULL ; -} -static inline void selinux_netlbl_sk_security_init (struct sk_security_struct *ssec,int family)
@@ -114,6 +98,14 @@ static inline int selinux_netlbl_inode_p {return 0 ; } + +static inline int selinux_netlbl_skb_sid (struct sk_buff *skb, +u32 base_sid, +u32 *sid) +{ + *sid =SECSID_NULL ; +return 0 ; +}#endif /* CONFIG_NETLABEL */ #endif
security/selinux/ss/services.c +22 -87
196 lines not on this page · raw message
--
paul moore
linux security @ hp
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.