Files
rockchip-kernel/include/linux
YiFei Zhu c4dcfdd406 bpf: Move getsockopt retval to struct bpf_cg_run_ctx
The retval value is moved to struct bpf_cg_run_ctx for ease of access
in different prog types with different context structs layouts. The
helper implementation (to be added in a later patch in the series) can
simply perform a container_of from current->bpf_ctx to retrieve
bpf_cg_run_ctx.

Unfortunately, there is no easy way to access the current task_struct
via the verifier BPF bytecode rewrite, aside from possibly calling a
helper, so a pointer to current task is added to struct bpf_sockopt_kern
so that the rewritten BPF bytecode can access struct bpf_cg_run_ctx with
an indirection.

For backward compatibility, if a getsockopt program rejects a syscall
by returning 0, an -EPERM will be generated, by having the
BPF_PROG_RUN_ARRAY_CG family macros automatically set the retval to
-EPERM. Unlike prior to this patch, this -EPERM will be visible to
ctx->retval for any other hooks down the line in the prog array.

Additionally, the restriction that getsockopt filters can only set
the retval to 0 is removed, considering that certain getsockopt
implementations may return optlen. Filters are now able to set the
value arbitrarily.

Signed-off-by: YiFei Zhu <zhuyifei@google.com>
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/r/73b0325f5c29912ccea7ea57ec1ed4d388fc1d37.1639619851.git.zhuyifei@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2022-01-19 12:51:30 -08:00
..
2021-09-20 12:43:34 +01:00
2021-08-29 14:47:42 +03:00
2021-10-07 16:51:57 +02:00
2021-10-18 14:43:23 -06:00
2021-11-17 10:36:15 -05:00
2021-09-08 15:32:35 -07:00
2021-12-10 17:10:55 -08:00
2021-10-25 12:01:14 +05:30
2021-12-10 12:51:28 +01:00
2021-12-01 00:06:43 +01:00
2021-08-26 15:32:28 -04:00
2021-09-06 07:20:56 -04:00
2021-11-17 10:36:35 -05:00
2021-10-18 07:49:38 -04:00
2021-10-05 06:54:16 -05:00
2021-10-18 07:49:39 -04:00
2021-09-30 12:46:44 -06:00
2021-09-27 09:27:29 -04:00
2022-01-06 12:25:40 +01:00
2021-08-23 13:19:12 +02:00
2021-09-21 13:44:55 -07:00
2021-11-10 21:16:56 +00:00
2021-11-16 19:07:53 -08:00
2021-09-17 13:52:17 +01:00
2021-10-18 07:49:39 -04:00
2021-09-27 09:27:29 -04:00
2021-11-17 10:36:35 -05:00
2021-09-27 17:00:21 +02:00
2021-10-14 13:29:18 +02:00
2021-08-18 22:08:24 +02:00
2021-11-18 09:36:39 +01:00
2021-10-07 16:51:57 +02:00
2021-10-18 07:49:39 -04:00
2021-10-18 17:20:50 +02:00
2021-08-17 17:50:51 +02:00
2021-10-30 16:37:28 +02:00
2021-11-16 13:10:34 +00:00
2021-10-26 14:58:45 +01:00
2021-08-19 09:02:55 +09:00
2021-11-03 11:41:25 -07:00
2021-10-07 13:51:11 +02:00
2021-09-22 16:59:13 +02:00
2021-09-08 15:32:35 -07:00
2021-12-09 10:49:56 -08:00
2021-10-19 23:44:30 +08:00