aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-11-13 18:39:10 -0500
committerJames Morris <jmorris@namei.org>2008-11-13 18:39:10 -0500
commit19d65624d38d6296dddf725d1b03baa8a491a553 (patch)
tree845b0cef28abf1c1c5baeafefbeeae1c53c88160
parent8f4194026bb1e3d95fedb340a2935895845ea1d5 (diff)
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: David Howells <dhowells@redhat.com> Reviewed-by: James Morris <jmorris@namei.org> Acked-by: Serge Hallyn <serue@us.ibm.com> Cc: netdev@vger.kernel.org Signed-off-by: James Morris <jmorris@namei.org>
-rw-r--r--net/unix/af_unix.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 4d3c6071b9a4..338c1aec7089 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -467,8 +467,7 @@ static int unix_listen(struct socket *sock, int backlog)
467 sk->sk_state = TCP_LISTEN; 467 sk->sk_state = TCP_LISTEN;
468 /* set credentials so connect can copy them */ 468 /* set credentials so connect can copy them */
469 sk->sk_peercred.pid = task_tgid_vnr(current); 469 sk->sk_peercred.pid = task_tgid_vnr(current);
470 sk->sk_peercred.uid = current->euid; 470 current_euid_egid(&sk->sk_peercred.uid, &sk->sk_peercred.gid);
471 sk->sk_peercred.gid = current->egid;
472 err = 0; 471 err = 0;
473 472
474out_unlock: 473out_unlock:
@@ -1126,8 +1125,7 @@ restart:
1126 newsk->sk_state = TCP_ESTABLISHED; 1125 newsk->sk_state = TCP_ESTABLISHED;
1127 newsk->sk_type = sk->sk_type; 1126 newsk->sk_type = sk->sk_type;
1128 newsk->sk_peercred.pid = task_tgid_vnr(current); 1127 newsk->sk_peercred.pid = task_tgid_vnr(current);
1129 newsk->sk_peercred.uid = current->euid; 1128 current_euid_egid(&newsk->sk_peercred.uid, &newsk->sk_peercred.gid);
1130 newsk->sk_peercred.gid = current->egid;
1131 newu = unix_sk(newsk); 1129 newu = unix_sk(newsk);
1132 newsk->sk_sleep = &newu->peer_wait; 1130 newsk->sk_sleep = &newu->peer_wait;
1133 otheru = unix_sk(other); 1131 otheru = unix_sk(other);
@@ -1187,8 +1185,9 @@ static int unix_socketpair(struct socket *socka, struct socket *sockb)
1187 unix_peer(ska)=skb; 1185 unix_peer(ska)=skb;
1188 unix_peer(skb)=ska; 1186 unix_peer(skb)=ska;
1189 ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current); 1187 ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current);
1190 ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid; 1188 current_euid_egid(&skb->sk_peercred.uid, &skb->sk_peercred.gid);
1191 ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid; 1189 ska->sk_peercred.uid = skb->sk_peercred.uid;
1190 ska->sk_peercred.gid = skb->sk_peercred.gid;
1192 1191
1193 if (ska->sk_type != SOCK_DGRAM) { 1192 if (ska->sk_type != SOCK_DGRAM) {
1194 ska->sk_state = TCP_ESTABLISHED; 1193 ska->sk_state = TCP_ESTABLISHED;