Skip to content

Commit 8718269

Browse files
jeromemarchandKernel Patches Daemon
authored andcommitted
bpf: Specify access type of bpf_sysctl_get_name args
The second argument of bpf_sysctl_get_name() helper is a pointer to a buffer that is being written to. However that isn't specify in the prototype. Until commit 37cce22 ("bpf: verifier: Refactor helper access type tracking"), all helper accesses were considered as a possible write access by the verifier, so no big harm was done. However, since then, the verifier might make wrong asssumption about the content of that address which might lead it to make faulty optimizations (such as removing code that was wrongly labeled dead). This is what happens in test_sysctl selftest to the tests related to sysctl_get_name. Add MEM_WRITE flag the second argument of bpf_sysctl_get_name(). Signed-off-by: Jerome Marchand <[email protected]>
1 parent 45c71f6 commit 8718269

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/cgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2272,7 +2272,7 @@ static const struct bpf_func_proto bpf_sysctl_get_name_proto = {
22722272
.gpl_only = false,
22732273
.ret_type = RET_INTEGER,
22742274
.arg1_type = ARG_PTR_TO_CTX,
2275-
.arg2_type = ARG_PTR_TO_MEM,
2275+
.arg2_type = ARG_PTR_TO_MEM | MEM_WRITE,
22762276
.arg3_type = ARG_CONST_SIZE,
22772277
.arg4_type = ARG_ANYTHING,
22782278
};

0 commit comments

Comments
 (0)