]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: skmsg: preserve sg.copy across SG transforms
authorYiming Qian <yimingqian591@gmail.com>
Wed, 10 Jun 2026 06:21:36 +0000 (06:21 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 16 Jun 2026 21:38:46 +0000 (14:38 -0700)
commit406e8a651a7b854c41fecd5117bb282b3a6c2c6b
treeb25425c04472319cfc09792524d3b6c18852801c
parentfbc6a80cb5d3fd4ac4b56e8c9d791dd17be890c4
net: skmsg: preserve sg.copy across SG transforms

The sk_msg sg.copy bitmap is part of the scatterlist entry ownership
state. A set bit tells sk_msg_compute_data_pointers() not to expose the
entry through writable BPF ctx->data. This protects entries backed by
pages that are not private to the sk_msg, such as splice-backed file
page-cache pages.

Several sk_msg transform paths move, copy, split, or compact
msg->sg.data[] entries without moving the matching sg.copy bit. This can
make an externally backed entry arrive at a new slot with a clear copy
bit. A later SK_MSG verdict can then expose sg_virt(sge) as writable
ctx->data and BPF stores can modify the original page cache.

Keep sg.copy synchronized with sg.data[] whenever entries are
transferred, shifted, split, or copied into a new sk_msg. Clear the bit
when an entry is replaced by a newly allocated private page or freed.
This covers the BPF pull/push/pop helpers, sk_msg_shift_left/right(),
sk_msg_xfer(), and tls_split_open_record(), including the partial tail
entry created during TLS open-record splitting.

Fixes: d3b18ad31f93 ("tls: add bpf support to sk_msg handling")
Cc: stable@vger.kernel.org
Reported-by: Yiming Qian <yimingqian591@gmail.com>
Reported-by: Keenan Dong <keenanat2000@gmail.com>
Signed-off-by: Yiming Qian <yimingqian591@gmail.com>
Link: https://patch.msgid.link/20260610062137.49075-1-yimingqian591@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/skmsg.h
net/core/filter.c
net/core/skmsg.c
net/tls/tls_sw.c