diff options
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r-- | net/unix/af_unix.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index f70475bfb62a..de6ec519272e 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -128,23 +128,17 @@ static atomic_t unix_nr_socks = ATOMIC_INIT(0); | |||
128 | #define UNIX_ABSTRACT(sk) (unix_sk(sk)->addr->hash != UNIX_HASH_SIZE) | 128 | #define UNIX_ABSTRACT(sk) (unix_sk(sk)->addr->hash != UNIX_HASH_SIZE) |
129 | 129 | ||
130 | #ifdef CONFIG_SECURITY_NETWORK | 130 | #ifdef CONFIG_SECURITY_NETWORK |
131 | static void unix_get_peersec_dgram(struct sk_buff *skb) | 131 | static void unix_get_secdata(struct scm_cookie *scm, struct sk_buff *skb) |
132 | { | 132 | { |
133 | int err; | 133 | memcpy(UNIXSID(skb), &scm->secid, sizeof(u32)); |
134 | |||
135 | err = security_socket_getpeersec_dgram(skb, UNIXSECDATA(skb), | ||
136 | UNIXSECLEN(skb)); | ||
137 | if (err) | ||
138 | *(UNIXSECDATA(skb)) = NULL; | ||
139 | } | 134 | } |
140 | 135 | ||
141 | static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb) | 136 | static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb) |
142 | { | 137 | { |
143 | scm->secdata = *UNIXSECDATA(skb); | 138 | scm->secid = *UNIXSID(skb); |
144 | scm->seclen = *UNIXSECLEN(skb); | ||
145 | } | 139 | } |
146 | #else | 140 | #else |
147 | static inline void unix_get_peersec_dgram(struct sk_buff *skb) | 141 | static inline void unix_get_secdata(struct scm_cookie *scm, struct sk_buff *skb) |
148 | { } | 142 | { } |
149 | 143 | ||
150 | static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb) | 144 | static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb) |
@@ -663,11 +657,10 @@ static int unix_autobind(struct socket *sock) | |||
663 | goto out; | 657 | goto out; |
664 | 658 | ||
665 | err = -ENOMEM; | 659 | err = -ENOMEM; |
666 | addr = kmalloc(sizeof(*addr) + sizeof(short) + 16, GFP_KERNEL); | 660 | addr = kzalloc(sizeof(*addr) + sizeof(short) + 16, GFP_KERNEL); |
667 | if (!addr) | 661 | if (!addr) |
668 | goto out; | 662 | goto out; |
669 | 663 | ||
670 | memset(addr, 0, sizeof(*addr) + sizeof(short) + 16); | ||
671 | addr->name->sun_family = AF_UNIX; | 664 | addr->name->sun_family = AF_UNIX; |
672 | atomic_set(&addr->refcnt, 1); | 665 | atomic_set(&addr->refcnt, 1); |
673 | 666 | ||
@@ -1323,8 +1316,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1323 | memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred)); | 1316 | memcpy(UNIXCREDS(skb), &siocb->scm->creds, sizeof(struct ucred)); |
1324 | if (siocb->scm->fp) | 1317 | if (siocb->scm->fp) |
1325 | unix_attach_fds(siocb->scm, skb); | 1318 | unix_attach_fds(siocb->scm, skb); |
1326 | 1319 | unix_get_secdata(siocb->scm, skb); | |
1327 | unix_get_peersec_dgram(skb); | ||
1328 | 1320 | ||
1329 | skb->h.raw = skb->data; | 1321 | skb->h.raw = skb->data; |
1330 | err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len); | 1322 | err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len); |