bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next v2] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF.
@ 2021-03-07 12:09 Tal Lossos
  2021-03-07 18:18 ` Yonghong Song
  2021-03-08 16:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Tal Lossos @ 2021-03-07 12:09 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..2921ca39a93e 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 ERR_PTR(-EBADF);
 
 	sdata = inode_storage_lookup(f->f_inode, map, true);
 	fput(f);
-- 
2.27.0


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

end of thread, other threads:[~2021-03-08 16:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-07 12:09 [PATCH bpf-next v2] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF Tal Lossos
2021-03-07 18:18 ` Yonghong Song
2021-03-08 15:07   ` KP Singh
2021-03-08 16:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).