Alexei Starovoitov
20c09d92fa
bpf: Introduce kptr_rcu.
...
The life time of certain kernel structures like 'struct cgroup' is protected by RCU.
Hence it's safe to dereference them directly from __kptr tagged pointers in bpf maps.
The resulting pointer is MEM_RCU and can be passed to kfuncs that expect KF_RCU.
Derefrence of other kptr-s returns PTR_UNTRUSTED.
For example:
struct map_value {
struct cgroup __kptr *cgrp;
};
SEC("tp_btf/cgroup_mkdir")
int BPF_PROG(test_cgrp_get_ancestors, struct cgroup *cgrp_arg, const char *path)
{
struct cgroup *cg, *cg2;
cg = bpf_cgroup_acquire(cgrp_arg); // cg is PTR_TRUSTED and ref_obj_id > 0
bpf_kptr_xchg(&v->cgrp, cg);
cg2 = v->cgrp; // This is new feature introduced by this patch.
// cg2 is PTR_MAYBE_NULL | MEM_RCU.
// When cg2 != NULL, it's a valid cgroup, but its percpu_ref could be zero
if (cg2)
bpf_cgroup_ancestor(cg2, level); // safe to do.
}
Signed-off-by: Alexei Starovoitov <ast@kernel.org >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Acked-by: Tejun Heo <tj@kernel.org >
Acked-by: David Vernet <void@manifault.com >
Link: https://lore.kernel.org/bpf/20230303041446.3630-4-alexei.starovoitov@gmail.com
2023-03-03 17:42:20 +01:00
..
2023-01-16 09:26:05 +01:00
2023-01-25 08:55:19 -08:00
2022-11-04 12:59:25 +02:00
2023-02-08 21:53:24 +01:00
2023-02-02 13:40:23 +01:00
2023-01-16 09:26:05 +01:00
2022-11-24 17:12:27 +01:00
2023-01-13 08:40:41 +00:00
2023-01-20 10:54:05 +01:00
2023-01-20 18:20:38 -08:00
2022-12-15 09:45:51 -08:00
2022-12-11 21:25:58 +01:00
2022-11-23 20:37:51 +00:00
2023-01-11 06:52:43 -05:00
2023-02-01 17:29:30 +01:00
2023-02-20 16:38:00 -08:00
2023-02-16 11:36:14 -08:00
2023-02-13 18:51:35 +02:00
2023-01-02 12:08:53 +01:00
2023-01-02 15:10:05 +01:00
2023-02-16 21:23:52 +00:00
2022-10-27 14:38:04 +03:00
2022-11-21 14:38:28 +01:00
2023-02-21 17:32:50 -08:00
2023-01-09 17:00:54 +01:00
2022-11-14 09:35:50 -08:00
2022-12-08 13:02:37 +00:00
2023-01-31 15:01:47 +01:00
2023-02-21 18:24:12 -08:00
2022-12-19 08:47:33 -06:00
2023-02-21 18:24:12 -08:00
2023-01-07 10:38:11 -08:00
2023-02-02 22:48:20 +01:00
2023-01-09 17:00:54 +01:00
2022-11-07 14:02:11 +00:00
2023-01-20 13:25:17 +00:00
2023-02-03 21:59:41 +01:00
2023-01-24 13:41:57 +01:00
2022-12-01 15:51:32 +00:00
2022-10-21 07:55:44 +09:00
2023-02-07 12:53:53 +01:00
2023-01-12 11:22:22 +01:00
2022-11-30 15:59:06 -08:00
2022-11-09 10:27:10 -08:00
2023-02-15 19:38:50 +01:00
2023-01-19 14:46:25 +01:00
2023-01-31 14:42:10 +01:00
2022-12-07 09:43:12 -07:00
2022-11-21 11:39:05 -07:00
2022-12-13 10:43:59 -08:00
2022-12-13 10:43:59 -08:00
2023-02-14 14:24:09 -07:00
2023-03-01 10:24:33 -08:00
2022-12-04 12:59:58 -08:00
2023-02-22 12:59:32 -08:00
2022-10-25 23:19:19 -07:00
2023-03-01 09:55:23 -08:00
2023-03-01 09:55:24 -08:00
2022-11-30 17:13:25 -08:00
2023-03-03 17:42:20 +01:00
2022-11-09 12:31:16 -05:00
2023-02-03 08:20:55 -07:00
2023-01-19 09:24:29 +01:00
2022-10-31 07:12:13 -10:00
2022-11-02 08:18:27 -07:00
2022-12-12 15:48:36 -08:00
2022-12-07 13:54:01 -08:00
2023-01-13 11:48:15 +01:00
2022-10-19 09:58:49 +02:00
2023-02-21 15:27:48 -08:00
2023-02-21 15:27:48 -08:00
2022-11-08 17:37:20 -08:00
2022-11-02 12:39:27 -07:00
2022-12-02 11:11:27 +01:00
2022-12-02 11:25:02 +01:00
2022-12-06 16:55:18 +01:00
2023-01-31 15:01:45 +01:00
2022-12-12 18:18:34 -08:00
2023-01-13 11:48:15 +01:00
2023-02-09 20:19:18 +01:00
2022-12-13 15:47:48 -08:00
2023-01-18 12:27:17 +01:00
2023-02-21 18:24:12 -08:00
2023-02-13 18:35:15 +08:00
2022-11-18 09:14:10 +01:00
2022-12-13 19:29:45 -08:00
2022-12-11 18:12:17 -08:00
2022-11-30 16:13:16 -08:00
2022-11-20 20:49:51 +09:00
2022-12-16 03:54:54 -08:00
2022-10-18 01:21:55 +03:00
2023-01-29 15:18:33 -07:00
2023-01-29 15:18:33 -07:00
2023-01-29 15:18:33 -07:00
2023-01-29 15:18:33 -07:00
2023-01-09 22:05:54 +01:00
2023-01-05 15:12:12 +00:00
2023-01-26 15:28:25 +01:00
2023-02-13 11:05:12 +00:00
2022-12-13 10:33:08 -08:00
2023-01-19 09:24:28 +01:00
2023-01-26 07:00:06 -05:00
2023-02-07 12:53:53 +01:00
2022-11-22 18:50:44 -08:00
2023-02-10 11:03:37 +01:00
2023-01-19 09:24:27 +01:00
2023-01-11 06:52:43 -05:00
2023-03-01 09:55:24 -08:00
2023-02-07 18:20:00 -08:00
2022-11-16 15:53:33 -08:00
2023-01-05 12:08:29 -08:00
2022-12-13 09:47:48 -08:00
2022-12-01 10:46:54 -05:00
2023-02-20 11:53:11 -08:00
2022-11-23 10:31:13 -08:00
2023-02-20 12:33:41 -08:00
2023-01-27 14:46:31 -08:00
2023-01-24 11:49:42 +00:00
2022-11-30 14:49:40 -08:00
2022-10-24 12:30:26 +03:00
2023-01-17 18:50:06 +01:00
2023-02-13 14:16:35 +01:00
2022-11-30 15:58:40 -08:00
2023-02-14 13:39:33 +08:00
2022-11-25 16:14:19 +01:00
2022-12-02 13:10:36 -08:00
2022-11-30 15:58:46 -08:00
2023-02-17 15:07:05 -08:00
2022-11-18 16:59:34 +08:00
2022-12-04 16:45:02 -08:00
2023-01-17 13:41:27 +00:00
2023-01-17 09:29:59 +01:00
2023-02-02 21:08:32 +01:00
2023-02-16 09:33:25 +01:00
2023-01-03 19:48:43 +01:00
2022-11-03 20:46:32 -07:00
2022-11-11 18:18:05 -08:00
2023-01-27 11:19:45 +00:00
2023-01-19 09:24:28 +01:00
2022-11-30 16:13:18 -08:00
2022-12-30 19:57:38 +01:00
2023-02-06 13:47:40 +01:00
2022-11-03 15:47:45 +01:00
2022-11-29 16:34:15 -04:00
2023-01-29 15:17:41 -07:00
2022-12-07 06:47:13 -07:00
2022-12-11 19:30:19 -08:00
2022-11-19 10:44:16 +01:00
2023-02-15 19:38:53 +01:00
2022-12-14 09:15:43 -08:00
2022-11-30 20:16:49 -04:00
2022-12-16 03:54:54 -08:00
2023-02-01 20:54:27 -08:00
2023-02-05 10:57:55 +00:00
2022-12-05 22:22:34 +01:00
2023-02-13 19:31:25 +00:00
2022-11-24 17:55:05 +01:00
2023-01-25 09:46:49 +00:00
2023-01-26 06:59:40 -05:00
2022-12-08 21:49:25 -05:00
2022-12-01 15:53:05 -08:00
2022-11-15 00:42:02 -08:00
2022-11-10 16:27:46 +01:00
2022-12-11 19:30:20 -08:00
2023-01-05 12:21:11 -08:00
2022-11-29 09:26:07 +00:00
2022-11-18 13:55:07 -08:00
2023-02-13 10:11:20 +02:00
2022-11-30 15:58:41 -08:00
2022-10-28 13:37:23 -07:00
2022-11-22 17:34:43 +01:00
2022-11-22 17:34:52 +01:00
2022-11-10 13:11:58 +00:00
2022-12-15 11:12:21 -08:00
2022-11-30 19:25:23 +00:00
2023-01-27 11:07:11 +00:00
2022-11-11 17:20:26 +09:00
2022-12-02 23:52:32 -08:00
2022-11-30 14:49:42 -08:00
2022-11-30 12:06:51 +01:00
2023-02-06 15:31:05 +01:00
2022-11-22 19:38:39 -07:00
2023-01-19 09:24:28 +01:00
2023-01-19 09:24:28 +01:00
2022-11-08 15:57:22 -08:00
2023-01-31 15:01:47 +01:00
2022-12-08 21:49:25 -05:00
2023-01-10 15:53:36 -08:00
2023-02-13 11:12:31 +00:00
2023-02-10 18:59:56 -08:00
2022-11-08 17:37:17 -08:00
2022-11-08 17:37:22 -08:00
2022-11-16 09:44:26 -07:00
2022-11-14 10:07:22 -08:00
2023-02-08 09:16:07 +00:00
2022-11-18 13:55:07 -08:00
2022-11-24 17:12:15 +01:00
2023-01-11 16:14:20 -08:00
2022-11-30 15:58:40 -08:00
2023-01-31 15:01:20 +01:00
2023-02-20 17:41:08 -08:00
2022-12-13 19:29:45 -08:00
2023-01-19 09:24:30 +01:00
2023-01-19 17:07:15 -08:00
2022-12-02 17:54:07 +11:00
2023-01-19 09:24:30 +01:00
2022-12-05 22:22:34 +01:00
2022-12-05 22:22:34 +01:00
2022-11-07 08:42:19 +00:00
2023-01-19 09:24:28 +01:00
2022-10-24 13:44:11 -07:00
2023-02-20 11:22:54 +00:00
2023-02-17 13:04:56 +01:00
2022-12-07 10:56:29 +08:00
2023-02-01 21:04:09 -08:00
2022-12-10 11:01:12 -05:00
2023-01-19 09:24:28 +01:00
2022-11-18 02:15:15 +01:00
2023-02-21 14:45:22 -08:00
2022-10-25 15:15:52 -07:00
2022-12-28 06:26:31 -10:00
2023-01-28 14:36:29 +01:00
2022-11-22 17:34:55 +01:00
2022-11-28 18:57:50 +01:00
2022-11-29 10:45:53 +01:00
2022-11-02 12:39:27 -07:00
2023-01-11 16:14:22 -08:00
2022-12-15 11:12:21 -08:00
2022-12-11 18:12:12 -08:00
2022-12-11 18:12:08 -08:00
2022-12-02 13:04:44 -08:00
2023-01-16 09:26:06 +01:00
2023-02-13 12:17:20 +01:00
2022-12-05 09:31:46 +01:00
2022-11-30 15:58:40 -08:00
2023-01-13 11:48:17 +01:00
2022-12-12 16:07:04 -08:00
2023-01-18 11:57:20 +01:00
2022-12-17 14:06:53 -06:00
2023-02-13 11:12:31 +00:00
2022-11-07 17:54:57 -08:00
2023-01-04 14:44:13 -07:00
2022-11-09 21:14:21 -06:00
2023-02-13 19:17:34 +01:00
2023-02-21 18:24:12 -08:00
2022-10-28 10:00:26 +02:00
2023-01-19 09:24:28 +01:00
2022-12-20 03:13:45 +01:00
2022-11-08 16:42:15 +00:00
2022-12-16 03:54:54 -08:00
2022-10-30 10:12:14 +01:00
2022-10-17 13:14:32 -07:00
2023-01-13 08:40:41 +00:00
2022-11-11 10:58:39 +00:00
2022-10-23 18:06:54 -04:00
2022-12-21 09:41:28 -08:00
2022-10-24 13:30:15 +01:00
2023-01-19 09:24:29 +01:00
2022-12-20 03:13:45 +01:00
2023-01-03 17:28:33 -08:00
2023-02-02 16:33:43 -08:00
2023-01-03 17:48:40 -08:00
2023-01-03 17:48:40 -08:00
2023-01-16 13:16:09 +00:00
2022-11-15 14:30:41 -08:00
2023-01-23 17:40:30 +01:00
2022-12-09 10:42:56 +00:00
2022-11-23 19:08:30 -05:00
2022-11-30 15:58:48 -08:00
2022-10-31 18:10:21 -07:00
2022-11-11 08:38:29 -07:00
2023-02-20 17:41:08 -08:00
2022-11-09 18:06:35 +00:00
2022-11-17 21:43:34 -08:00
2022-12-02 11:33:48 -08:00
2023-01-19 09:24:28 +01:00
2022-12-08 09:18:58 -07:00
2022-11-22 17:53:10 +01:00
2022-12-16 03:31:56 -08:00
2022-12-15 10:37:27 -08:00
2022-10-28 21:56:18 -07:00
2023-02-09 15:56:51 -08:00
2023-02-20 16:46:10 -08:00
2022-12-01 01:07:32 +01:00
2022-11-27 23:35:04 +01:00
2022-12-12 09:13:06 -08:00
2022-12-01 00:09:09 +01:00
2022-10-25 11:44:20 -07:00
2023-01-31 20:37:18 +01:00
2023-01-03 17:49:22 -08:00
2023-01-03 17:49:22 -08:00
2022-11-18 02:18:10 +01:00
2023-01-26 07:00:06 -05:00
2023-01-30 07:21:25 +00:00
2023-02-09 22:30:24 -08:00
2022-11-01 10:04:51 -07:00
2023-01-31 16:44:07 -08:00
2022-12-09 19:31:11 -08:00
2022-10-19 09:58:49 +02:00
2022-10-28 10:47:42 +01:00
2023-02-02 15:26:45 +01:00
2023-01-13 11:48:16 +01:00
2022-12-01 11:35:40 +01:00
2022-11-24 15:09:12 +01:00
2022-11-17 11:26:20 +01:00
2023-02-07 18:20:00 -08:00
2023-01-13 17:15:17 +01:00
2023-02-13 10:11:20 +02:00
2023-02-12 10:23:39 -05:00
2023-01-31 15:01:46 +01:00
2022-12-10 13:36:05 -05:00
2022-11-16 21:52:05 -05:00
2023-01-13 11:48:16 +01:00
2022-11-09 13:02:16 +01:00
2022-11-09 13:02:16 +01:00
2023-01-12 20:57:43 -08:00
2023-02-08 15:26:58 -08:00
2023-02-08 15:26:58 -08:00
2022-11-16 09:43:35 +00:00
2023-01-08 20:59:17 -07:00
2023-01-17 17:39:13 +01:00
2022-10-28 13:37:22 -07:00
2023-01-24 21:32:55 -08:00
2022-10-23 12:01:01 -07:00
2022-12-15 13:12:15 -08:00
2022-12-12 09:29:56 +00:00
2023-01-16 13:26:33 +00:00
2022-11-30 15:58:41 -08:00
2022-11-16 11:33:03 -07:00
2023-01-04 12:25:29 -10:00
2022-11-02 11:51:03 +00:00
2023-01-19 09:24:28 +01:00
2022-11-30 15:58:52 -08:00
2022-10-24 12:12:32 -07:00