]> Git Repo - linux.git/commitdiff
net/af_packet: check len when min_header_len equals to 0
authorZhengchao Shao <[email protected]>
Wed, 27 Jul 2022 09:33:12 +0000 (17:33 +0800)
committerDavid S. Miller <[email protected]>
Fri, 29 Jul 2022 11:09:27 +0000 (12:09 +0100)
User can use AF_PACKET socket to send packets with the length of 0.
When min_header_len equals to 0, packet_snd will call __dev_queue_xmit
to send packets, and sock->type can be any type.

Reported-by: [email protected]
Fixes: fd1894224407 ("bpf: Don't redirect packets with invalid pkt_len")
Signed-off-by: Zhengchao Shao <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/packet/af_packet.c

index d08c4728523b5f853be6d57b73e4033326d7ba65..5cbe07116e04e68251de863307e7194b9e07a789 100644 (file)
@@ -3037,8 +3037,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
        if (err)
                goto out_free;
 
-       if (sock->type == SOCK_RAW &&
-           !dev_validate_header(dev, skb->data, len)) {
+       if ((sock->type == SOCK_RAW &&
+            !dev_validate_header(dev, skb->data, len)) || !skb->len) {
                err = -EINVAL;
                goto out_free;
        }
This page took 0.059157 seconds and 4 git commands to generate.