lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <SJ0PR18MB5216960DD7420BBBAFA6B238DBB8A@SJ0PR18MB5216.namprd18.prod.outlook.com> Date: Fri, 24 Nov 2023 02:12:53 +0000 From: Suman Ghosh <sumang@...vell.com> To: Mike Pattrick <mkp@...hat.com>, "netdev@...r.kernel.org" <netdev@...r.kernel.org> CC: "willemdebruijn.kernel@...il.com" <willemdebruijn.kernel@...il.com>, "davem@...emloft.net" <davem@...emloft.net>, "edumazet@...gle.com" <edumazet@...gle.com>, "kuba@...nel.org" <kuba@...nel.org>, "pabeni@...hat.com" <pabeni@...hat.com>, "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org> Subject: RE: [EXT] [PATCH net-next] packet: Account for VLAN_HLEN in csum_start when virtio_net_hdr is enabled > static int packet_rcv_vnet(struct msghdr *msg, const struct sk_buff >*skb, >- size_t *len, int vnet_hdr_sz) >+ size_t *len, int vnet_hdr_sz, >+ const struct sock *sk) > { > struct virtio_net_hdr_mrg_rxbuf vnet_hdr = { .num_buffers = 0 }; >+ int vlan_hlen; > > if (*len < vnet_hdr_sz) > return -EINVAL; > *len -= vnet_hdr_sz; > >- if (virtio_net_hdr_from_skb(skb, (struct virtio_net_hdr >*)&vnet_hdr, vio_le(), true, 0)) >+ if (sk->sk_type == SOCK_RAW && skb_vlan_tag_present(skb)) >+ vlan_hlen = VLAN_HLEN; >+ else >+ vlan_hlen = 0; [Suman] A minor nit. You can initialize vlan_hdr = 0 and get rid of the else. >+ >+ if (virtio_net_hdr_from_skb(skb, (struct virtio_net_hdr >*)&vnet_hdr, >+ vio_le(), true, vlan_hlen)) > return -EINVAL; > > return memcpy_to_msg(msg, (void *)&vnet_hdr, vnet_hdr_sz); @@ - >2368,13 +2376,21 @@ static int tpacket_rcv(struct sk_buff *skb, struct >net_device *dev, > __set_bit(slot_id, po->rx_ring.rx_owner_map); > } > >- if (vnet_hdr_sz && >- virtio_net_hdr_from_skb(skb, h.raw + macoff - >- sizeof(struct virtio_net_hdr), >- vio_le(), true, 0)) { >- if (po->tp_version == TPACKET_V3) >- prb_clear_blk_fill_status(&po->rx_ring); >- goto drop_n_account; >+ if (vnet_hdr_sz) { >+ int vlan_hlen; >+ >+ if (sk->sk_type == SOCK_RAW && skb_vlan_tag_present(skb)) >+ vlan_hlen = VLAN_HLEN; >+ else >+ vlan_hlen = 0; [Suman] Same as previous comment. >+ >+ if (virtio_net_hdr_from_skb(skb, h.raw + macoff - >+ sizeof(struct virtio_net_hdr), >+ vio_le(), true, vlan_hlen)) { >+ if (po->tp_version == TPACKET_V3) >+ prb_clear_blk_fill_status(&po->rx_ring); >+ goto drop_n_account; >+ } > } > > if (po->tp_version <= TPACKET_V2) { >@@ -3464,7 +3480,7 @@ static int packet_recvmsg(struct socket *sock, >struct msghdr *msg, size_t len, > packet_rcv_try_clear_pressure(pkt_sk(sk)); > > if (vnet_hdr_len) { >- err = packet_rcv_vnet(msg, skb, &len, vnet_hdr_len); >+ err = packet_rcv_vnet(msg, skb, &len, vnet_hdr_len, sk); > if (err) > goto out_free; > } >-- >2.40.1 >
Powered by blists - more mailing lists