Files
linux/include/linux
Hou Tao 3af43ba4c6 bpf: Pass map file to .map_update_batch directly
Currently bpf_map_do_batch() first invokes fdget(batch.map_fd) to get
the target map file, then it invokes generic_map_update_batch() to do
batch update. generic_map_update_batch() will get the target map file
by using fdget(batch.map_fd) again and pass it to bpf_map_update_value().

The problem is map file returned by the second fdget() may be NULL or a
totally different file compared by map file in bpf_map_do_batch(). The
reason is that the first fdget() only guarantees the liveness of struct
file instead of file descriptor and the file description may be released
by concurrent close() through pick_file().

It doesn't incur any problem as for now, because maps with batch update
support don't use map file in .map_fd_get_ptr() ops. But it is better to
fix the potential access of an invalid map file.

Using __bpf_map_get() again in generic_map_update_batch() can not fix
the problem, because batch.map_fd may be closed and reopened, and the
returned map file may be different with map file got in
bpf_map_do_batch(), so just passing the map file directly to
.map_update_batch() in bpf_map_do_batch().

Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20221116075059.1551277-1-houtao@huaweicloud.com
2022-11-17 17:12:35 +01:00
..
2022-10-27 13:23:43 +02:00
2022-11-07 14:00:27 +01:00
2022-05-22 20:44:29 +01:00
2022-03-23 19:58:38 +01:00
2022-07-05 20:25:39 +02:00
2022-09-21 11:18:28 +09:00
2022-09-26 12:19:12 -07:00
2022-11-03 23:09:40 -07:00
2022-09-26 19:46:29 -07:00
2022-09-26 10:13:13 -07:00
2022-09-26 10:13:13 -07:00
2022-09-15 09:32:06 -07:00
2022-09-26 10:13:14 -07:00
2022-03-15 10:32:44 +01:00
2022-06-28 10:37:25 -03:00
2022-07-01 14:53:01 +02:00
2022-10-17 13:49:45 +02:00
2022-08-31 14:57:28 +01:00
2022-10-03 14:02:45 -07:00
2022-08-16 12:46:26 +02:00
2022-06-09 21:53:09 -07:00
2022-06-09 21:53:12 -07:00
2022-11-11 18:18:05 -08:00
2022-02-28 23:26:27 -08:00
2022-09-01 18:04:43 +02:00
2022-06-27 06:29:12 -06:00
2022-09-08 12:59:00 -06:00
2022-09-26 13:31:20 +02:00
2022-09-01 18:08:44 +02:00
2022-07-17 17:31:38 -07:00
2022-10-03 14:03:19 -07:00
2022-05-02 14:06:20 -06:00
2022-05-03 16:09:03 -04:00
2022-11-09 19:28:49 -08:00
2022-06-19 10:38:26 +01:00
2022-07-27 14:04:52 +02:00
2022-09-26 19:46:18 -07:00
2022-10-03 14:03:19 -07:00
2022-04-28 23:16:14 -07:00
2022-08-02 12:34:04 -04:00
2022-09-01 17:39:49 -04:00
2022-08-22 14:26:30 +01:00
2022-05-17 13:32:46 -04:00
2022-08-09 14:11:34 -04:00
2022-07-29 20:16:58 -04:00
2022-10-03 17:34:32 -07:00
2022-09-26 19:46:27 -07:00
2022-09-26 19:46:09 -07:00
2022-07-01 16:38:35 -06:00
2022-10-17 16:32:05 +02:00
2022-10-04 20:52:38 +02:00
2022-10-11 17:42:58 -06:00
2022-09-19 06:17:05 -07:00
2022-10-11 17:42:58 -06:00
2022-03-08 14:33:36 -06:00
2022-03-17 20:16:29 -07:00
2022-03-23 19:58:41 +01:00
2022-05-22 21:03:01 +01:00
2022-04-07 12:53:54 +02:00
2022-06-27 14:41:31 +02:00
2022-02-24 15:04:51 +00:00
2022-11-11 18:18:05 -08:00
2022-05-08 01:33:08 -07:00
2022-09-07 12:42:25 +01:00
2022-02-25 09:36:06 +01:00
2022-09-29 15:20:29 +02:00
2022-04-11 19:18:27 -06:00
2022-03-22 15:57:11 -07:00
2022-09-22 16:12:34 +02:00
2022-09-22 16:12:34 +02:00
2022-08-31 13:37:32 +02:00
2022-09-16 10:56:08 +01:00
2022-08-28 16:52:28 +01:00
2022-10-07 09:32:40 -04:00
2022-10-07 08:10:52 -06:00
2022-09-26 19:46:18 -07:00
2022-06-13 09:54:52 -07:00
2022-09-26 19:46:18 -07:00
2022-09-28 10:00:16 +02:00
2022-07-10 21:17:30 -04:00