<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/net/packet/internal.h, branch linux-6.15.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.15.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.15.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-06-19T13:40:01Z</updated>
<entry>
<title>af_packet: move notifier's packet_dev_mc out of rcu critical section</title>
<updated>2025-06-19T13:40:01Z</updated>
<author>
<name>Stanislav Fomichev</name>
</author>
<published>2025-05-22T03:11:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2dd4781c5af99415ebbd2f7cc763feb109863c05'/>
<id>urn:sha1:2dd4781c5af99415ebbd2f7cc763feb109863c05</id>
<content type='text'>
[ Upstream commit d8d85ef0a631df9127f202e6371bb33a0b589952 ]

Syzkaller reports the following issue:

 BUG: sleeping function called from invalid context at kernel/locking/mutex.c:578
 __mutex_lock+0x106/0xe80 kernel/locking/mutex.c:746
 team_change_rx_flags+0x38/0x220 drivers/net/team/team_core.c:1781
 dev_change_rx_flags net/core/dev.c:9145 [inline]
 __dev_set_promiscuity+0x3f8/0x590 net/core/dev.c:9189
 netif_set_promiscuity+0x50/0xe0 net/core/dev.c:9201
 dev_set_promiscuity+0x126/0x260 net/core/dev_api.c:286 packet_dev_mc net/packet/af_packet.c:3698 [inline]
 packet_dev_mclist_delete net/packet/af_packet.c:3722 [inline]
 packet_notifier+0x292/0xa60 net/packet/af_packet.c:4247
 notifier_call_chain+0x1b3/0x3e0 kernel/notifier.c:85
 call_netdevice_notifiers_extack net/core/dev.c:2214 [inline]
 call_netdevice_notifiers net/core/dev.c:2228 [inline]
 unregister_netdevice_many_notify+0x15d8/0x2330 net/core/dev.c:11972
 rtnl_delete_link net/core/rtnetlink.c:3522 [inline]
 rtnl_dellink+0x488/0x710 net/core/rtnetlink.c:3564
 rtnetlink_rcv_msg+0x7cf/0xb70 net/core/rtnetlink.c:6955
 netlink_rcv_skb+0x219/0x490 net/netlink/af_netlink.c:2534

Calling `PACKET_ADD_MEMBERSHIP` on an ops-locked device can trigger
the `NETDEV_UNREGISTER` notifier, which may require disabling promiscuous
and/or allmulti mode. Both of these operations require acquiring
the netdev instance lock.

Move the call to `packet_dev_mc` outside of the RCU critical section.
The `mclist` modifications (add, del, flush, unregister) are protected by
the RTNL, not the RCU. The RCU only protects the `sklist` and its
associated `sks`. The delayed operation on the `mclist` entry remains
within the RTNL.

Reported-by: syzbot+b191b5ccad8d7a986286@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b191b5ccad8d7a986286
Fixes: ad7c7b2172c3 ("net: hold netdev instance lock during sysfs operations")
Signed-off-by: Stanislav Fomichev &lt;stfomichev@gmail.com&gt;
Reviewed-by: Willem de Bruijn &lt;willemb@google.com&gt;
Link: https://patch.msgid.link/20250522031129.3247266-1-stfomichev@gmail.com
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>packet: Move reference count in packet_sock to atomic_long_t</title>
<updated>2023-12-04T22:45:04Z</updated>
<author>
<name>Daniel Borkmann</name>
</author>
<published>2023-12-01T13:10:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=db3fadacaf0c817b222090290d06ca2a338422d0'/>
<id>urn:sha1:db3fadacaf0c817b222090290d06ca2a338422d0</id>
<content type='text'>
In some potential instances the reference count on struct packet_sock
could be saturated and cause overflows which gets the kernel a bit
confused. To prevent this, move to a 64-bit atomic reference count on
64-bit architectures to prevent the possibility of this type to overflow.

Because we can not handle saturation, using refcount_t is not possible
in this place. Maybe someday in the future if it changes it could be
used. Also, instead of using plain atomic64_t, use atomic_long_t instead.
32-bit machines tend to be memory-limited (i.e. anything that increases
a reference uses so much memory that you can't actually get to 2**32
references). 32-bit architectures also tend to have serious problems
with 64-bit atomics. Hence, atomic_long_t is the more natural solution.

Reported-by: "The UK's National Cyber Security Centre (NCSC)" &lt;security@ncsc.gov.uk&gt;
Co-developed-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: stable@kernel.org
Reviewed-by: Willem de Bruijn &lt;willemb@google.com&gt;
Reviewed-by: Eric Dumazet &lt;edumazet@google.com&gt;
Link: https://lore.kernel.org/r/20231201131021.19999-1-daniel@iogearbox.net
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>net/packet: Annotate struct packet_fanout with __counted_by</title>
<updated>2023-10-06T10:36:25Z</updated>
<author>
<name>Kees Cook</name>
</author>
<published>2023-10-03T23:17:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b3783e5efde4201b2cc7a2fee41791b413137f4c'/>
<id>urn:sha1:b3783e5efde4201b2cc7a2fee41791b413137f4c</id>
<content type='text'>
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for
array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct packet_fanout.

Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: Eric Dumazet &lt;edumazet@google.com&gt;
Cc: Jakub Kicinski &lt;kuba@kernel.org&gt;
Cc: Paolo Abeni &lt;pabeni@redhat.com&gt;
Cc: Willem de Bruijn &lt;willemb@google.com&gt;
Cc: Anqi Shen &lt;amy.saq@antgroup.com&gt;
Cc: netdev@vger.kernel.org
Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1]
Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Reviewed-by: Gustavo A. R. Silva &lt;gustavoars@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/packet: support mergeable feature of virtio</title>
<updated>2023-04-21T11:01:58Z</updated>
<author>
<name>Jianfeng Tan</name>
</author>
<published>2023-04-19T07:24:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dfc39d4026fb2432363c0f77543c4cf3adca4c7b'/>
<id>urn:sha1:dfc39d4026fb2432363c0f77543c4cf3adca4c7b</id>
<content type='text'>
Packet sockets, like tap, can be used as the backend for kernel vhost.
In packet sockets, virtio net header size is currently hardcoded to be
the size of struct virtio_net_hdr, which is 10 bytes; however, it is not
always the case: some virtio features, such as mrg_rxbuf, need virtio
net header to be 12-byte long.

