Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 201860
b: refs/heads/master
c: d4f2d97
h: refs/heads/master
v: v3
  • Loading branch information
Paul Moore authored and James Morris committed Aug 2, 2010
1 parent f7a6e76 commit 4003cfb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 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: 4d1e24514d80cb266231d0c1b6c02161970ad019
refs/heads/master: d4f2d97841827cb876da8b607df05a3dab812416
32 changes: 12 additions & 20 deletions trunk/security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3671,6 +3671,12 @@ 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)
{
return tsec->sockcreate_sid ? : tsec->sid;
}

static int socket_has_perm(struct task_struct *task, struct socket *sock,
u32 perms)
{
Expand Down Expand Up @@ -3698,44 +3704,30 @@ static int selinux_socket_create(int family, int type,
{
const struct cred *cred = current_cred();
const struct task_security_struct *tsec = cred->security;
u32 sid, newsid;
u32 newsid;
u16 secclass;
int err = 0;

if (kern)
goto out;

sid = tsec->sid;
newsid = tsec->sockcreate_sid ?: sid;
return 0;

newsid = socket_sockcreate_sid(tsec);
secclass = socket_type_to_security_class(family, type, protocol);
err = avc_has_perm(sid, newsid, secclass, SOCKET__CREATE, NULL);

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

static int selinux_socket_post_create(struct socket *sock, int family,
int type, int protocol, int kern)
{
const struct cred *cred = current_cred();
const struct task_security_struct *tsec = cred->security;
struct inode_security_struct *isec;
struct inode_security_struct *isec = SOCK_INODE(sock)->i_security;
struct sk_security_struct *sksec;
u32 sid, newsid;
int err = 0;

sid = tsec->sid;
newsid = tsec->sockcreate_sid;

isec = SOCK_INODE(sock)->i_security;

if (kern)
isec->sid = SECINITSID_KERNEL;
else if (newsid)
isec->sid = newsid;
else
isec->sid = sid;
isec->sid = socket_sockcreate_sid(tsec);

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

0 comments on commit 4003cfb

Please sign in to comment.