aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp
diff options
context:
space:
mode:
authorlucien <lucien.xin@gmail.com>2015-12-05 02:15:17 -0500
committerDavid S. Miller <davem@davemloft.net>2015-12-06 13:25:12 -0500
commit69b5777f2e5779bb987d4a25a33401d5ac257c14 (patch)
tree1333f49fe1b4d26f42c0d398a8f548314b81b1b8 /net/sctp
parented7d42e24effbd3681e909711a7a2119a85e9217 (diff)
sctp: hold the chunks only after the chunk is enqueued in outq
When a msg is sent, sctp will hold the chunks of this msg and then try to enqueue them. But if the chunks are not enqueued in sctp_outq_tail() because of the invalid state, sctp_cmd_interpreter() may still return success to sctp_sendmsg() after calling sctp_outq_flush(), these chunks will become orphans and will leak. So we fix them by moving sctp_chunk_hold() to sctp_outq_tail(), where we are sure that the chunk is going to get queued. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r--net/sctp/outqueue.c1
-rw-r--r--net/sctp/socket.c2
2 files changed, 1 insertions, 2 deletions
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 7e8f0a117106..0b3d8189f140 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -324,6 +324,7 @@ int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk)
324 sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)) : 324 sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)) :
325 "illegal chunk"); 325 "illegal chunk");
326 326
327 sctp_chunk_hold(chunk);
327 sctp_outq_tail_data(q, chunk); 328 sctp_outq_tail_data(q, chunk);
328 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) 329 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED)
329 SCTP_INC_STATS(net, SCTP_MIB_OUTUNORDERCHUNKS); 330 SCTP_INC_STATS(net, SCTP_MIB_OUTUNORDERCHUNKS);
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 1a32ecdb8bae..bd57300c8e91 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1952,8 +1952,6 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
1952 1952
1953 /* Now send the (possibly) fragmented message. */ 1953 /* Now send the (possibly) fragmented message. */
1954 list_for_each_entry(chunk, &datamsg->chunks, frag_list) { 1954 list_for_each_entry(chunk, &datamsg->chunks, frag_list) {
1955 sctp_chunk_hold(chunk);
1956
1957 /* Do accounting for the write space. */ 1955 /* Do accounting for the write space. */
1958 sctp_set_owner_w(chunk); 1956 sctp_set_owner_w(chunk);
1959 1957