isdn/gigaset: limit raw CAPI message dump length
authorTilman Schmidt <tilman@imap.cc>
Sat, 11 Oct 2014 11:46:29 +0000 (13:46 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Oct 2014 19:05:33 +0000 (15:05 -0400)
In dump_rawmsg, the length field from a received data package was
used unscrutinized, allowing an attacker to control the size of the
allocated buffer and the number of times the output loop iterates.
Fix by limiting to a reasonable value.

Spotted with Coverity.

Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/isdn/gigaset/capi.c

index 044392cba262a7b0b871764d3ec7eff8bad7b3e5..47e2a913a6ef01e3d9ead723ce239a43e9d54e83 100644 (file)
@@ -250,6 +250,8 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag,
        l -= 12;
        if (l <= 0)
                return;
+       if (l > 64)
+               l = 64; /* arbitrary limit */
        dbgline = kmalloc(3 * l, GFP_ATOMIC);
        if (!dbgline)
                return;