mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 13:44:15 +08:00
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>
This commit is contained in:
parent
8f4194026b
commit
19d65624d3
@ -467,8 +467,7 @@ static int unix_listen(struct socket *sock, int backlog)
|
||||
sk->sk_state = TCP_LISTEN;
|
||||
/* set credentials so connect can copy them */
|
||||
sk->sk_peercred.pid = task_tgid_vnr(current);
|
||||
sk->sk_peercred.uid = current->euid;
|
||||
sk->sk_peercred.gid = current->egid;
|
||||
current_euid_egid(&sk->sk_peercred.uid, &sk->sk_peercred.gid);
|
||||
err = 0;
|
||||
|
||||
out_unlock:
|
||||
@ -1126,8 +1125,7 @@ restart:
|
||||
newsk->sk_state = TCP_ESTABLISHED;
|
||||
newsk->sk_type = sk->sk_type;
|
||||
newsk->sk_peercred.pid = task_tgid_vnr(current);
|
||||
newsk->sk_peercred.uid = current->euid;
|
||||
newsk->sk_peercred.gid = current->egid;
|
||||
current_euid_egid(&newsk->sk_peercred.uid, &newsk->sk_peercred.gid);
|
||||
newu = unix_sk(newsk);
|
||||
newsk->sk_sleep = &newu->peer_wait;
|
||||
otheru = unix_sk(other);
|
||||
@ -1187,8 +1185,9 @@ static int unix_socketpair(struct socket *socka, struct socket *sockb)
|
||||
unix_peer(ska)=skb;
|
||||
unix_peer(skb)=ska;
|
||||
ska->sk_peercred.pid = skb->sk_peercred.pid = task_tgid_vnr(current);
|
||||
ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid;
|
||||
ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid;
|
||||
current_euid_egid(&skb->sk_peercred.uid, &skb->sk_peercred.gid);
|
||||
ska->sk_peercred.uid = skb->sk_peercred.uid;
|
||||
ska->sk_peercred.gid = skb->sk_peercred.gid;
|
||||
|
||||
if (ska->sk_type != SOCK_DGRAM) {
|
||||
ska->sk_state = TCP_ESTABLISHED;
|
||||
|
Loading…
Reference in New Issue
Block a user