diff options
Diffstat (limited to 'include/net/scm.h')
-rw-r--r-- | include/net/scm.h | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/include/net/scm.h b/include/net/scm.h index b11708105681..8de2d37d2077 100644 --- a/include/net/scm.h +++ b/include/net/scm.h | |||
@@ -26,7 +26,6 @@ struct scm_fp_list { | |||
26 | 26 | ||
27 | struct scm_cookie { | 27 | struct scm_cookie { |
28 | struct pid *pid; /* Skb credentials */ | 28 | struct pid *pid; /* Skb credentials */ |
29 | const struct cred *cred; | ||
30 | struct scm_fp_list *fp; /* Passed files */ | 29 | struct scm_fp_list *fp; /* Passed files */ |
31 | struct scm_creds creds; /* Skb credentials */ | 30 | struct scm_creds creds; /* Skb credentials */ |
32 | #ifdef CONFIG_SECURITY_NETWORK | 31 | #ifdef CONFIG_SECURITY_NETWORK |
@@ -51,23 +50,18 @@ static __inline__ void unix_get_peersec_dgram(struct socket *sock, struct scm_co | |||
51 | #endif /* CONFIG_SECURITY_NETWORK */ | 50 | #endif /* CONFIG_SECURITY_NETWORK */ |
52 | 51 | ||
53 | static __inline__ void scm_set_cred(struct scm_cookie *scm, | 52 | static __inline__ void scm_set_cred(struct scm_cookie *scm, |
54 | struct pid *pid, const struct cred *cred) | 53 | struct pid *pid, kuid_t uid, kgid_t gid) |
55 | { | 54 | { |
56 | scm->pid = get_pid(pid); | 55 | scm->pid = get_pid(pid); |
57 | scm->cred = cred ? get_cred(cred) : NULL; | ||
58 | scm->creds.pid = pid_vnr(pid); | 56 | scm->creds.pid = pid_vnr(pid); |
59 | scm->creds.uid = cred ? cred->uid : INVALID_UID; | 57 | scm->creds.uid = uid; |
60 | scm->creds.gid = cred ? cred->gid : INVALID_GID; | 58 | scm->creds.gid = gid; |
61 | } | 59 | } |
62 | 60 | ||
63 | static __inline__ void scm_destroy_cred(struct scm_cookie *scm) | 61 | static __inline__ void scm_destroy_cred(struct scm_cookie *scm) |
64 | { | 62 | { |
65 | put_pid(scm->pid); | 63 | put_pid(scm->pid); |
66 | scm->pid = NULL; | 64 | scm->pid = NULL; |
67 | |||
68 | if (scm->cred) | ||
69 | put_cred(scm->cred); | ||
70 | scm->cred = NULL; | ||
71 | } | 65 | } |
72 | 66 | ||
73 | static __inline__ void scm_destroy(struct scm_cookie *scm) | 67 | static __inline__ void scm_destroy(struct scm_cookie *scm) |
@@ -81,8 +75,10 @@ static __inline__ int scm_send(struct socket *sock, struct msghdr *msg, | |||
81 | struct scm_cookie *scm, bool forcecreds) | 75 | struct scm_cookie *scm, bool forcecreds) |
82 | { | 76 | { |
83 | memset(scm, 0, sizeof(*scm)); | 77 | memset(scm, 0, sizeof(*scm)); |
78 | scm->creds.uid = INVALID_UID; | ||
79 | scm->creds.gid = INVALID_GID; | ||
84 | if (forcecreds) | 80 | if (forcecreds) |
85 | scm_set_cred(scm, task_tgid(current), current_cred()); | 81 | scm_set_cred(scm, task_tgid(current), current_uid(), current_gid()); |
86 | unix_get_peersec_dgram(sock, scm); | 82 | unix_get_peersec_dgram(sock, scm); |
87 | if (msg->msg_controllen <= 0) | 83 | if (msg->msg_controllen <= 0) |
88 | return 0; | 84 | return 0; |