mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] bpf: fix excessively checking for elem_flags in batch update mode
@ 2024-07-17 11:15 Lin Feng
  2024-07-19 16:22 ` Daniel Borkmann
  0 siblings, 1 reply; 5+ messages in thread
From: Lin Feng @ 2024-07-17 11:15 UTC (permalink / raw)
  To: ast, daniel; +Cc: bpf, linux-kernel, yonghong.song

Currently generic_map_update_batch will reject all valid command flags for
BPF_MAP_UPDATE_ELEM other than BPF_F_LOCK, which is overkill, map updating
semantic does allow specify BPF_NOEXIST or BPF_EXIST even for batching
update.

Signed-off-by: Lin Feng <linf@wangsu.com>
---
 kernel/bpf/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 869265852d51..d85361f9a9b8 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1852,7 +1852,7 @@ int generic_map_update_batch(struct bpf_map *map, struct file *map_file,
 	void *key, *value;
 	int err = 0;
 
-	if (attr->batch.elem_flags & ~BPF_F_LOCK)
+	if ((attr->batch.elem_flags & ~BPF_F_LOCK) > BPF_EXIST)
 		return -EINVAL;
 
 	if ((attr->batch.elem_flags & BPF_F_LOCK) &&
-- 
2.42.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-07-23  1:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-17 11:15 [PATCH] bpf: fix excessively checking for elem_flags in batch update mode Lin Feng
2024-07-19 16:22 ` Daniel Borkmann
2024-07-22  1:54   ` Lin Feng
2024-07-23  1:21   ` Hou Tao
2024-07-23  1:44     ` Lin Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®