Commit 19d65624 authored by David Howells's avatar David Howells Committed by James Morris

CRED: Wrap task credential accesses in the UNIX socket protocol

Wrap access to task credentials so that they can be separated more easily from
the task_struct during the introduction of COW creds.

Change most current->(|e|s|fs)[ug]id to current_(|e|s|fs)[ug]id().

Change some task->e?[ug]id to task_e?[ug]id().  In some places it makes more
sense to use RCU directly rather than a convenient wrapper; these will be
addressed by later patches.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarJames Morris <jmorris@namei.org>
Acked-by: default avatarSerge Hallyn <serue@us.ibm.com>
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 8f419402
...@@ -467,8 +467,7 @@ static int unix_listen(struct socket *sock, int backlog) ...@@ -467,8 +467,7 @@ static int unix_listen(struct socket *sock, int backlog)
sk->sk_state = TCP_LISTEN; sk->sk_state = TCP_LISTEN;
/* set credentials so connect can copy them */ /* set credentials so connect can copy them */
sk->sk_peercred.pid = task_tgid_vnr(current); sk->sk_peercred.pid = task_tgid_vnr(current);
sk->sk_peercred.uid = current->euid; current_euid_egid(&sk->sk_peercred.uid, &sk->sk_peercred.gid);
sk->sk_peercred.gid = current->egid;
err = 0; err = 0;
out_unlock: out_unlock:
...@@ -1126,8 +1125,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1126,8 +1125,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
newsk->sk_state = TCP_ESTABLISHED; newsk->sk_state = TCP_ESTABLISHED;
newsk->sk_type = sk->sk_type; newsk->sk_type = sk->sk_type;
newsk->sk_peercred.pid = task_tgid_vnr(current); newsk->sk_peercred.pid = task_tgid_vnr(current);
newsk->sk_peercred.uid = current->euid; current_euid_egid(&newsk->sk_peercred.uid, &newsk->sk_peercred.gid);
newsk->sk_peercred.gid = current->egid;
newu = unix_sk(newsk); newu = unix_sk(newsk);
newsk->sk_sleep = &newu->peer_wait; newsk->sk_sleep = &newu->peer_wait;
otheru = unix_sk(other); otheru = unix_sk(other);
...@@ -1187,8 +1185,9 @@ static int unix_socketpair(struct socket *socka, struct socket *sockb) ...@@ -1187,8 +1185,9 @@ static int unix_socketpair(struct socket *socka, struct socket *sockb)
unix_peer(ska)=skb; unix_peer(ska)=skb;
unix_peer(skb)=ska; unix_peer(skb)=ska;
ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current); ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current);
ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid; current_euid_egid(&skb->sk_peercred.uid, &skb->sk_peercred.gid);
ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid; ska->sk_peercred.uid = skb->sk_peercred.uid;
ska->sk_peercred.gid = skb->sk_peercred.gid;
if (ska->sk_type != SOCK_DGRAM) { if (ska->sk_type != SOCK_DGRAM) {
ska->sk_state = TCP_ESTABLISHED; ska->sk_state = TCP_ESTABLISHED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment