]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net-timestamp: make sk_tskey more predictable in error path
authorVadim Fedorenko <vadfed@meta.com>
Tue, 13 Feb 2024 11:04:28 +0000 (03:04 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 15 Feb 2024 11:04:04 +0000 (12:04 +0100)
commit488b6d91b07112eaaaa4454332c1480894d4e06e
tree3dc7052af956c4df9e8de2353d41061a11c8d619
parent2ec197fda25f57afccac7f2846e509471488614c
net-timestamp: make sk_tskey more predictable in error path

When SOF_TIMESTAMPING_OPT_ID is used to ambiguate timestamped datagrams,
the sk_tskey can become unpredictable in case of any error happened
during sendmsg(). Move increment later in the code and make decrement of
sk_tskey in error path. This solution is still racy in case of multiple
threads doing snedmsg() over the very same socket in parallel, but still
makes error path much more predictable.

Fixes: 09c2d251b707 ("net-timestamp: add key to disambiguate concurrent datagrams")
Reported-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20240213110428.1681540-1-vadfed@meta.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/ipv4/ip_output.c
net/ipv6/ip6_output.c