All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF.
@ 2021-03-07 10:32 Tal Lossos
  2021-03-07 11:53 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Tal Lossos @ 2021-03-07 10:32 UTC (permalink / raw)
  To: bpf; +Cc: yhs, kpsingh, gilad.reti, Tal Lossos

bpf_fd_inode_storage_lookup_elem returned NULL when getting a bad FD which caused -ENOENT in bpf_map_copy_value.
EBADF is better than ENOENT for a bad FD behaviour.

The patch was partially contributed by CyberArk Software, Inc.

Signed-off-by: Tal Lossos <tallossos@gmail.com>
---
 kernel/bpf/bpf_inode_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/bpf_inode_storage.c b/kernel/bpf/bpf_inode_storage.c
index da753721457c..0ca25e9549d8 100644
--- a/kernel/bpf/bpf_inode_storage.c
+++ b/kernel/bpf/bpf_inode_storage.c
@@ -109,7 +109,7 @@ static void *bpf_fd_inode_storage_lookup_elem(struct bpf_map *map, void *key)
 	fd = *(int *)key;
 	f = fget_raw(fd);
 	if (!f)
-		return NULL;
+		return -EBADF;
 
 	sdata = inode_storage_lookup(f->f_inode, map, true);
 	fput(f);
-- 
2.27.0


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

end of thread, other threads:[~2021-03-07 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-07 10:32 [PATCH bpf-next] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF Tal Lossos
2021-03-07 11:53 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.