]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net/hamradio/6pack: Fix the size of a sk_buff used in 'sp_bump()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 26 Aug 2019 19:02:09 +0000 (21:02 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 7 Sep 2019 13:46:28 +0000 (15:46 +0200)
We 'allocate' 'count' bytes here. In fact, 'dev_alloc_skb' already add some
extra space for padding, so a bit more is allocated.

However, we use 1 byte for the KISS command, then copy 'count' bytes, so
count+1 bytes.

Explicitly allocate and use 1 more byte to be safe.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hamradio/6pack.c

index 331c16d30d5df02d1a00bca2c4871362e5dbfeb6..23281aeeb2226ee4dc9d7655aebc247c94c94def 100644 (file)
@@ -344,10 +344,10 @@ static void sp_bump(struct sixpack *sp, char cmd)
 
        sp->dev->stats.rx_bytes += count;
 
-       if ((skb = dev_alloc_skb(count)) == NULL)
+       if ((skb = dev_alloc_skb(count + 1)) == NULL)
                goto out_mem;
 
-       ptr = skb_put(skb, count);
+       ptr = skb_put(skb, count + 1);
        *ptr++ = cmd;   /* KISS command */
 
        memcpy(ptr, sp->cooked_buf + 1, count);