Skip to content
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

bpf verifier: not able to store an immediate number into a register memory if reg type is PTR_TO_CTX #95

Open
QiongwenXu opened this issue Sep 6, 2020 · 0 comments

Comments

@QiongwenXu
Copy link
Collaborator

QiongwenXu commented Sep 6, 2020

bpf verifier:
not able to store an immediate number into a register memory if reg type is PTR_TO_CTX
but storing a register value is legal
eg:

*(u32*)(r1+0) = r2 -> legal
*(u32*)(r1+0) = 0  -> illegal

where r1 is the input of BPF program

reference:
https://github.com/torvalds/linux/blob/a8205e310011f09cc73cd577d7b0074c57b9bb54/kernel/bpf/verifier.c
key information:
1.

 * At the start of BPF program the register R1 contains a pointer to bpf_context
 * and has type PTR_TO_CTX.
			if (is_ctx_reg(env, insn->dst_reg)) {
				verbose(env, "BPF_ST stores into R%d %s is not allowed\n",
					insn->dst_reg,
					reg_type_str[reg_state(env, insn->dst_reg)->type]);
				return -EACCES;
			}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant