summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2019-06-25 00:21:45 +0800
committerBen Hutchings <ben@decadent.org.uk>2019-10-05 16:20:07 +0100
commitb4b1f8ed7290a00b05a52a165282e394a620c816 (patch)
tree1cd69b5210609bb5fcdb18b7aaaa66cd5f9a9a5e /net
parent2489c9a50ed7ee6400fe93b70523fe37bae39eb0 (diff)
downloadlinux-stable-b4b1f8ed7290a00b05a52a165282e394a620c816.tar.gz
linux-stable-b4b1f8ed7290a00b05a52a165282e394a620c816.tar.bz2
linux-stable-b4b1f8ed7290a00b05a52a165282e394a620c816.zip
sctp: change to hold sk after auth shkey is created successfully
commit 25bff6d5478b2a02368097015b7d8eb727c87e16 upstream. Now in sctp_endpoint_init(), it holds the sk then creates auth shkey. But when the creation fails, it doesn't release the sk, which causes a sk defcnf leak, Here to fix it by only holding the sk when auth shkey is created successfully. Fixes: a29a5bd4f5c3 ("[SCTP]: Implement SCTP-AUTH initializations.") Reported-by: syzbot+afabda3890cc2f765041@syzkaller.appspotmail.com Reported-by: syzbot+276ca1c77a19977c0130@syzkaller.appspotmail.com Signed-off-by: Xin Long <lucien.xin@gmail.com> Acked-by: Neil Horman <nhorman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'net')
-rw-r--r--net/sctp/endpointola.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 9da76ba4d10f..3550f0784306 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -126,10 +126,6 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
/* Initialize the bind addr area */
sctp_bind_addr_init(&ep->base.bind_addr, 0);
- /* Remember who we are attached to. */
- ep->base.sk = sk;
- sock_hold(ep->base.sk);
-
/* Create the lists of associations. */
INIT_LIST_HEAD(&ep->asocs);
@@ -165,6 +161,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
ep->auth_hmacs_list = auth_hmacs;
ep->auth_chunk_list = auth_chunks;
+ /* Remember who we are attached to. */
+ ep->base.sk = sk;
+ sock_hold(ep->base.sk);
+
return ep;
nomem_hmacs: