Message ID | 20210307120948.61414-1-tallossos@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 769c18b254ca191b45047e1fcb3b2ce56fada0b6 |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next,v2] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF. | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 7 maintainers not CCed: netdev@vger.kernel.org daniel@iogearbox.net andrii@kernel.org kafai@fb.com ast@kernel.org john.fastabend@gmail.com songliubraving@fb.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 1 this patch: 1 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 8 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 1 this patch: 1 |
netdev/header_inline | success | Link |
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>
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>
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
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);
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(-)