bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF
authorTal Lossos <tallossos@gmail.com>
Sun, 7 Mar 2021 12:09:48 +0000 (14:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 Mar 2021 12:31:56 +0000 (14:31 +0200)
commitf7c3d7615e6c62d13e2b56b9eaf029f682e44cf8
treecebe7b34a8572d9470f1ace0bc7815310f87200e
parent926cde9eec67cf3fe29cd68aaf4b759455c29046
bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF

[ Upstream commit 769c18b254ca191b45047e1fcb3b2ce56fada0b6 ]

bpf_fd_inode_storage_lookup_elem() returned NULL when getting a bad FD,
which caused -ENOENT in bpf_map_copy_value. -EBADF error is better than
-ENOENT for a bad FD behaviour.

The patch was partially contributed by CyberArk Software, Inc.

Fixes: 8ea636848aca ("bpf: Implement bpf_local_storage for inodes")
Signed-off-by: Tal Lossos <tallossos@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: KP Singh <kpsingh@kernel.org>
Link: https://lore.kernel.org/bpf/20210307120948.61414-1-tallossos@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/bpf_inode_storage.c