linux-stable/net/sctp
Xin Long bc9a2f36a7 sctp: not bind the socket in sctp_connect
[ Upstream commit 9b6c08878e ]

Now when sctp_connect() is called with a wrong sa_family, it binds
to a port but doesn't set bp->port, then sctp_get_af_specific will
return NULL and sctp_connect() returns -EINVAL.

Then if sctp_bind() is called to bind to another port, the last
port it has bound will leak due to bp->port is NULL by then.

sctp_connect() doesn't need to bind ports, as later __sctp_connect
will do it if bp->port is NULL. So remove it from sctp_connect().
While at it, remove the unnecessary sockaddr.sa_family len check
as it's already done in sctp_inet_connect.

Fixes: 644fbdeacf ("sctp: fix the issue that flags are ignored when using kernel_connect")
Reported-by: syzbot+079bf326b38072f849d9@syzkaller.appspotmail.com
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-28 08:29:27 +02:00
..
associola.c sctp: update frag_point when stream_interleave is set 2018-12-17 09:24:28 +01:00
auth.c treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
bind_addr.c sctp: remove the typedef sctp_scope_t 2017-08-06 21:33:41 -07:00
chunk.c net/sctp: Make wrappers for accessing in/out streams 2018-08-11 12:25:15 -07:00
debug.c sctp: add SCTP_CID_I_DATA and SCTP_CID_I_FWD_TSN conversion in sctp_cname 2018-02-12 11:40:01 -05:00
diag.c inet_diag: fix reporting cgroup classid and fallback to priority 2019-02-27 10:08:58 +01:00
endpointola.c sctp: change to hold sk after auth shkey is created successfully 2019-07-03 13:14:47 +02:00
input.c sctp: use the pmtu from the icmp packet to update transport pathmtu 2018-10-15 22:54:20 -07:00
inqueue.c sctp: fix the issue that the cookie-ack with auth can't get processed 2018-05-02 11:15:33 -04:00
ipv6.c sctp: set flow sport from saddr only when it's 0 2019-02-06 17:30:10 +01:00
Kconfig sctp: whitespace fixes 2018-07-24 14:10:42 -07:00
Makefile sctp: rename sctp_diag.c as diag.c 2018-02-13 13:56:31 -05:00
objcnt.c proc: introduce proc_create_seq{,_data} 2018-05-16 07:23:35 +02:00
offload.c sctp: call gso_reset_checksum when computing checksum in sctp_gso_segment 2019-02-27 10:08:58 +01:00
output.c Revert "sctp: remove sctp_transport_pmtu_check" 2018-11-23 08:17:04 +01:00
outqueue.c sctp: define SCTP_SS_DEFAULT for Stream schedulers 2018-11-23 08:17:06 +01:00
primitive.c sctp: remove the typedef sctp_subtype_t 2017-08-06 21:33:42 -07:00
proc.c sctp: remove useless start_fail from sctp_ht_iter in proc 2018-08-27 15:13:17 -07:00
protocol.c sctp: initialize _pad of sockaddr_in before copying to user memory 2019-04-17 08:38:41 +02:00
sm_make_chunk.c sctp: Free cookie before we memdup a new one 2019-06-22 08:15:14 +02:00
sm_sideeffect.c Fix memory leak in sctp_process_init 2019-06-11 12:20:47 +02:00
sm_statefuns.c sctp: avoid running the sctp state machine recursively 2019-05-05 14:42:39 +02:00
sm_statetable.c sctp: implement validate_ftsn for sctp_stream_interleave 2017-12-15 13:52:22 -05:00
socket.c sctp: not bind the socket in sctp_connect 2019-07-28 08:29:27 +02:00
stream.c sctp: fix error handling on stream scheduler initialization 2019-07-28 08:29:25 +02:00
stream_interleave.c net/sctp: Make wrappers for accessing in/out streams 2018-08-11 12:25:15 -07:00
stream_sched.c net/sctp: Make wrappers for accessing in/out streams 2018-08-11 12:25:15 -07:00
stream_sched_prio.c net/sctp: Make wrappers for accessing in/out streams 2018-08-11 12:25:15 -07:00
stream_sched_rr.c net/sctp: Make wrappers for accessing in/out streams 2018-08-11 12:25:15 -07:00
sysctl.c sctp: support sysctl to allow users to use stream interleave 2017-12-15 13:52:22 -05:00
transport.c sctp: update dst pmtu with the correct daddr 2018-09-20 11:29:30 -07:00
tsnmap.c
ulpevent.c sctp: remove sctp_chunk_put from fail_mark err path in sctp_ulpevent_make_rcvmsg 2018-05-10 17:48:36 -04:00
ulpqueue.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-12-22 11:16:31 -05:00