Skip to content

Commit 97f5457

Browse files
dcarattigregkh
authored andcommitted
sctp: fix ICMP processing if skb is non-linear
[ Upstream commit 804ec7ebe8ea003999ca8d1bfc499edc6a9e07df ] sometimes ICMP replies to INIT chunks are ignored by the client, even if the encapsulated SCTP headers match an open socket. This happens when the ICMP packet is carried by a paged skb: use skb_header_pointer() to read packet contents beyond the SCTP header, so that chunk header and initiate tag are validated correctly. v2: - don't use skb_header_pointer() to read the transport header, since icmp_socket_deliver() already puts these 8 bytes in the linear area. - change commit message to make specific reference to INIT chunks. Signed-off-by: Davide Caratti <dcaratti@redhat.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Acked-by: Vlad Yasevich <vyasevich@gmail.com> Reviewed-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fe22b60 commit 97f5457

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

net/sctp/input.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,14 @@ struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb,
472472
struct sctp_association **app,
473473
struct sctp_transport **tpp)
474474
{
475+
struct sctp_init_chunk *chunkhdr, _chunkhdr;
475476
union sctp_addr saddr;
476477
union sctp_addr daddr;
477478
struct sctp_af *af;
478479
struct sock *sk = NULL;
479480
struct sctp_association *asoc;
480481
struct sctp_transport *transport = NULL;
481-
struct sctp_init_chunk *chunkhdr;
482482
__u32 vtag = ntohl(sctphdr->vtag);
483-
int len = skb->len - ((void *)sctphdr - (void *)skb->data);
484483

485484
*app = NULL; *tpp = NULL;
486485

@@ -515,13 +514,16 @@ struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb,
515514
* discard the packet.
516515
*/
517516
if (vtag == 0) {
518-
chunkhdr = (void *)sctphdr + sizeof(struct sctphdr);
519-
if (len < sizeof(struct sctphdr) + sizeof(sctp_chunkhdr_t)
520-
+ sizeof(__be32) ||
517+
/* chunk header + first 4 octects of init header */
518+
chunkhdr = skb_header_pointer(skb, skb_transport_offset(skb) +
519+
sizeof(struct sctphdr),
520+
sizeof(struct sctp_chunkhdr) +
521+
sizeof(__be32), &_chunkhdr);
522+
if (!chunkhdr ||
521523
chunkhdr->chunk_hdr.type != SCTP_CID_INIT ||
522-
ntohl(chunkhdr->init_hdr.init_tag) != asoc->c.my_vtag) {
524+
ntohl(chunkhdr->init_hdr.init_tag) != asoc->c.my_vtag)
523525
goto out;
524-
}
526+
525527
} else if (vtag != asoc->c.peer_vtag) {
526528
goto out;
527529
}

0 commit comments

Comments
 (0)