net/packet: rx_owner_map depends on pg_vec

[ Upstream commit ec6af094ea28f0f2dda1a6a33b14cd57e36a9755 ]

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: 61fad6816fc1 ("net/packet: tpacket_rcv: avoid a producer race condition")
Reported-by: Syzbot <>
Signed-off-by: Willem de Bruijn <>
Reviewed-by: Eric Dumazet <>
Signed-off-by: Jakub Kicinski <>
Signed-off-by: Sasha Levin <>
(cherry picked from commit 027a13973dadb64ef4f19db56c9b619ee82c3375)
Signed-off-by: Robert Kolchmeyer <>

RELEASE_NOTE=Fixed a double-free issue in packet_set_ring in the Linux kernel.

cos-patch: bug
Change-Id: Ida77996f5bcbdf5441eb3bf8b15a9025809f2d35
Reviewed-by: Vaibhav Rustagi <>
Reviewed-by: Oleksandr Tymoshenko <>
Tested-by: Cusky Presubmit Bot <>
1 file changed