Mergeable buffers, as a virtio feature, is worthy of supporting: packets
that are larger than one-mbuf size will be dropped in vhost worker's
handle_rx if mrg_rxbuf feature is not used, but large packets
cannot be avoided and increasing mbuf's size is not economical.

With this virtio feature enabled by virtio-user, packet sockets with
hardcoded 10-byte virtio net header will parse mac head incorrectly in
packet_snd by taking the last two bytes of virtio net header as part of
mac header.
This incorrect mac header parsing will cause packet to be dropped due to
invalid ether head checking in later under-layer device packet receiving.

By adding extra field vnet_hdr_sz with utilizing holes in struct
packet_sock to record currently used virtio net header size and supporting
extra sockopt PACKET_VNET_HDR_SZ to set specified vnet_hdr_sz, packet
sockets can know the exact length of virtio net header that virtio user
gives.
In packet_snd, tpacket_snd and packet_recvmsg, instead of using
hardcoded virtio net header size, it can get the exact vnet_hdr_sz from
corresponding packet_sock, and parse mac header correctly based on this
information to avoid the packets being mistakenly dropped.

Signed-off-by: Jianfeng Tan &lt;henry.tjf@antgroup.com&gt;
Co-developed-by: Anqi Shen &lt;amy.saq@antgroup.com&gt;
Signed-off-by: Anqi Shen &lt;amy.saq@antgroup.com&gt;
Reviewed-by: Willem de Bruijn &lt;willemb@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/packet: remove po-&gt;xmit</title>
<updated>2023-03-19T10:57:54Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2023-03-17T16:20:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=105a201ebf3312990b96c4fbaade22e31402f8cc'/>
<id>urn:sha1:105a201ebf3312990b96c4fbaade22e31402f8cc</id>
<content type='text'>
Use PACKET_SOCK_QDISC_BYPASS atomic bit instead of a pointer.

This removes one indirect call in fast path,
and READ_ONCE()/WRITE_ONCE() annotations as well.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Suggested-by: Willem de Bruijn &lt;willemb@google.com&gt;
Cc: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Reviewed-by: Willem de Bruijn &lt;willemb@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>af_packet: preserve const qualifier in pkt_sk()</title>
<updated>2023-03-18T12:23:33Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2023-03-17T15:55:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=68ac9a8b6e65c7cbbe96541353dab1b3f8de2043'/>
<id>urn:sha1:68ac9a8b6e65c7cbbe96541353dab1b3f8de2043</id>
<content type='text'>
We can change pkt_sk() to propagate const qualifier of its argument,
thanks to container_of_const()

This should avoid some potential errors caused by accidental
(const -&gt; not_const) promotion.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Cc: Willem de Bruijn &lt;willemb@google.com&gt;
Reviewed-by: Simon Horman &lt;simon.horman@corigine.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/packet: convert po-&gt;pressure to an atomic flag</title>
<updated>2023-03-17T08:52:06Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2023-03-16T01:10:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=791a3e9f1a86fe8eb09173c9788493b8b5c957f4'/>
<id>urn:sha1:791a3e9f1a86fe8eb09173c9788493b8b5c957f4</id>
<content type='text'>
Not only this removes some READ_ONCE()/WRITE_ONCE(),
this also removes one integer.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/packet: convert po-&gt;running to an atomic flag</title>
<updated>2023-03-17T08:52:06Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2023-03-16T01:10:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=61edf479818e63978cabd243b82ca80f8948a313'/>
<id>urn:sha1:61edf479818e63978cabd243b82ca80f8948a313</id>
<content type='text'>
Instead of consuming 32 bits for po-&gt;running, use
one available bit in po-&gt;flags.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/packet: convert po-&gt;has_vnet_hdr to an atomic flag</title>
<updated>2023-03-17T08:52:05Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2023-03-16T01:10:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=50d935eafee292fc432d5ac8c8715a6492961abc'/>
<id>urn:sha1:50d935eafee292fc432d5ac8c8715a6492961abc</id>
<content type='text'>
po-&gt;has_vnet_hdr can be read locklessly.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/packet: convert po-&gt;tp_loss to an atomic flag</title>
<updated>2023-03-17T08:52:05Z</updated>
<author>
<name>Eric Dumazet</name>
</author>
<published>2023-03-16T01:10:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=164bddace2e03f6005e650cb88f101a66ebdc05a'/>
<id>urn:sha1:164bddace2e03f6005e650cb88f101a66ebdc05a</id>
<content type='text'>
tp_loss can be read locklessly.

Convert it to an atomic flag to avoid races.

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
