diff mbox series

[bpf-next,v4,4/7] bpf: sockmap: accept sock_common pointer when updating

Message ID 20200907144701.44867-5-lmb@cloudflare.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series Sockmap iterator | expand

Commit Message

Lorenz Bauer Sept. 7, 2020, 2:46 p.m. UTC
The sockmap update path already ensures that only full sockets are
inserted (see sock_map_sk_state_allowed). Allow BPF to pass pointers
to sock_common to map_update_elem(sockmap). This allows calling the
helper with struct sock pointer derived from the sockmap iterator context.

Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
 kernel/bpf/verifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index f1f45ce42d60..a4c398e05673 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -3895,7 +3895,7 @@  static int resolve_map_arg_type(struct bpf_verifier_env *env,
 	case BPF_MAP_TYPE_SOCKMAP:
 	case BPF_MAP_TYPE_SOCKHASH:
 		if (*arg_type == ARG_PTR_TO_MAP_VALUE) {
-			*arg_type = ARG_PTR_TO_SOCKET;
+			*arg_type = ARG_PTR_TO_SOCK_COMMON;
 		} else {
 			verbose(env, "invalid arg_type for sockmap/sockhash\n");
 			return -EINVAL;