Tonghao Zhang
0a473f8343
bpf: hash map, avoid deadlock with suitable hash mask
[ Upstream commit 9f907439dc ]
The deadlock still may occur while accessed in NMI and non-NMI
context. Because in NMI, we still may access the same bucket but with
different map_locked index.
For example, on the same CPU, .max_entries = 2, we update the hash map,
with key = 4, while running bpf prog in NMI nmi_handle(), to update
hash map with key = 20, so it will have the same bucket index but have
different map_locked index.
To fix this issue, using min mask to hash again.
Fixes: 20b6cc34ea ("bpf: Avoid hashtab deadlock with map_locked")
Signed-off-by: Tonghao Zhang <tong@infragraf.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Cc: Song Liu <song@kernel.org>
Cc: Yonghong Song <yhs@fb.com>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Stanislav Fomichev <sdf@google.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Hou Tao <houtao1@huawei.com>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20230111092903.92389-1-tong@infragraf.org
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-13 16:48:16 +02:00
..
2023-04-13 16:48:16 +02:00
2022-12-14 11:37:19 +01:00
2021-05-07 00:26:34 -07:00
2022-05-25 09:57:37 +02:00
2022-10-05 10:39:40 +02:00
2023-03-30 12:47:51 +02:00
2023-03-30 12:47:41 +02:00
2022-12-31 13:14:04 +01:00
2022-12-31 13:14:47 +01:00
2023-03-17 08:48:58 +01:00
2023-04-05 11:24:52 +02:00
2022-10-26 12:34:30 +02:00
2023-03-10 09:39:57 +01:00
2023-03-10 09:39:51 +01:00
2023-03-11 13:57:32 +01:00
2023-03-10 09:39:47 +01:00
2023-04-05 11:24:53 +02:00
2023-03-10 09:39:51 +01:00
2023-04-05 11:24:54 +02:00
2021-05-02 00:43:35 +09:00
2022-12-31 13:14:40 +01:00
2022-02-23 12:03:07 +01:00
2022-08-31 17:16:33 +02:00
2021-08-24 18:52:36 -04:00
2020-12-03 14:58:35 +01:00
2022-02-08 18:34:03 +01:00
2022-04-08 14:23:06 +02:00
2021-03-22 15:23:32 -04:00
2022-04-08 14:23:06 +02:00
2020-07-30 11:15:58 -07:00
2021-01-24 14:27:16 +01:00
2022-06-22 14:22:04 +02:00
2023-04-05 11:24:53 +02:00
2020-02-04 03:05:26 +00:00
2020-06-11 15:14:36 +02:00
2021-08-16 18:55:32 +02:00
2022-12-31 13:14:04 +01:00
2021-12-29 12:28:49 +01:00
2020-04-15 11:21:54 +02:00
2022-02-23 12:03:20 +01:00
2021-05-12 11:43:25 +02:00
2023-02-01 08:27:22 +01:00
2020-04-07 10:43:42 -07:00
2023-03-11 13:57:38 +01:00
2023-03-17 08:48:47 +01:00
2021-06-18 11:43:08 +02:00
2021-05-27 04:01:50 +09:00
2021-02-26 09:41:03 -08:00
2021-07-02 12:08:10 -07:00
2019-07-12 11:05:40 -07:00
2021-06-10 10:00:08 +02:00
2021-07-05 10:46:20 +02:00
2021-07-08 11:48:22 -07:00
2020-12-15 19:36:48 -08:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2021-08-17 17:50:51 +02:00
2021-06-28 22:43:05 +02:00
2020-11-02 18:00:20 -08:00
2021-08-30 16:36:10 +02:00
2019-09-06 23:58:44 +02:00
2022-07-21 21:24:29 +02:00
2021-02-22 12:33:26 +00:00
2021-09-08 15:32:34 -07:00
2019-05-24 20:16:01 +02:00
2021-05-07 00:26:33 -07:00
2023-03-10 09:40:01 +01:00
2019-05-30 11:26:39 -07:00
2023-03-30 12:47:42 +02:00
2020-04-27 02:07:40 -04:00
2022-12-31 13:14:04 +01:00
2021-01-19 10:24:45 +01:00
2021-01-19 10:24:45 +01:00
2019-05-24 17:27:11 +02:00
2023-02-01 08:27:23 +01:00
2021-08-16 18:55:32 +02:00
2021-09-03 09:58:12 -07:00
2022-12-31 13:14:24 +01:00
2023-02-01 08:27:22 +01:00
2021-08-16 14:42:22 +02:00
2023-03-10 09:39:09 +01:00
2021-08-10 12:53:07 +02:00
2022-08-17 14:24:04 +02:00
2022-06-09 10:22:29 +02:00
2020-10-16 11:11:19 -07:00
2021-06-21 13:08:36 +01:00
2020-07-27 14:31:12 -04:00
2022-12-31 13:14:05 +01:00
2020-11-25 18:52:35 +01:00
2023-03-10 09:40:08 +01:00
2022-04-08 14:23:10 +02:00
2022-06-09 10:22:46 +02:00
2021-11-18 19:16:29 +01:00
2022-02-16 12:56:38 +01:00
2022-07-21 21:24:42 +02:00
2022-08-17 14:24:24 +02:00
2021-08-10 14:57:42 +02:00
2021-08-10 22:50:07 +02:00
2022-02-23 12:03:07 +01:00
2022-04-13 20:59:28 +02:00
2022-04-13 20:59:28 +02:00
2022-04-13 20:59:28 +02:00
2021-03-23 16:01:58 +01:00
2022-08-31 17:16:33 +02:00
2023-01-24 07:22:44 +01:00
2021-06-23 16:41:24 -06:00
2023-02-01 08:27:20 +01:00
2021-04-30 11:20:42 -07:00
2020-11-16 08:08:54 -08:00
2019-05-21 11:52:39 +02:00
2021-08-10 10:48:07 -07:00
2021-08-16 11:39:51 -04:00
2022-01-27 11:05:35 +01:00
2022-02-23 12:03:20 +01:00
2021-05-07 00:26:34 -07:00
2021-05-09 13:07:03 -07:00
2022-03-08 19:12:42 +01:00
2019-05-21 10:50:45 +02:00
2021-09-08 11:50:27 -07:00
2021-07-03 11:41:14 -07:00
2020-04-27 02:07:40 -04:00
2020-08-19 14:13:20 +02:00
2023-03-17 08:48:59 +01:00
2022-08-25 11:40:43 +02:00
2021-08-17 07:49:10 -10:00
2022-09-28 11:11:56 +02:00