BPF List
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Fix truncation bug in coerce_reg_to_size_sx and extend selftests.
@ 2024-10-14 12:11 Dimitar Kanaliev
  2024-10-14 12:11 ` [PATCH v2 1/3] bpf: Fix truncation bug in coerce_reg_to_size_sx() Dimitar Kanaliev
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Dimitar Kanaliev @ 2024-10-14 12:11 UTC (permalink / raw)
  To: Yonghong Song, bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Mykola Lysenko,
	Dimitar Kanaliev

This patch series addresses a truncation bug in the eBPF verifier function
coerce_reg_to_size_sx(). The issue was caused by the incorrect ordering
of assignments between 32-bit and 64-bit min/max values, leading to
improper truncation when updating the register state. This issue has been
reported previously by Zac Ecob[1] , but was not followed up on.

The first patch fixes the assignment order in coerce_reg_to_size_sx()
to ensure correct truncation. The subsequent patches add selftests for
coerce_{reg,subreg}_to_size_sx.

Changelog:
	v1 -> v2:
	 - Moved selftests inside the conditional check for cpuv4

[1] (https://lore.kernel.org/bpf/h3qKLDEO6m9nhif0eAQX4fVrqdO0D_OPb0y5HfMK9jBePEKK33wQ3K-bqSVnr0hiZdFZtSJOsbNkcEQGpv_yJk61PAAiO8fUkgMRSO-lB50=@protonmail.com/)

Dimitar Kanaliev (3):
  bpf: Fix truncation bug in coerce_reg_to_size_sx()
  selftests/bpf: Add test for truncation after sign extension in
    coerce_reg_to_size_sx()
  selftests/bpf: Add test for sign extension in
    coerce_subreg_to_size_sx()

 kernel/bpf/verifier.c                         |  8 ++--
 .../selftests/bpf/progs/verifier_movsx.c      | 40 +++++++++++++++++++
 2 files changed, 44 insertions(+), 4 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-10-15 18:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14 12:11 [PATCH v2 0/3] Fix truncation bug in coerce_reg_to_size_sx and extend selftests Dimitar Kanaliev
2024-10-14 12:11 ` [PATCH v2 1/3] bpf: Fix truncation bug in coerce_reg_to_size_sx() Dimitar Kanaliev
2024-10-14 16:53   ` Yonghong Song
2024-10-15  0:34   ` Shung-Hsi Yu
2024-10-15 12:47   ` Shung-Hsi Yu
2024-10-14 12:11 ` [PATCH v2 2/3] selftests/bpf: Add test for truncation after sign extension " Dimitar Kanaliev
2024-10-14 17:55   ` Yonghong Song
2024-10-14 12:11 ` [PATCH v2 3/3] selftests/bpf: Add test for sign extension in coerce_subreg_to_size_sx() Dimitar Kanaliev
2024-10-14 17:55   ` Yonghong Song
2024-10-15 18:20 ` [PATCH v2 0/3] Fix truncation bug in coerce_reg_to_size_sx and extend selftests patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox