* [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
* Re: [PATCH bpf-next v2] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF.
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
1 sibling, 1 reply; 4+ messages in thread
From: Yonghong Song @ 2021-03-07 18:18 UTC (permalink / raw)
To: Tal Lossos, bpf; +Cc: kpsingh, gilad.reti
On 3/7/21 4:09 AM, Tal Lossos wrote:
> 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>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next v2] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF.
2021-03-07 18:18 ` Yonghong Song
@ 2021-03-08 15:07 ` KP Singh
0 siblings, 0 replies; 4+ messages in thread
From: KP Singh @ 2021-03-08 15:07 UTC (permalink / raw)
To: Yonghong Song; +Cc: Tal Lossos, bpf, Gilad Reti
On Sun, Mar 7, 2021 at 7:18 PM Yonghong Song <yhs@fb.com> wrote:
>
>
>
> On 3/7/21 4:09 AM, Tal Lossos wrote:
> > 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>
>
> Acked-by: Yonghong Song <yhs@fb.com>
Thanks this makes sense and is consistent with sk_storage (which
uses sockfd_lookup) and task_storage (which uses pidfd_get_pid)
which return an -EBADF as well.
Acked-by: KP Singh <kpsingh@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next v2] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF.
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 16:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-08 16:00 UTC (permalink / raw)
To: Tal Lossos; +Cc: bpf, yhs, kpsingh, gilad.reti
Hello:
This patch was applied to bpf/bpf.git (refs/heads/master):
On Sun, 7 Mar 2021 14:09:48 +0200 you wrote:
> 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>
>
> [...]
Here is the summary with links:
- [bpf-next,v2] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF.
https://git.kernel.org/bpf/bpf/c/769c18b254ca
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [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).