diff options
Diffstat (limited to 'net/core/scm.c')
-rw-r--r-- | net/core/scm.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/net/core/scm.c b/net/core/scm.c index 811b53fb330e..ff52ad0a5150 100644 --- a/net/core/scm.c +++ b/net/core/scm.c | |||
@@ -173,7 +173,7 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p) | |||
173 | if (err) | 173 | if (err) |
174 | goto error; | 174 | goto error; |
175 | 175 | ||
176 | if (pid_vnr(p->pid) != p->creds.pid) { | 176 | if (!p->pid || pid_vnr(p->pid) != p->creds.pid) { |
177 | struct pid *pid; | 177 | struct pid *pid; |
178 | err = -ESRCH; | 178 | err = -ESRCH; |
179 | pid = find_get_pid(p->creds.pid); | 179 | pid = find_get_pid(p->creds.pid); |
@@ -183,8 +183,9 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p) | |||
183 | p->pid = pid; | 183 | p->pid = pid; |
184 | } | 184 | } |
185 | 185 | ||
186 | if ((p->cred->euid != p->creds.uid) || | 186 | if (!p->cred || |
187 | (p->cred->egid != p->creds.gid)) { | 187 | (p->cred->euid != p->creds.uid) || |
188 | (p->cred->egid != p->creds.gid)) { | ||
188 | struct cred *cred; | 189 | struct cred *cred; |
189 | err = -ENOMEM; | 190 | err = -ENOMEM; |
190 | cred = prepare_creds(); | 191 | cred = prepare_creds(); |
@@ -193,7 +194,8 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p) | |||
193 | 194 | ||
194 | cred->uid = cred->euid = p->creds.uid; | 195 | cred->uid = cred->euid = p->creds.uid; |
195 | cred->gid = cred->egid = p->creds.gid; | 196 | cred->gid = cred->egid = p->creds.gid; |
196 | put_cred(p->cred); | 197 | if (p->cred) |
198 | put_cred(p->cred); | ||
197 | p->cred = cred; | 199 | p->cred = cred; |
198 | } | 200 | } |
199 | break; | 201 | break; |