-
Notifications
You must be signed in to change notification settings - Fork 12
[LTS 9.2] net: tls, update curr on splice as well #305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
jira VULN-6844 cve CVE-2024-0646 commit-author John Fastabend <[email protected]> commit c5a5950 upstream-diff used linux-stable LT-5.15 sha ba5efd8 commit c5a5950 upstream. The curr pointer must also be updated on the splice similar to how we do this for other copy types. Fixes: d829e9c ("tls: convert to generic sk_msg interface") Signed-off-by: John Fastabend <[email protected]> Reported-by: Jann Horn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit ba5efd8) Signed-off-by: Marcin Wcisło <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚤
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the deeper dive on the history.
If "try_verify_in_tasklet" is set for dm-verity, DM_BUFIO_CLIENT_NO_SLEEP is enabled for dm-bufio. However, when bufio tries to evict buffers, there is a chance to trigger scheduling in spin_lock_bh, the following warning is hit: BUG: sleeping function called from invalid context at drivers/md/dm-bufio.c:2745 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 123, name: kworker/2:2 preempt_count: 201, expected: 0 RCU nest depth: 0, expected: 0 4 locks held by kworker/2:2/123: #0: ffff88800a2d1548 ((wq_completion)dm_bufio_cache){....}-{0:0}, at: process_one_work+0xe46/0x1970 #1: ffffc90000d97d20 ((work_completion)(&dm_bufio_replacement_work)){....}-{0:0}, at: process_one_work+0x763/0x1970 #2: ffffffff8555b528 (dm_bufio_clients_lock){....}-{3:3}, at: do_global_cleanup+0x1ce/0x710 #3: ffff88801d5820b8 (&c->spinlock){....}-{2:2}, at: do_global_cleanup+0x2a5/0x710 Preemption disabled at: [<0000000000000000>] 0x0 CPU: 2 UID: 0 PID: 123 Comm: kworker/2:2 Not tainted 6.16.0-rc3-g90548c634bd0 #305 PREEMPT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 Workqueue: dm_bufio_cache do_global_cleanup Call Trace: <TASK> dump_stack_lvl+0x53/0x70 __might_resched+0x360/0x4e0 do_global_cleanup+0x2f5/0x710 process_one_work+0x7db/0x1970 worker_thread+0x518/0xea0 kthread+0x359/0x690 ret_from_fork+0xf3/0x1b0 ret_from_fork_asm+0x1a/0x30 </TASK> That can be reproduced by: veritysetup format --data-block-size=4096 --hash-block-size=4096 /dev/vda /dev/vdb SIZE=$(blockdev --getsz /dev/vda) dmsetup create myverity -r --table "0 $SIZE verity 1 /dev/vda /dev/vdb 4096 4096 <data_blocks> 1 sha256 <root_hash> <salt> 1 try_verify_in_tasklet" mount /dev/dm-0 /mnt -o ro echo 102400 > /sys/module/dm_bufio/parameters/max_cache_size_bytes [read files in /mnt] Cc: [email protected] # v6.4+ Fixes: 450e8de ("dm bufio: improve concurrent IO performance") Signed-off-by: Wang Shuai <[email protected]> Signed-off-by: Sheng Yong <[email protected]> Signed-off-by: Mikulas Patocka <[email protected]>
[LTS 9.2]
CVE-2024-0646
VULN-6844
Problem
https://www.cve.org/CVERecord?id=CVE-2024-0646
Background
"Splicing" is a method
https://github.com/torvalds/linux/blob/master/Documentation/filesystems/splice.rst
Applicability
The
tls
module is enabled inciqlts9_2
for all configuration variantsAlthough the mere
tls
enablement may not be sufficient condition to definitively say that the bug applies, the similarity between thenet/tls/tls_sw.c
file's history to that of LTS 9.4 and Linux stable 5.15 where the patch was backported strongly suggests that it does. See analysis below.Analysis and solution
The mainline fix is given in the c5a5950 commit. However, the commit's modification subject -
net/tls/tls_sw.c
- was undergoing heavy development in the upstream and the file differs substantially from theciqlts9_2
version. The git'scherry-pick
's automatic difference resolution is meaningless.The mainline fix boils down to adding these two lines in the procedure responsible for sending a spliced page:
In the mainline kernel the lines are added in the
tls_sw_sendmsg_splice
function, which is missing in theciqlts9_2
version.To span the bridge between mainline and
ciqlts9_2
consider the following timeline of thenet/tls/tls_sw.c
file modification in mainline Kernel. The commits are given from newest to oldest, asgit log
would order them by default. (For the bird's view of the file's history in the context of upstream and Rocky Kernels see Appendix.)Legend:
Commentary:
Commit fe1e81d introduced the - later fixed -
tls_sw_sendmsg_splice
function and hooked it totls_sw_sendmsg
. This provided the actual splicing functionality which was included as a phony two commits before.The
tls_sw_do_sendpage
function was later removed in 45e5be8. The large part oftls_sw_sendmsg
was factored out, along with thetls_sw_sendmsg_splice
's hook, to thetls_sw_sendmsg_locked
function. Thetls_sw_sendpage
which was using the removedtls_sw_do_sendpage
function was expressed usingtls_sw_sendmsg
, whiletls_sw_sendpage_locked
was expressed using the lower-leveltls_sw_sendmsg_locked
directly.Reverse call tree before:
Reverse call tree after:
Functions
tls_sw_sendpage
,tls_sw_sendpage_locked
were removed entirely a commit later (dc97391) marking the end of lasttls_sw_do_sendpage
's remnants in thetls_sw.c
code.The functions layout remained unchanged up to the bugfix in c5a5950.
Compare this with the
ciqlts9_2
history spanning the fix included in this PR and the preceding commit:The timeline given before explains the continuity between the
tls_sw_do_sendpage
and thetls_sw_sendmsg_splice
where the upstream fix was placed. The exact placing of themsg_pl->sg.copybreak
andmsg_pl->sg.curr
fields modification was dictated by thesk_msg_page_add
function call using themsg_pl
struct - the new lines are introduced right after it in both the mainline fix and in this patch, be it in thetls_sw_do_sendpage
ortls_sw_sendmsg_splice
function:The same place was picked for the CVE fix in LTS 9.4 in 8ad16a7 by RedHat as well as in the 5.15 stable backport in ba5efd8. In fact, this patch is a direct cherry pick of the ba5efd8 commit.
kABI check: passed
Boot test: passed
boot-test.log
Kselftests: passed relative
Coverage
bpf
(excepttest_sockmap
,test_progs-no_alu32
,test_progs
,test_kmod.sh
,test_xsk.sh
),breakpoints
,capabilities
,cgroup
(excepttest_freezer
,test_memcontrol
),clone3
,core
,cpu-hotplug
,cpufreq
,drivers/dma-buf
,drivers/net/bonding
,drivers/net/team
,filesystems/binderfs
,firmware
,fpu
,ftrace
,futex
,gpio
,intel_pstate
,ipc
,ir
,kcmp
,kexec
,kvm
,landlock
,lib
,livepatch
,membarrier
,memfd
,memory-hotplug
,mincore
,mount
,mqueue
,nci
,net/forwarding
(exceptsch_tbf_ets.sh
,q_in_vni.sh
,ipip_hier_gre_keys.sh
,dual_vxlan_bridge.sh
,tc_police.sh
,sch_ets.sh
,tc_actions.sh
,mirror_gre_vlan_bridge_1q.sh
,sch_red.sh
,vxlan_bridge_1d_ipv6.sh
,mirror_gre_bridge_1d_vlan.sh
,sch_tbf_root.sh
,sch_tbf_prio.sh
),net/mptcp
(exceptuserspace_pm.sh
,simult_flows.sh
),net
(exceptxfrm_policy.sh
,reuseport_addr_any.sh
,udpgso_bench.sh
,fib_nexthops.sh
,ip_defrag.sh
,udpgro_fwd.sh
,reuseaddr_conflict
,txtimestamp.sh
,gro.sh
),netfilter
(exceptnft_trans_stress.sh
),nsfs
,openat2
,pid_namespace
,pidfd
,proc
(exceptproc-pid-vm
,proc-uptime-001
),pstore
,ptrace
,rlimits
,rseq
,seccomp
,sgx
,sigaltstack
,size
,splice
,static_keys
,syscall_user_dispatch
,tc-testing
,tdx
,timens
,timers
(exceptraw_skew
),tmpfs
,tpm2
,vDSO
,vm
,x86
,zram
Reference
kselftests–ciqlts9_2–run1.log
kselftests–ciqlts9_2–run2.log
Patch
kselftests–ciqlts9_2-CVE-2024-0646–run1.log
Comparison
Test results for the reference kernel and the patch are the same
In particular the
net:tls
test testing the modified module passed in the patched kernelSpecific tests: skipped
Appendix
Below is the full history of mainline
net/tls/tls_sw.c
file (except merge commits), cross-referenced with the history of the same file in the official stable releases 5.15 and 4.19, along with the Rocky versions LTS 8.6, 8.8, 9.2 and 9.4. The=
char next to the corresponding commit indicates that this is the exact same commit while~
char indicates that it is a cherry-picked backport. The commits relevant to this PR are marked with numberstls_sw-history.txt