All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Alva Lan <alvalan9@foxmail.com>, Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 6.1.y] bpf, sockmap: Fix race between element replace and close()
Date: Thu,  9 Jan 2025 09:44:25 -0500	[thread overview]
Message-ID: <20250109092342-e7b05470e6eae637@stable.kernel.org> (raw)
In-Reply-To: <tencent_B2D63C382230E90D77B40E353B1F6F92AB08@qq.com>

[ Sasha's backport helper bot ]

Hi,

The upstream commit SHA1 provided is correct: ed1fc5d76b81a4d681211333c026202cad4d5649

WARNING: Author mismatch between patch and upstream commit:
Backport author: Alva Lan<alvalan9@foxmail.com>
Commit author: Michal Luczaj<mhal@rbox.co>


Status in newer kernel trees:
6.12.y | Present (different SHA1: bf2318e288f6)
6.6.y | Present (different SHA1: b015f19fedd2)
6.1.y | Present (different SHA1: b543d4a4153f)

Note: The patch differs from the upstream commit:
---
1:  ed1fc5d76b81 ! 1:  559c7465df3b bpf, sockmap: Fix race between element replace and close()
    @@ Metadata
      ## Commit message ##
         bpf, sockmap: Fix race between element replace and close()
     
    +    [ Upstream commit ed1fc5d76b81a4d681211333c026202cad4d5649 ]
    +
         Element replace (with a socket different from the one stored) may race
         with socket's close() link popping & unlinking. __sock_map_delete()
         unconditionally unrefs the (wrong) element:
    @@ Commit message
         Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
         Reviewed-by: John Fastabend <john.fastabend@gmail.com>
         Link: https://lore.kernel.org/bpf/20241202-sockmap-replace-v1-3-1e88579e7bd5@rbox.co
    +    Signed-off-by: Alva Lan <alvalan9@foxmail.com>
     
      ## net/core/sock_map.c ##
     @@ net/core/sock_map.c: static void *sock_map_lookup_sys(struct bpf_map *map, void *key)
    @@ net/core/sock_map.c: static void *sock_map_lookup_sys(struct bpf_map *map, void
     +	struct sock *sk = NULL;
      	int err = 0;
      
    - 	spin_lock_bh(&stab->lock);
    + 	if (irqs_disabled())
    + 		return -EOPNOTSUPP; /* locks here are hardirq-unsafe */
    + 
    + 	raw_spin_lock_bh(&stab->lock);
     -	sk = *psk;
     -	if (!sk_test || sk_test == sk)
    ++
     +	if (!sk_test || sk_test == *psk)
      		sk = xchg(psk, NULL);
      
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.1.y        |  Success    |  Success   |

      reply	other threads:[~2025-01-09 14:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 12:08 [PATCH 6.1.y] bpf, sockmap: Fix race between element replace and close() Alva Lan
2025-01-09 14:44 ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250109092342-e7b05470e6eae637@stable.kernel.org \
    --to=sashal@kernel.org \
    --cc=alvalan9@foxmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.