Skip to content

Commit ec6af09

Browse files
wdebruijkuba-moo
authored andcommitted
net/packet: rx_owner_map depends on pg_vec
Packet sockets may switch ring versions. Avoid misinterpreting state between versions, whose fields share a union. rx_owner_map is only allocated with a packet ring (pg_vec) and both are swapped together. If pg_vec is NULL, meaning no packet ring was allocated, then neither was rx_owner_map. And the field may be old state from a tpacket_v3. Fixes: 61fad68 ("net/packet: tpacket_rcv: avoid a producer race condition") Reported-by: Syzbot <syzbot+1ac0994a0a0c55151121@syzkaller.appspotmail.com> Signed-off-by: Willem de Bruijn <willemb@google.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/r/20211215143937.106178-1-willemdebruijn.kernel@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4812217 commit ec6af09

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎net/packet/af_packet.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4492,9 +4492,10 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
44924492
}
44934493

44944494
out_free_pg_vec:
4495-
bitmap_free(rx_owner_map);
4496-
if (pg_vec)
4495+
if (pg_vec) {
4496+
bitmap_free(rx_owner_map);
44974497
free_pg_vec(pg_vec, order, req->tp_block_nr);
4498+
}
44984499
out:
44994500
return err;
45004501
}

0 commit comments

Comments
 (0)