Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Jason Xing <kerneljasonxing@gmail.com>, stable@vger.kernel.org
Cc: stable-commits@vger.kernel.org,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Eric Dumazet <edumazet@google.com>,
	Neal Cardwell <ncardwell@google.com>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>
Subject: Re: Patch "bpf: Prevent unsafe access to the sock fields in the BPF timestamping callback" has been added to the 6.1-stable tree
Date: Fri, 23 May 2025 16:17:21 -0700	[thread overview]
Message-ID: <69d1a996-5eaa-4af9-978d-c59c70a95438@linux.dev> (raw)
In-Reply-To: <CAL+tcoBEGozJ1Zs2c0L-kG=ZTVfPGXdshQxs7nCxwr-NhZoUPw@mail.gmail.com>

On 5/22/25 4:25 PM, Jason Xing wrote:
> On Fri, May 23, 2025 at 7:17 AM Sasha Levin <sashal@kernel.org> wrote:
>>
>> This is a note to let you know that I've just added the patch titled
>>
>>      bpf: Prevent unsafe access to the sock fields in the BPF timestamping callback
>>
>> to the 6.1-stable tree which can be found at:
>>      http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
>>
>> The filename of the patch is:
>>       bpf-prevent-unsafe-access-to-the-sock-fields-in-the-.patch
>> and it can be found in the queue-6.1 subdirectory.
>>
>> If you, or anyone else, feels it should not be added to the stable tree,
>> please let <stable@vger.kernel.org> know about it.
> 
> Hi,
> 
> I'm notified that this patch has been added into many branches, which
> is against my expectations. The BPF timestaping feature was
> implemented in 6.14 and the patch you are handling is just one of them.
> 
> The function of this patch prevents unexpected bpf programs using this
> feature from triggering
> fatal problems. So, IMHO, we don't need this patch in all the
> older/stable branches:)
> 
> Thanks,
> Jason
> 
> 
>>
>>
>>
>> commit 00b709040e0fdf5949dfbf02f38521e0b10943ac
>> Author: Jason Xing <kerneljasonxing@gmail.com>
>> Date:   Thu Feb 20 15:29:31 2025 +0800
>>
>>      bpf: Prevent unsafe access to the sock fields in the BPF timestamping callback
>>
>>      [ Upstream commit fd93eaffb3f977b23bc0a48d4c8616e654fcf133 ]
>>
>>      The subsequent patch will implement BPF TX timestamping. It will

Agree. The patch is a preparation work for the new bpf tx timestamping feature. 
It is not stable material.

Thanks,
Martin

>>      call the sockops BPF program without holding the sock lock.
>>
>>      This breaks the current assumption that all sock ops programs will
>>      hold the sock lock. The sock's fields of the uapi's bpf_sock_ops
>>      requires this assumption.
>>
>>      To address this, a new "u8 is_locked_tcp_sock;" field is added. This
>>      patch sets it in the current sock_ops callbacks. The "is_fullsock"
>>      test is then replaced by the "is_locked_tcp_sock" test during
>>      sock_ops_convert_ctx_access().
>>
>>      The new TX timestamping callbacks added in the subsequent patch will
>>      not have this set. This will prevent unsafe access from the new
>>      timestamping callbacks.
>>
>>      Potentially, we could allow read-only access. However, this would
>>      require identifying which callback is read-safe-only and also requires
>>      additional BPF instruction rewrites in the covert_ctx. Since the BPF
>>      program can always read everything from a socket (e.g., by using
>>      bpf_core_cast), this patch keeps it simple and disables all read
>>      and write access to any socket fields through the bpf_sock_ops
>>      UAPI from the new TX timestamping callback.
>>
>>      Moreover, note that some of the fields in bpf_sock_ops are specific
>>      to tcp_sock, and sock_ops currently only supports tcp_sock. In
>>      the future, UDP timestamping will be added, which will also break
>>      this assumption. The same idea used in this patch will be reused.
>>      Considering that the current sock_ops only supports tcp_sock, the
>>      variable is named is_locked_"tcp"_sock.
>>
>>      Signed-off-by: Jason Xing <kerneljasonxing@gmail.com>
>>      Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
>>      Link: https://patch.msgid.link/20250220072940.99994-4-kerneljasonxing@gmail.com
>>      Signed-off-by: Sasha Levin <sashal@kernel.org>

  reply	other threads:[~2025-05-23 23:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250522231656.3254864-1-sashal@kernel.org>
2025-05-22 23:25 ` Patch "bpf: Prevent unsafe access to the sock fields in the BPF timestamping callback" has been added to the 6.1-stable tree Jason Xing
2025-05-23 23:17   ` Martin KaFai Lau [this message]
2025-05-27 14:53     ` Greg KH

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=69d1a996-5eaa-4af9-978d-c59c70a95438@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@google.com \
    --cc=haoluo@google.com \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kerneljasonxing@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=ncardwell@google.com \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=stable-commits@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yonghong.song@linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox