Repository navigation
Commit afbf21d
bpf: Support readonly/readwrite buffers in verifier
Readonly and readwrite buffer register states
are introduced. Totally four states,
PTR_TO_RDONLY_BUF[_OR_NULL] and PTR_TO_RDWR_BUF[_OR_NULL]
are supported. As suggested by their respective
names, PTR_TO_RDONLY_BUF[_OR_NULL] are for
readonly buffers and PTR_TO_RDWR_BUF[_OR_NULL]
for read/write buffers.
These new register states will be used
by later bpf map element iterator.
New register states share some similarity to
PTR_TO_TP_BUFFER as it will calculate accessed buffer
size during verification time. The accessed buffer
size will be later compared to other metrics during
later attach/link_create time.
Similar to reg_state PTR_TO_BTF_ID_OR_NULL in bpf
iterator programs, PTR_TO_RDONLY_BUF_OR_NULL or
PTR_TO_RDWR_BUF_OR_NULL reg_types can be set at
prog->aux->bpf_ctx_arg_aux, and bpf verifier will
retrieve the values during btf_ctx_access().
Later bpf map element iterator implementation
will show how such information will be assigned
during target registeration time.
The verifier is also enhanced such that PTR_TO_RDONLY_BUF
can be passed to ARG_PTR_TO_MEM[_OR_NULL] helper argument, and
PTR_TO_RDWR_BUF can be passed to ARG_PTR_TO_MEM[_OR_NULL] or
ARG_PTR_TO_UNINIT_MEM.
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200723184111.590274-1-yhs@fb.com1 parent f9c7927 commit afbf21d
3 files changed
Lines changed: 104 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
356 | 360 | | |
357 | 361 | | |
358 | 362 | | |
| |||
694 | 698 | | |
695 | 699 | | |
696 | 700 | | |
| 701 | + | |
| 702 | + | |
697 | 703 | | |
698 | 704 | | |
699 | 705 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3806 | 3806 | | |
3807 | 3807 | | |
3808 | 3808 | | |
| 3809 | + | |
| 3810 | + | |
| 3811 | + | |
| 3812 | + | |
| 3813 | + | |
| 3814 | + | |
| 3815 | + | |
| 3816 | + | |
| 3817 | + | |
| 3818 | + | |
| 3819 | + | |
| 3820 | + | |
| 3821 | + | |
3809 | 3822 | | |
3810 | 3823 | | |
3811 | 3824 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
412 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
413 | 415 | | |
414 | 416 | | |
415 | 417 | | |
| |||
503 | 505 | | |
504 | 506 | | |
505 | 507 | | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
506 | 512 | | |
507 | 513 | | |
508 | 514 | | |
| |||
2173 | 2179 | | |
2174 | 2180 | | |
2175 | 2181 | | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
2176 | 2186 | | |
2177 | 2187 | | |
2178 | 2188 | | |
| |||
3052 | 3062 | | |
3053 | 3063 | | |
3054 | 3064 | | |
3055 | | - | |
3056 | | - | |
3057 | | - | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
3058 | 3069 | | |
3059 | 3070 | | |
3060 | 3071 | | |
3061 | | - | |
3062 | | - | |
| 3072 | + | |
| 3073 | + | |
3063 | 3074 | | |
3064 | 3075 | | |
3065 | 3076 | | |
| |||
3071 | 3082 | | |
3072 | 3083 | | |
3073 | 3084 | | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
3074 | 3099 | | |
3075 | 3100 | | |
3076 | 3101 | | |
3077 | 3102 | | |
3078 | 3103 | | |
3079 | 3104 | | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
3080 | 3124 | | |
3081 | 3125 | | |
3082 | 3126 | | |
| |||
3427 | 3471 | | |
3428 | 3472 | | |
3429 | 3473 | | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
3430 | 3491 | | |
3431 | 3492 | | |
3432 | 3493 | | |
| |||
3668 | 3729 | | |
3669 | 3730 | | |
3670 | 3731 | | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
3671 | 3744 | | |
3672 | 3745 | | |
3673 | 3746 | | |
| |||
3933 | 4006 | | |
3934 | 4007 | | |
3935 | 4008 | | |
| 4009 | + | |
| 4010 | + | |
3936 | 4011 | | |
3937 | 4012 | | |
3938 | 4013 | | |
| |||
6806 | 6881 | | |
6807 | 6882 | | |
6808 | 6883 | | |
| 6884 | + | |
| 6885 | + | |
| 6886 | + | |
| 6887 | + | |
6809 | 6888 | | |
6810 | 6889 | | |
6811 | 6890 | | |
| |||
0 commit comments