Skip to content

Commit

Permalink
sctp: fix panic when sending auth chunks
Browse files Browse the repository at this point in the history
When we introduced GSO support, if using auth the auth chunk was being
left queued on the packet even after the final segment was generated.
Later on sctp_transmit_packet it calls sctp_packet_reset, which zeroed
the packet len while not accounting for this left-over. This caused more
space to be used the next packet due to the chunk still being queued,
but space which wasn't allocated as its size wasn't accounted.

The fix is to only queue it back when we know that we are going to
generate another segment.

Fixes: 90017ac ("sctp: Add GSO support")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Marcelo Ricardo Leitner authored and David S. Miller committed Jul 9, 2016
1 parent 09a7636 commit f1533cc
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions net/sctp/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,7 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
*/
pkt_size -= WORD_ROUND(chunk->skb->len);

if (chunk == packet->auth && !list_empty(&packet->chunk_list))
list_add(&chunk->list, &packet->chunk_list);
else if (!sctp_chunk_is_data(chunk))
if (!sctp_chunk_is_data(chunk) && chunk != packet->auth)
sctp_chunk_free(chunk);

if (!pkt_size)
Expand All @@ -605,6 +603,18 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
(struct sctp_auth_chunk *)auth,
gfp);

if (packet->auth) {
if (!list_empty(&packet->chunk_list)) {
/* We will generate more packets, so re-queue
* auth chunk.
*/
list_add(&chunk->list, &packet->chunk_list);
} else {
sctp_chunk_free(packet->auth);
packet->auth = NULL;
}
}

if (!gso)
break;

Expand Down Expand Up @@ -735,6 +745,8 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
}
goto out;
nomem:
if (packet->auth && list_empty(&packet->auth->list))
sctp_chunk_free(packet->auth);
err = -ENOMEM;
goto err;
}
Expand Down

0 comments on commit f1533cc

Please sign in to comment.