]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: netlink: catch attempts to send empty messages
authorJakub Kicinski <kuba@kernel.org>
Wed, 18 Dec 2024 02:44:00 +0000 (18:44 -0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 20 Dec 2024 02:06:28 +0000 (18:06 -0800)
syzbot can figure out a way to redirect a netlink message to a tap.
Sending empty skbs to devices is not valid and we end up hitting
a skb_assert_len() in __dev_queue_xmit().

Make catching these mistakes easier, assert the skb size directly
in netlink core.

Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20241218024400.824355-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/netlink/af_netlink.c

index f4e7b5e4bb59fd991ead7a33e4eae3bca0a82f97..85311226183a259574c64643eae9e906ccc9c1da 100644 (file)
@@ -1287,6 +1287,7 @@ static struct sk_buff *netlink_trim(struct sk_buff *skb, gfp_t allocation)
 {
        int delta;
 
+       skb_assert_len(skb);
        WARN_ON(skb->sk != NULL);
        delta = skb->end - skb->tail;
        if (is_vmalloc_addr(skb->head) || delta * 2 < skb->truesize)