]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sctp: hold the chunks only after the chunk is enqueued in outq
authorlucien <lucien.xin@gmail.com>
Sat, 5 Dec 2015 07:15:17 +0000 (15:15 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 6 Dec 2015 18:25:12 +0000 (13:25 -0500)
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>
net/sctp/outqueue.c
net/sctp/socket.c

index 7e8f0a117106cabbf043e24e33f56b307cf4fc88..0b3d8189f140e093d7b08198dbf507a0537e9fe8 100644 (file)
@@ -324,6 +324,7 @@ int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk)
                                 sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)) :
                                 "illegal chunk");
 
+                       sctp_chunk_hold(chunk);
                        sctp_outq_tail_data(q, chunk);
                        if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED)
                                SCTP_INC_STATS(net, SCTP_MIB_OUTUNORDERCHUNKS);
index 1a32ecdb8bae98de2e76591f0f5ffee1441ff04d..bd57300c8e91ce88e140677312fda200296c2e3c 100644 (file)
@@ -1952,8 +1952,6 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
 
        /* Now send the (possibly) fragmented message. */
        list_for_each_entry(chunk, &datamsg->chunks, frag_list) {
-               sctp_chunk_hold(chunk);
-
                /* Do accounting for the write space.  */
                sctp_set_owner_w(chunk);