bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF.
PATCH v2 1/1 bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF.
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.
--- kernel/bpf/bpf_inode_storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/bpf_inode_storage.c +1 -1
@@ -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);
Signature · 1 line
2.27.0
Quoted 7 lines · Tal Lossos
bpf_fd_inode_storage_lookup_elemreturned NULL when getting a bad FD, which caused-ENOENTinbpf_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 <[email protected]>
KP Singh
Acked-byQuoted 8 lines · Yonghong Song
Quoted 4 lines · Tal Lossos
bpf_fd_inode_storage_lookup_elemreturned NULL when getting a bad FD, which caused-ENOENTinbpf_map_copy_value.
EBADF is better than ENOENT for a bad FD behaviour.
Quoted 5 lines
Quoted 3 lines
The patch was partially contributed by CyberArk Software, Inc.
Signed-off-by Tal Lossos <[email protected]>Acked-by Yonghong Song <[email protected]>
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.
This patch was applied to bpf/bpf.git (refs/heads/master):
Hello:
This patch was applied to bpf/bpf.git (refs/heads/master):
Quoted 9 lines · On Sun, 7 Mar 2021 14:09:48 +0200 you wrote:
bpf_fd_inode_storage_lookup_elemreturned NULL when getting a bad FD, which caused-ENOENTinbpf_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 <[email protected]>[...]
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