From: Tal Lossos <tallossos@gmail.com>
To: bpf@vger.kernel.org
Cc: yhs@fb.com, kpsingh@kernel.org, gilad.reti@gmail.com,
Tal Lossos <tallossos@gmail.com>
Subject: [PATCH bpf-next] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF.
Date: Sun, 7 Mar 2021 12:32:24 +0200 [thread overview]
Message-ID: <20210307103224.60366-1-tallossos@gmail.com> (raw)
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
next reply other threads:[~2021-03-07 10:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-07 10:32 Tal Lossos [this message]
2021-03-07 11:53 ` [PATCH bpf-next] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210307103224.60366-1-tallossos@gmail.com \
--to=tallossos@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=gilad.reti@gmail.com \
--cc=kpsingh@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.