]> git.hungrycats.org Git - linux/commitdiff
fixup: sctp: verify size of a new chunk in _sctp_make_chunk()
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Mar 2018 09:56:00 +0000 (10:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 18 Mar 2018 10:15:45 +0000 (11:15 +0100)
Ben writes:
> > + int chunklen;
> > +
> > + chunklen = sizeof(*chunk_hdr) + paylen;
>
> I think this length still needs to be rounded up (with WORD_ROUND here,
> instead of SCTP_PAD4 upstream).

So here's a fix for this problem.

Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sctp/sm_make_chunk.c

index 6d48cbf6465d0014bccb6e8c1ee2b3438ac94089..bbf6abb6ae3c39e40494cec59dc201ca61cd932d 100644 (file)
@@ -1369,7 +1369,7 @@ static struct sctp_chunk *_sctp_make_chunk(const struct sctp_association *asoc,
        struct sock *sk;
        int chunklen;
 
-       chunklen = sizeof(*chunk_hdr) + paylen;
+       chunklen = WORD_ROUND(sizeof(*chunk_hdr) + paylen);
        if (chunklen > SCTP_MAX_CHUNK_LEN)
                goto nodata;