Skip to content

Commit 5184635

Browse files
iAtsumuWatanabedavem330
authored andcommitted
packet: make aligned size of struct tpacket{2,3}_hdr clear
struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT. We may add members to them until current aligned size without forcing userspace to call getsockopt(..., PACKET_HDRLEN, ...). Signed-off-by: Atzm Watanabe <atzm@stratosphere.co.jp> Acked-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9f605ac commit 5184635

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎net/packet/af_packet.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,13 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
18121812
struct timespec ts;
18131813
__u32 ts_status;
18141814

1815+
/* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT.
1816+
* We may add members to them until current aligned size without forcing
1817+
* userspace to call getsockopt(..., PACKET_HDRLEN, ...).
1818+
*/
1819+
BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32);
1820+
BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48);
1821+
18151822
if (skb->pkt_type == PACKET_LOOPBACK)
18161823
goto drop;
18171824

0 commit comments

Comments
 (0)