public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf] bpf/tests: Remove test for MOVSX32 with offset=32
@ 2023-11-10 17:51 Puranjay Mohan
  2023-11-12 19:14 ` Stanislav Fomichev
  2023-11-15 20:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Puranjay Mohan @ 2023-11-10 17:51 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Puranjay Mohan,
	open list:BPF [GENERAL] (Safe Dynamic Programs and Tools),
	open list

MOVSX32 only supports sign extending 8-bit and 16-bit operands into 32
bit operands. The "ALU_MOVSX | BPF_W" test tries to sign extend a 32 bit
operand into a 32 bit operand which is equivalent to a normal BPF_MOV.

Remove this test as it tries to run an invalid instruction.

Fixes: daabb2b098e0 ("bpf/tests: add tests for cpuv4 instructions")
Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202310111838.46ff5b6a-oliver.sang@intel.com
---
 lib/test_bpf.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 7916503e6a6a..c148f8d1e564 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -5144,22 +5144,6 @@ static struct bpf_test tests[] = {
 		{ },
 		{ { 0, 0x1 } },
 	},
-	{
-		"ALU_MOVSX | BPF_W",
-		.u.insns_int = {
-			BPF_LD_IMM64(R2, 0x00000000deadbeefLL),
-			BPF_LD_IMM64(R3, 0xdeadbeefdeadbeefLL),
-			BPF_MOVSX32_REG(R1, R3, 32),
-			BPF_JMP_REG(BPF_JEQ, R2, R1, 2),
-			BPF_MOV32_IMM(R0, 2),
-			BPF_EXIT_INSN(),
-			BPF_MOV32_IMM(R0, 1),
-			BPF_EXIT_INSN(),
-		},
-		INTERNAL,
-		{ },
-		{ { 0, 0x1 } },
-	},
 	/* MOVSX64 REG */
 	{
 		"ALU64_MOVSX | BPF_B",
-- 
2.39.2


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

* Re: [PATCH bpf] bpf/tests: Remove test for MOVSX32 with offset=32
  2023-11-10 17:51 [PATCH bpf] bpf/tests: Remove test for MOVSX32 with offset=32 Puranjay Mohan
@ 2023-11-12 19:14 ` Stanislav Fomichev
  2023-11-13  3:27   ` Yonghong Song
  2023-11-15 20:50 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Stanislav Fomichev @ 2023-11-12 19:14 UTC (permalink / raw)
  To: Puranjay Mohan
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Hao Luo, Jiri Olsa,
	open list:BPF [GENERAL] (Safe Dynamic Programs and Tools),
	open list

On 11/10, Puranjay Mohan wrote:
> MOVSX32 only supports sign extending 8-bit and 16-bit operands into 32
> bit operands. The "ALU_MOVSX | BPF_W" test tries to sign extend a 32 bit
> operand into a 32 bit operand which is equivalent to a normal BPF_MOV.
> 
> Remove this test as it tries to run an invalid instruction.
> 
> Fixes: daabb2b098e0 ("bpf/tests: add tests for cpuv4 instructions")
> Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202310111838.46ff5b6a-oliver.sang@intel.com

Acked-by: Stanislav Fomichev <sdf@google.com>

(based on the fact that emit_movsx_reg doesn't handle 32 bit case under !is64)

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

* Re: [PATCH bpf] bpf/tests: Remove test for MOVSX32 with offset=32
  2023-11-12 19:14 ` Stanislav Fomichev
@ 2023-11-13  3:27   ` Yonghong Song
  0 siblings, 0 replies; 4+ messages in thread
From: Yonghong Song @ 2023-11-13  3:27 UTC (permalink / raw)
  To: Stanislav Fomichev, Puranjay Mohan
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, John Fastabend, KP Singh, Hao Luo,
	Jiri Olsa,
	open list:BPF [GENERAL] (Safe Dynamic Programs and Tools),
	open list


On 11/12/23 11:14 AM, Stanislav Fomichev wrote:
> On 11/10, Puranjay Mohan wrote:
>> MOVSX32 only supports sign extending 8-bit and 16-bit operands into 32
>> bit operands. The "ALU_MOVSX | BPF_W" test tries to sign extend a 32 bit
>> operand into a 32 bit operand which is equivalent to a normal BPF_MOV.
>>
>> Remove this test as it tries to run an invalid instruction.
>>
>> Fixes: daabb2b098e0 ("bpf/tests: add tests for cpuv4 instructions")
>> Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
>> Reported-by: kernel test robot <oliver.sang@intel.com>
>> Closes: https://lore.kernel.org/oe-lkp/202310111838.46ff5b6a-oliver.sang@intel.com
> Acked-by: Stanislav Fomichev <sdf@google.com>
>
> (based on the fact that emit_movsx_reg doesn't handle 32 bit case under !is64)

The test failure signature is:
   #83 ALU_MOVSX | BPF_W jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times)

If the asm code went though verifier, we should get a verification failure.
But in test_bpf.ko case, the asm code is directly jited (see jited:1 above),
so there is no verification failure.

The current jit does not do error handling and assumes asm code are all legal,
so for !is64 case, the size = 32 asm code is silently ignored for x86 side
and caused the error. But the test is introduced by arm64 and the test passed
for arm64.

Not sure how we could prevent such issues. To handle *all* illegal insns in jit
definitely not a good idea. In any case, the change for this patch looks good.

Acked-by: Yonghong Song <yonghong.song@linux.dev>


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

* Re: [PATCH bpf] bpf/tests: Remove test for MOVSX32 with offset=32
  2023-11-10 17:51 [PATCH bpf] bpf/tests: Remove test for MOVSX32 with offset=32 Puranjay Mohan
  2023-11-12 19:14 ` Stanislav Fomichev
@ 2023-11-15 20:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-15 20:50 UTC (permalink / raw)
  To: Puranjay Mohan
  Cc: ast, daniel, andrii, martin.lau, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Fri, 10 Nov 2023 17:51:50 +0000 you wrote:
> MOVSX32 only supports sign extending 8-bit and 16-bit operands into 32
> bit operands. The "ALU_MOVSX | BPF_W" test tries to sign extend a 32 bit
> operand into a 32 bit operand which is equivalent to a normal BPF_MOV.
> 
> Remove this test as it tries to run an invalid instruction.
> 
> Fixes: daabb2b098e0 ("bpf/tests: add tests for cpuv4 instructions")
> Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202310111838.46ff5b6a-oliver.sang@intel.com
> 
> [...]

Here is the summary with links:
  - [bpf] bpf/tests: Remove test for MOVSX32 with offset=32
    https://git.kernel.org/bpf/bpf-next/c/5fa201f37c2e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-11-15 20:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-10 17:51 [PATCH bpf] bpf/tests: Remove test for MOVSX32 with offset=32 Puranjay Mohan
2023-11-12 19:14 ` Stanislav Fomichev
2023-11-13  3:27   ` Yonghong Song
2023-11-15 20:50 ` 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