Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 235110
b: refs/heads/master
c: 2ad18bd
h: refs/heads/master
v: v3
  • Loading branch information
Harry Ciao authored and Eric Paris committed Mar 3, 2011
1 parent cd8c257 commit 731b8e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 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: 6f5317e730505d5cbc851c435a2dfe3d5a21d343
refs/heads/master: 2ad18bdf3b8f84c85c7da7e4de365f7c5701fb3f
27 changes: 21 additions & 6 deletions trunk/security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3591,9 +3591,16 @@ static int selinux_skb_peerlbl_sid(struct sk_buff *skb, u16 family, u32 *sid)

/* socket security operations */

static u32 socket_sockcreate_sid(const struct task_security_struct *tsec)
static int socket_sockcreate_sid(const struct task_security_struct *tsec,
u16 secclass, u32 *socksid)
{
return tsec->sockcreate_sid ? : tsec->sid;
if (tsec->sockcreate_sid > SECSID_NULL) {
*socksid = tsec->sockcreate_sid;
return 0;
}

return security_transition_sid(tsec->sid, tsec->sid, secclass, NULL,
socksid);
}

static int sock_has_perm(struct task_struct *task, struct sock *sk, u32 perms)
Expand All @@ -3617,12 +3624,16 @@ static int selinux_socket_create(int family, int type,
const struct task_security_struct *tsec = current_security();
u32 newsid;
u16 secclass;
int rc;

if (kern)
return 0;

newsid = socket_sockcreate_sid(tsec);
secclass = socket_type_to_security_class(family, type, protocol);
rc = socket_sockcreate_sid(tsec, secclass, &newsid);
if (rc)
return rc;

return avc_has_perm(tsec->sid, newsid, secclass, SOCKET__CREATE, NULL);
}

Expand All @@ -3634,12 +3645,16 @@ static int selinux_socket_post_create(struct socket *sock, int family,
struct sk_security_struct *sksec;
int err = 0;

isec->sclass = socket_type_to_security_class(family, type, protocol);

if (kern)
isec->sid = SECINITSID_KERNEL;
else
isec->sid = socket_sockcreate_sid(tsec);
else {
err = socket_sockcreate_sid(tsec, isec->sclass, &(isec->sid));
if (err)
return err;
}

isec->sclass = socket_type_to_security_class(family, type, protocol);
isec->initialized = 1;

if (sock->sk) {
Expand Down

0 comments on commit 731b8e9

Please sign in to comment.