Daniel Borkmann
7acfa07c58
bpf: Fix oob access in cgroup local storage
...
[ Upstream commit abad3d0bad ]
Lonial reported that an out-of-bounds access in cgroup local storage
can be crafted via tail calls. Given two programs each utilizing a
cgroup local storage with a different value size, and one program
doing a tail call into the other. The verifier will validate each of
the indivial programs just fine. However, in the runtime context
the bpf_cg_run_ctx holds an bpf_prog_array_item which contains the
BPF program as well as any cgroup local storage flavor the program
uses. Helpers such as bpf_get_local_storage() pick this up from the
runtime context:
ctx = container_of(current->bpf_ctx, struct bpf_cg_run_ctx, run_ctx);
storage = ctx->prog_item->cgroup_storage[stype];
if (stype == BPF_CGROUP_STORAGE_SHARED)
ptr = &READ_ONCE(storage->buf)->data[0];
else
ptr = this_cpu_ptr(storage->percpu_buf);
For the second program which was called from the originally attached
one, this means bpf_get_local_storage() will pick up the former
program's map, not its own. With mismatching sizes, this can result
in an unintended out-of-bounds access.
To fix this issue, we need to extend bpf_map_owner with an array of
storage_cookie[] to match on i) the exact maps from the original
program if the second program was using bpf_get_local_storage(), or
ii) allow the tail call combination if the second program was not
using any of the cgroup local storage maps.
Fixes: 7d9c342789 ("bpf: Make cgroup storages shared between programs on the same cgroup")
Reported-by: Lonial Con <kongln9170@gmail.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Link: https://lore.kernel.org/r/20250730234733.530041-4-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org >
Signed-off-by: Sasha Levin <sashal@kernel.org >
2025-09-09 18:56:19 +02:00
..
2024-06-27 13:49:11 +02:00
2024-12-09 10:32:02 +01:00
2025-01-02 10:31:59 +01:00
2024-12-19 18:11:29 +01:00
2024-06-12 11:12:23 +02:00
2024-10-22 15:46:19 +02:00
2024-12-14 19:59:46 +01:00
2024-06-12 11:12:21 +02:00
2024-10-22 15:46:35 +02:00
2025-02-08 09:51:57 +01:00
2025-06-04 14:42:09 +02:00
2025-09-04 15:30:23 +02:00
2025-06-27 11:08:51 +01:00
2025-05-09 09:43:58 +02:00
2025-02-08 09:51:54 +01:00
2024-06-21 14:38:34 +02:00
2024-09-12 11:11:32 +02:00
2025-08-28 16:28:42 +02:00
2024-09-08 07:54:43 +02:00
2024-07-25 09:50:47 +02:00
2025-03-07 16:45:36 +01:00
2025-08-28 16:28:19 +02:00
2025-06-27 11:08:52 +01:00
2024-09-12 11:11:40 +02:00
2025-08-28 16:28:42 +02:00
2025-06-19 15:28:08 +02:00
2024-11-14 13:19:38 +01:00
2025-09-04 15:30:21 +02:00
2025-08-15 12:08:39 +02:00
2025-04-25 10:45:45 +02:00
2025-02-17 09:40:03 +01:00
2025-06-19 15:28:44 +02:00
2024-10-04 16:29:59 +02:00
2024-06-12 11:11:38 +02:00
2025-08-28 16:28:40 +02:00
2024-08-14 13:59:02 +02:00
2025-02-21 13:57:09 +01:00
2024-12-09 10:32:56 +01:00
2024-05-25 16:22:53 +02:00
2025-05-09 09:43:54 +02:00
2025-09-09 18:56:18 +02:00
2025-09-09 18:56:19 +02:00
2025-02-08 09:52:26 +01:00
2025-06-19 15:28:44 +02:00
2024-07-25 09:50:40 +02:00
2025-02-21 13:57:17 +01:00
2025-01-09 13:31:53 +01:00
2024-08-14 13:58:56 +02:00
2025-03-13 12:58:27 +01:00
2024-07-05 09:34:04 +02:00
2024-12-09 10:32:46 +01:00
2024-12-09 10:32:46 +01:00
2024-11-08 16:28:20 +01:00
2025-08-28 16:28:46 +02:00
2025-07-06 11:00:10 +02:00
2025-04-10 14:37:36 +02:00
2025-06-04 14:42:24 +02:00
2025-04-10 14:37:32 +02:00
2024-06-12 11:12:14 +02:00
2025-07-10 16:03:21 +02:00
2025-08-28 16:28:42 +02:00
2024-08-29 17:33:14 +02:00
2024-11-22 15:38:35 +01:00
2024-06-12 11:11:57 +02:00
2024-11-08 16:28:24 +01:00
2024-09-04 13:28:24 +02:00
2025-06-04 14:41:53 +02:00
2024-12-14 20:00:16 +01:00
2025-02-21 13:57:17 +01:00
2025-08-28 16:28:42 +02:00
2024-12-14 19:59:58 +01:00
2024-08-29 17:33:31 +02:00
2025-07-10 16:03:18 +02:00
2024-10-04 16:29:37 +02:00
2024-12-14 20:00:05 +01:00
2024-06-12 11:11:56 +02:00
2024-10-10 11:58:00 +02:00
2025-05-09 09:43:54 +02:00
2024-06-12 11:12:51 +02:00
2025-08-15 12:08:39 +02:00
2025-08-28 16:28:39 +02:00
2024-07-25 09:50:57 +02:00
2024-09-08 07:54:44 +02:00
2024-07-11 12:49:16 +02:00
2025-04-10 14:37:29 +02:00
2025-06-19 15:28:44 +02:00
2025-06-04 14:42:21 +02:00
2024-12-09 10:31:48 +01:00
2025-06-04 14:42:22 +02:00
2024-11-08 16:28:27 +01:00
2025-06-27 11:09:00 +01:00
2024-09-08 07:54:43 +02:00
2025-07-06 11:00:09 +02:00
2025-08-28 16:28:11 +02:00
2024-10-10 11:58:01 +02:00
2025-03-22 12:50:37 -07:00
2025-02-08 09:51:58 +01:00
2025-08-28 16:28:23 +02:00
2024-12-09 10:32:59 +01:00
2024-10-17 15:24:26 +02:00
2025-04-10 14:37:26 +02:00
2025-06-19 15:28:44 +02:00
2024-12-27 13:58:55 +01:00
2024-11-08 16:28:19 +01:00
2024-06-21 14:38:30 +02:00
2025-08-28 16:28:47 +02:00
2025-07-06 11:00:16 +02:00
2025-08-01 09:47:29 +01:00
2024-10-17 15:24:13 +02:00
2024-12-09 10:31:50 +01:00
2025-02-08 09:52:27 +01:00
2024-06-27 13:49:13 +02:00
2024-06-27 13:49:03 +02:00
2024-06-16 13:47:41 +02:00
2024-06-12 11:12:52 +02:00
2025-02-17 09:40:16 +01:00
2024-12-14 20:00:12 +01:00
2025-07-10 16:03:15 +02:00
2024-12-09 10:32:45 +01:00
2024-07-11 12:49:18 +02:00
2025-06-04 14:42:01 +02:00
2025-07-17 18:35:22 +02:00
2025-06-19 15:28:19 +02:00
2025-01-09 13:31:40 +01:00
2024-11-01 01:58:25 +01:00
2025-08-28 16:28:39 +02:00
2024-10-17 15:24:10 +02:00
2025-01-17 13:36:26 +01:00
2025-08-28 16:28:39 +02:00
2024-11-22 15:38:37 +01:00
2024-12-09 10:32:59 +01:00
2024-07-18 13:21:10 +02:00
2024-06-27 13:49:14 +02:00
2025-05-18 08:24:11 +02:00
2025-08-15 12:08:57 +02:00
2025-02-08 09:52:02 +01:00
2025-06-04 14:42:06 +02:00
2025-01-09 13:31:41 +01:00
2025-06-27 11:09:03 +01:00
2024-10-17 15:24:29 +02:00
2024-12-09 10:32:12 +01:00
2025-06-04 14:42:25 +02:00
2025-09-04 15:30:20 +02:00
2025-04-25 10:45:46 +02:00
2025-01-17 13:36:09 +01:00
2025-03-22 12:50:43 -07:00
2024-07-05 09:33:53 +02:00
2024-09-18 19:24:04 +02:00
2025-02-27 04:10:47 -08:00
2024-08-03 08:53:38 +02:00
2024-12-09 10:31:56 +01:00
2025-02-08 09:51:51 +01:00
2024-12-09 10:32:59 +01:00
2024-12-09 10:32:59 +01:00
2024-07-25 09:50:56 +02:00
2025-06-04 14:42:21 +02:00
2024-07-18 13:21:20 +02:00
2024-10-17 15:24:22 +02:00
2025-08-28 16:28:40 +02:00
2025-06-04 14:42:13 +02:00
2025-04-25 10:45:31 +02:00
2025-06-19 15:28:19 +02:00
2025-08-28 16:28:42 +02:00
2025-01-23 17:21:14 +01:00
2025-08-15 12:08:42 +02:00
2024-06-12 11:11:56 +02:00
2025-08-15 12:08:54 +02:00
2024-08-14 13:58:47 +02:00
2024-09-18 19:24:03 +02:00
2025-01-23 17:21:12 +01:00
2025-08-15 12:08:46 +02:00
2024-06-12 11:12:24 +02:00
2025-06-04 14:42:13 +02:00
2025-03-07 16:45:47 +01:00
2025-06-04 14:42:13 +02:00
2025-04-25 10:45:06 +02:00
2025-01-09 13:31:41 +01:00
2024-10-04 16:29:38 +02:00
2024-12-14 19:59:50 +01:00
2025-08-15 12:09:07 +02:00
2024-08-11 12:47:16 +02:00
2025-02-01 18:37:51 +01:00
2024-07-11 12:49:18 +02:00
2025-01-09 13:32:05 +01:00
2024-12-09 10:31:51 +01:00
2024-07-05 09:34:00 +02:00
2025-02-27 04:10:45 -08:00
2025-08-28 16:28:23 +02:00
2025-02-27 04:10:50 -08:00
2024-08-29 17:33:23 +02:00
2024-06-16 13:47:49 +02:00
2024-12-09 10:32:10 +01:00
2024-11-22 15:38:32 +01:00
2025-01-09 13:31:41 +01:00
2025-08-01 09:47:30 +01:00
2024-12-19 18:11:37 +01:00
2024-10-10 11:58:08 +02:00
2024-07-05 09:34:04 +02:00
2024-08-11 12:47:13 +02:00
2024-11-01 01:58:20 +01:00
2024-10-17 15:24:23 +02:00
2024-11-08 16:28:16 +01:00
2024-11-14 13:19:37 +01:00
2025-05-22 14:12:12 +02:00
2025-04-10 14:37:41 +02:00
2025-06-04 14:41:54 +02:00
2025-06-04 14:41:54 +02:00
2024-06-12 11:12:35 +02:00
2024-06-27 13:49:05 +02:00
2025-05-18 08:24:09 +02:00
2024-11-08 16:28:26 +01:00
2024-10-10 11:57:36 +02:00
2024-11-14 13:19:39 +01:00
2024-12-09 10:33:06 +01:00
2024-10-10 11:57:17 +02:00
2025-08-28 16:28:25 +02:00
2025-01-02 10:32:00 +01:00
2025-08-15 12:09:01 +02:00
2024-12-27 13:58:57 +01:00
2024-07-05 09:33:45 +02:00
2024-10-04 16:30:02 +02:00