]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
af_packet: fix the SO_SNDTIMEO constraint not effective on tpacked_snd()
authorYun Lu <luyun@kylinos.cn>
Fri, 11 Jul 2025 09:32:59 +0000 (17:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Jul 2025 06:53:13 +0000 (08:53 +0200)
commit67ea5f37b203c7bce841ff11b6f9f06c04c12dc5
tree06ca2122bc150a0e622e5ce670c12222c283d7c0
parente51cf5d4aa9844b37a38f9a888a7f4c3c9fa3b09
af_packet: fix the SO_SNDTIMEO constraint not effective on tpacked_snd()

commit c1ba3c0cbdb5e53a8ec5d708e99cd4c497028a13 upstream.

Due to the changes in commit 581073f626e3 ("af_packet: do not call
packet_read_pending() from tpacket_destruct_skb()"), every time
tpacket_destruct_skb() is executed, the skb_completion is marked as
completed. When wait_for_completion_interruptible_timeout() returns
completed, the pending_refcnt has not yet been reduced to zero.
Therefore, when ph is NULL, the wait function may need to be called
multiple times until packet_read_pending() finally returns zero.

We should call sock_sndtimeo() only once, otherwise the SO_SNDTIMEO
constraint could be way off.

Fixes: 581073f626e3 ("af_packet: do not call packet_read_pending() from tpacket_destruct_skb()")
Cc: stable@kernel.org
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Yun Lu <luyun@kylinos.cn>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/packet/af_packet.c