WARNING: line length of 90 exceeds 80 columns #42: FILE: tools/testing/selftests/bpf/prog_tests/verifier.c:137: + /* test_verifier tests are executed w/o CAP_SYS_ADMIN, do the same here */ WARNING: line length of 98 exceeds 80 columns #45: FILE: tools/testing/selftests/bpf/prog_tests/verifier.c:140: + PRINT_FAIL("failed to drop CAP_SYS_ADMIN: %i, %s\n", err, strerror(-err)); WARNING: line length of 101 exceeds 80 columns #60: FILE: tools/testing/selftests/bpf/prog_tests/verifier.c:152: + PRINT_FAIL("failed to restore CAP_SYS_ADMIN: %i, %s\n", err, strerror(-err)); WARNING: line length of 89 exceeds 80 columns #66: FILE: tools/testing/selftests/bpf/prog_tests/verifier.c:157: +#define RUN_WITH_CAP_SYS_ADMIN(skel) run_tests_aux(#skel, skel##__elf_bytes, NULL, false) WARNING: line length of 87 exceeds 80 columns #75: FILE: tools/testing/selftests/bpf/prog_tests/verifier.c:182: +void test_verifier_ctx(void) { RUN_WITH_CAP_SYS_ADMIN(verifier_ctx); } WARNING: const array should probably be static const #107: FILE: tools/testing/selftests/bpf/progs/verifier_ctx.c:9: +const char ctx_strncmp_target[] = "ctx"; WARNING: const array should probably be static const #108: FILE: tools/testing/selftests/bpf/progs/verifier_ctx.c:10: +const char ctx_snprintf_fmt[] = ""; WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #147: FILE: tools/testing/selftests/bpf/progs/verifier_ctx.c:316: + volatile __u32 val; WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #161: FILE: tools/testing/selftests/bpf/progs/verifier_ctx.c:330: + volatile __u32 val; CHECK: Macro argument 'off' may be better as '(off)' to avoid precedence issues #322: FILE: tools/testing/selftests/bpf/progs/verifier_ctx.c:487: +#define no_rewrite_ctx_access(type, name, off, load_t) \ SEC(type) \ __description(type ": read ctx at fixed offset") \ __success \ + int no_rewrite_##name##_fixed(void *ctx) \ { \ + char *p = ctx; \ + volatile load_t val; \ + \ + val = *(load_t *)(p + off); \ + (void)val; \ + return 0; \ } \ SEC(type) \ __description(type ": reject variable offset ctx access") \ __failure __msg("variable ctx access var_off=") \ + int no_rewrite_##name##_var(void *ctx) \ { \ + __u64 off_var = bpf_get_prandom_u32(); \ + char *p = ctx; \ + \ + off_var &= 4; \ + p += off_var; \ + return *(load_t *)p; \ } \ SEC(type) \ __description(type ": reject negative offset ctx access") \ + __failure __msg("invalid bpf_context access") \ + int no_rewrite_##name##_neg(void *ctx) \ { \ + char *p = ctx; \ + \ + p -= 612; \ + return *(load_t *)p; \ + } \ + SEC(type) \ + __description(type ": reject helper read ctx at fixed offset") \ + __failure __msg("dereference of modified ctx ptr") \ + int no_rewrite_##name##_helper_read_fixed(void *ctx) \ + { \ + char *p = ctx; \ + \ + p += off; \ + return bpf_strncmp(p, 4, ctx_strncmp_target); \ + } \ + SEC(type) \ + __description(type ": reject helper write ctx at fixed offset") \ + __failure __msg("dereference of modified ctx ptr") \ + int no_rewrite_##name##_helper_write_fixed(void *ctx) \ + { \ + char *p = ctx; \ + \ + p += off; \ + return bpf_probe_read_kernel(p, 4, 0); \ + } \ + SEC(type) \ + __description(type ": reject helper read ctx with variable offset") \ + __failure __msg("variable ctx access var_off=") \ + int no_rewrite_##name##_helper_read_var(void *ctx) \ + { \ + __u64 off_var = bpf_get_prandom_u32(); \ + char *p = ctx; \ + \ + off_var &= 4; \ + p += off_var; \ + return bpf_strncmp(p, 4, ctx_strncmp_target); \ + } \ + SEC(type) \ + __description(type ": reject helper write ctx with variable offset") \ + __failure __msg("variable ctx access var_off=") \ + int no_rewrite_##name##_helper_write_var(void *ctx) \ + { \ + __u64 off_var = bpf_get_prandom_u32(); \ + char *p = ctx; \ + \ + off_var &= 4; \ + p += off_var; \ + return bpf_probe_read_kernel(p, 4, 0); \ + } \ + SEC(type) \ + __description(type ": reject helper read zero-sized ctx access") \ + __failure __msg("R4 type=ctx expected=fp") \ + int no_rewrite_##name##_helper_read_zero(void *ctx) \ + { \ + return bpf_snprintf(0, 0, ctx_snprintf_fmt, ctx, 0); \ + } \ + SEC(type) \ + __description(type ": reject helper write zero-sized ctx access") \ + __failure __msg("R1 type=ctx expected=fp") \ + int no_rewrite_##name##_helper_write_zero(void *ctx) \ + { \ + return bpf_probe_read_kernel(ctx, 0, 0); \ + } \ + SEC(type) \ + __description(type ": reject kfunc ctx at fixed offset") \ + __failure __msg("dereference of modified ctx ptr") \ + int no_rewrite_##name##_kfunc_fixed(void *ctx) \ + { \ + char *p = ctx; \ + \ + p += off; \ + bpf_kfunc_call_test_mem_len_pass1(p, 4); \ + return 0; \ + } \ + SEC(type) \ + __description(type ": reject kfunc ctx with variable offset") \ + __failure __msg("variable ctx access var_off=") \ + int no_rewrite_##name##_kfunc_var(void *ctx) \ + { \ + __u64 off_var = bpf_get_prandom_u32(); \ + char *p = ctx; \ + \ + off_var &= 4; \ + p += off_var; \ + bpf_kfunc_call_test_mem_len_pass1(p, 4); \ + return 0; \ + } \ + SEC(type) \ + __description(type ": reject kfunc zero-sized ctx access") \ + __failure __msg("R1 type=ctx expected=fp") \ + int no_rewrite_##name##_kfunc_zero(void *ctx) \ + { \ + bpf_kfunc_call_test_mem_len_pass1(ctx, 0); \ + return 0; \ } WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #338: FILE: tools/testing/selftests/bpf/progs/verifier_ctx.c:494: + volatile load_t val; \ WARNING: line length of 81 exceeds 80 columns #445: FILE: tools/testing/selftests/bpf/progs/verifier_ctx.c:578: + return bpf_probe_read_kernel(ctx, 0, 0); \ WARNING: line length of 87 exceeds 80 columns #494: FILE: tools/testing/selftests/bpf/progs/verifier_ctx.c:619: +no_rewrite_ctx_access("netfilter", netfilter, offsetof(struct bpf_nf_ctx, skb), __u64); total: 0 errors, 12 warnings, 1 checks, 476 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. Commit 791481f187d6 ("selftests/bpf: Adjust syscall ctx variable offset tests") has style problems, please review. NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT BAD_REPORTED_BY_LINK CAMELCASE COMMIT_LOG_LONG_LINE FILE_PATH_CHANGES GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. total: 0 errors, 12 warnings, 1 checks, 476 lines checked