Skip to content

Commit 50ef0e2

Browse files
lxingregkh
authored andcommitted
sctp: sctp_addr_id2transport should verify the addr before looking up assoc
[ Upstream commit 6f29a130613191d3c6335169febe002cba00edf5 ] sctp_addr_id2transport is a function for sockopt to look up assoc by address. As the address is from userspace, it can be a v4-mapped v6 address. But in sctp protocol stack, it always handles a v4-mapped v6 address as a v4 address. So it's necessary to convert it to a v4 address before looking up assoc by address. This patch is to fix it by calling sctp_verify_addr in which it can do this conversion before calling sctp_endpoint_lookup_assoc, just like what sctp_sendmsg and __sctp_connect do for the address from users. Signed-off-by: Xin Long <lucien.xin@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7075262 commit 50ef0e2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

net/sctp/socket.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,12 @@ static struct sctp_transport *sctp_addr_id2transport(struct sock *sk,
235235
sctp_assoc_t id)
236236
{
237237
struct sctp_association *addr_asoc = NULL, *id_asoc = NULL;
238-
struct sctp_transport *transport;
238+
struct sctp_af *af = sctp_get_af_specific(addr->ss_family);
239239
union sctp_addr *laddr = (union sctp_addr *)addr;
240+
struct sctp_transport *transport;
241+
242+
if (sctp_verify_addr(sk, laddr, af->sockaddr_len))
243+
return NULL;
240244

241245
addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep,
242246
laddr,

0 commit comments

Comments
 (0)