Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 80883
b: refs/heads/master
c: 75e2291
h: refs/heads/master
i:
  80881: f1b1483
  80879: 6b1f93e
v: v3
  • Loading branch information
Paul Moore authored and James Morris committed Jan 29, 2008
1 parent 23509cf commit c0aa458
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 16efd45435fa695b501b7f73c3259bd7c77cc12c
refs/heads/master: 75e22910cf0c26802b09dac2e34c13e648d3ed02
2 changes: 2 additions & 0 deletions trunk/include/net/netlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ int netlbl_sock_setattr(struct sock *sk,
int netlbl_sock_getattr(struct sock *sk,
struct netlbl_lsm_secattr *secattr);
int netlbl_skbuff_getattr(const struct sk_buff *skb,
u16 family,
struct netlbl_lsm_secattr *secattr);
void netlbl_skbuff_err(struct sk_buff *skb, int error);

Expand Down Expand Up @@ -415,6 +416,7 @@ static inline int netlbl_sock_getattr(struct sock *sk,
return -ENOSYS;
}
static inline int netlbl_skbuff_getattr(const struct sk_buff *skb,
u16 family,
struct netlbl_lsm_secattr *secattr)
{
return -ENOSYS;
Expand Down
2 changes: 2 additions & 0 deletions trunk/net/netlabel/netlabel_kapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ int netlbl_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr)
/**
* netlbl_skbuff_getattr - Determine the security attributes of a packet
* @skb: the packet
* @family: protocol family
* @secattr: the security attributes
*
* Description:
Expand All @@ -342,6 +343,7 @@ int netlbl_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr)
*
*/
int netlbl_skbuff_getattr(const struct sk_buff *skb,
u16 family,
struct netlbl_lsm_secattr *secattr)
{
if (CIPSO_V4_OPTEXIST(skb) &&
Expand Down
33 changes: 22 additions & 11 deletions trunk/security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3429,6 +3429,7 @@ static int selinux_parse_skb(struct sk_buff *skb, struct avc_audit_data *ad,
/**
* selinux_skb_extlbl_sid - Determine the external label of a packet
* @skb: the packet
* @family: protocol family
* @sid: the packet's SID
*
* Description:
Expand All @@ -3441,13 +3442,16 @@ static int selinux_parse_skb(struct sk_buff *skb, struct avc_audit_data *ad,
* selinux_netlbl_skbuff_getsid().
*
*/
static void selinux_skb_extlbl_sid(struct sk_buff *skb, u32 *sid)
static void selinux_skb_extlbl_sid(struct sk_buff *skb,
u16 family,
u32 *sid)
{
u32 xfrm_sid;
u32 nlbl_sid;

selinux_skb_xfrm_sid(skb, &xfrm_sid);
if (selinux_netlbl_skbuff_getsid(skb,
family,
(xfrm_sid == SECSID_NULL ?
SECINITSID_NETMSG : xfrm_sid),
&nlbl_sid) != 0)
Expand Down Expand Up @@ -3940,7 +3944,7 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
if (err)
goto out;

err = selinux_netlbl_sock_rcv_skb(sksec, skb, &ad);
err = selinux_netlbl_sock_rcv_skb(sksec, skb, family, &ad);
if (err)
goto out;

Expand Down Expand Up @@ -3996,18 +4000,25 @@ static int selinux_socket_getpeersec_stream(struct socket *sock, char __user *op
static int selinux_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
{
u32 peer_secid = SECSID_NULL;
int err = 0;
u16 family;

if (sock && sock->sk->sk_family == PF_UNIX)
if (sock)
family = sock->sk->sk_family;
else if (skb && skb->sk)
family = skb->sk->sk_family;
else
goto out;

if (sock && family == PF_UNIX)
selinux_get_inode_sid(SOCK_INODE(sock), &peer_secid);
else if (skb)
selinux_skb_extlbl_sid(skb, &peer_secid);
selinux_skb_extlbl_sid(skb, family, &peer_secid);

if (peer_secid == SECSID_NULL)
err = -EINVAL;
out:
*secid = peer_secid;

return err;
if (peer_secid == SECSID_NULL)
return -EINVAL;
return 0;
}

static int selinux_sk_alloc_security(struct sock *sk, int family, gfp_t priority)
Expand Down Expand Up @@ -4062,7 +4073,7 @@ static int selinux_inet_conn_request(struct sock *sk, struct sk_buff *skb,
u32 newsid;
u32 peersid;

selinux_skb_extlbl_sid(skb, &peersid);
selinux_skb_extlbl_sid(skb, sk->sk_family, &peersid);
if (peersid == SECSID_NULL) {
req->secid = sksec->sid;
req->peer_secid = SECSID_NULL;
Expand Down Expand Up @@ -4100,7 +4111,7 @@ static void selinux_inet_conn_established(struct sock *sk,
{
struct sk_security_struct *sksec = sk->sk_security;

selinux_skb_extlbl_sid(skb, &sksec->peer_sid);
selinux_skb_extlbl_sid(skb, sk->sk_family, &sksec->peer_sid);
}

static void selinux_req_classify_flow(const struct request_sock *req,
Expand Down
8 changes: 7 additions & 1 deletion trunk/security/selinux/include/netlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ void selinux_netlbl_sk_security_init(struct sk_security_struct *ssec,
void selinux_netlbl_sk_security_clone(struct sk_security_struct *ssec,
struct sk_security_struct *newssec);

int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, u32 base_sid, u32 *sid);
int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
u16 family,
u32 base_sid,
u32 *sid);

void selinux_netlbl_sock_graft(struct sock *sk, struct socket *sock);
int selinux_netlbl_socket_post_create(struct socket *sock);
int selinux_netlbl_inode_permission(struct inode *inode, int mask);
int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
struct sk_buff *skb,
u16 family,
struct avc_audit_data *ad);
int selinux_netlbl_socket_setsockopt(struct socket *sock,
int level,
Expand Down Expand Up @@ -83,6 +87,7 @@ static inline void selinux_netlbl_sk_security_clone(
}

static inline int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
u16 family,
u32 base_sid,
u32 *sid)
{
Expand All @@ -106,6 +111,7 @@ static inline int selinux_netlbl_inode_permission(struct inode *inode,
}
static inline int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
struct sk_buff *skb,
u16 family,
struct avc_audit_data *ad)
{
return 0;
Expand Down
12 changes: 9 additions & 3 deletions trunk/security/selinux/netlabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ void selinux_netlbl_sk_security_clone(struct sk_security_struct *ssec,
/**
* selinux_netlbl_skbuff_getsid - Get the sid of a packet using NetLabel
* @skb: the packet
* @family: protocol family
* @base_sid: the SELinux SID to use as a context for MLS only attributes
* @sid: the SID
*
Expand All @@ -153,7 +154,10 @@ void selinux_netlbl_sk_security_clone(struct sk_security_struct *ssec,
* assign to the packet. Returns zero on success, negative values on failure.
*
*/
int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, u32 base_sid, u32 *sid)
int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
u16 family,
u32 base_sid,
u32 *sid)
{
int rc;
struct netlbl_lsm_secattr secattr;
Expand All @@ -164,7 +168,7 @@ int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, u32 base_sid, u32 *sid)
}

netlbl_secattr_init(&secattr);
rc = netlbl_skbuff_getattr(skb, &secattr);
rc = netlbl_skbuff_getattr(skb, family, &secattr);
if (rc == 0 && secattr.flags != NETLBL_SECATTR_NONE) {
rc = security_netlbl_secattr_to_sid(&secattr, base_sid, sid);
if (rc == 0 &&
Expand Down Expand Up @@ -292,6 +296,7 @@ int selinux_netlbl_inode_permission(struct inode *inode, int mask)
* selinux_netlbl_sock_rcv_skb - Do an inbound access check using NetLabel
* @sksec: the sock's sk_security_struct
* @skb: the packet
* @family: protocol family
* @ad: the audit data
*
* Description:
Expand All @@ -302,6 +307,7 @@ int selinux_netlbl_inode_permission(struct inode *inode, int mask)
*/
int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
struct sk_buff *skb,
u16 family,
struct avc_audit_data *ad)
{
int rc;
Expand All @@ -313,7 +319,7 @@ int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
return 0;

netlbl_secattr_init(&secattr);
rc = netlbl_skbuff_getattr(skb, &secattr);
rc = netlbl_skbuff_getattr(skb, family, &secattr);
if (rc == 0 && secattr.flags != NETLBL_SECATTR_NONE) {
rc = security_netlbl_secattr_to_sid(&secattr,
SECINITSID_NETMSG,
Expand Down

0 comments on commit c0aa458

Please sign in to comment.