tools/testing/selftests/bpf/progs/verifier_div0.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_div0.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/verifier_div0.c
Extension
.c
Size
4047 bytes
Lines
214
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/* Converted from tools/testing/selftests/bpf/verifier/div0.c */

#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"

SEC("socket")
__description("DIV32 by 0, zero check 1")
__success __success_unpriv __retval(42)
__naked void by_0_zero_check_1_1(void)
{
	asm volatile ("					\
	w0 = 42;					\
	w1 = 0;						\
	w2 = 1;						\
	w2 /= w1;					\
	exit;						\
"	::: __clobber_all);
}

SEC("socket")
__description("DIV32 by 0, zero check 2")
__success __success_unpriv __retval(42)
__naked void by_0_zero_check_2_1(void)
{
	asm volatile ("					\
	w0 = 42;					\
	r1 = 0xffffffff00000000LL ll;			\
	w2 = 1;						\
	w2 /= w1;					\
	exit;						\
"	::: __clobber_all);
}

SEC("socket")
__description("DIV64 by 0, zero check")
__success __success_unpriv __retval(42)
__naked void div64_by_0_zero_check(void)
{
	asm volatile ("					\
	w0 = 42;					\
	w1 = 0;						\
	w2 = 1;						\
	r2 /= r1;					\
	exit;						\
"	::: __clobber_all);
}

SEC("socket")
__description("MOD32 by 0, zero check 1")
__success __success_unpriv __retval(42)
__naked void by_0_zero_check_1_2(void)
{
	asm volatile ("					\
	w0 = 42;					\
	w1 = 0;						\
	w2 = 1;						\
	w2 %%= w1;					\
	exit;						\
"	::: __clobber_all);
}

SEC("socket")
__description("MOD32 by 0, zero check 2")
__success __success_unpriv __retval(42)
__naked void by_0_zero_check_2_2(void)
{
	asm volatile ("					\
	w0 = 42;					\
	r1 = 0xffffffff00000000LL ll;			\
	w2 = 1;						\
	w2 %%= w1;					\
	exit;						\
"	::: __clobber_all);
}

SEC("socket")
__description("MOD64 by 0, zero check")
__success __success_unpriv __retval(42)
__naked void mod64_by_0_zero_check(void)
{
	asm volatile ("					\
	w0 = 42;					\
	w1 = 0;						\
	w2 = 1;						\
	r2 %%= r1;					\
	exit;						\
"	::: __clobber_all);
}

Annotation

Implementation Notes