bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 v2] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF.
Date: Sun,  7 Mar 2021 14:09:48 +0200	[thread overview]
Message-ID: <20210307120948.61414-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..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


             reply	other threads:[~2021-03-07 12:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-07 12:09 Tal Lossos [this message]
2021-03-07 18:18 ` [PATCH bpf-next v2] bpf: Change inode_storage's lookup_elem return value from NULL to -EBADF Yonghong Song
2021-03-08 15:07   ` KP Singh
2021-03-08 16:00 ` patchwork-bot+netdevbpf

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=20210307120948.61414-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 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).