Skip to content

Commit 25bff6d

Browse files
lxindavem330
authored andcommitted
sctp: change to hold sk after auth shkey is created successfully
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: a29a5bd ("[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>
1 parent 1369653 commit 25bff6d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/sctp/endpointola.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
118118
/* Initialize the bind addr area */
119119
sctp_bind_addr_init(&ep->base.bind_addr, 0);
120120

121-
/* Remember who we are attached to. */
122-
ep->base.sk = sk;
123-
sock_hold(ep->base.sk);
124-
125121
/* Create the lists of associations. */
126122
INIT_LIST_HEAD(&ep->asocs);
127123

@@ -154,6 +150,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
154150
ep->prsctp_enable = net->sctp.prsctp_enable;
155151
ep->reconf_enable = net->sctp.reconf_enable;
156152

153+
/* Remember who we are attached to. */
154+
ep->base.sk = sk;
155+
sock_hold(ep->base.sk);
156+
157157
return ep;
158158

159159
nomem_shkey:

0 commit comments

Comments
 (0)