]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: sctp: Fix negotiation of the number of data streams.
authorDavid Laight <David.Laight@ACULAB.COM>
Wed, 19 Aug 2020 14:40:52 +0000 (14:40 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Aug 2020 23:37:37 +0000 (16:37 -0700)
The number of output and input streams was never being reduced, eg when
processing received INIT or INIT_ACK chunks.
The effect is that DATA chunks can be sent with invalid stream ids
and then discarded by the remote system.

Fixes: 16800b3e4be46 ("sctp: convert to genradix")
Signed-off-by: David Laight <david.laight@aculab.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/stream.c

index bda2536dd740f7efe7b19dfc17cfc939bae38f1f..6dc95dcc0ff4f065014dbc376aa01b86eb9b2db0 100644 (file)
@@ -88,12 +88,13 @@ static int sctp_stream_alloc_out(struct sctp_stream *stream, __u16 outcnt,
        int ret;
 
        if (outcnt <= stream->outcnt)
-               return 0;
+               goto out;
 
        ret = genradix_prealloc(&stream->out, outcnt, gfp);
        if (ret)
                return ret;
 
+out:
        stream->outcnt = outcnt;
        return 0;
 }
@@ -104,12 +105,13 @@ static int sctp_stream_alloc_in(struct sctp_stream *stream, __u16 incnt,
        int ret;
 
        if (incnt <= stream->incnt)
-               return 0;
+               goto out;
 
        ret = genradix_prealloc(&stream->in, incnt, gfp);
        if (ret)
                return ret;
 
+out:
        stream->incnt = incnt;
        return 0;
 }