Re: [PATCH] bpf: put file handler if no storage found

2 messages, 2 authors, 2021-01-20 · open the first message on its own page

Re: [PATCH] bpf: put file handler if no storage found

From: Alexei Starovoitov <hidden>
Date: 2021-01-20 19:27:24

On Tue, Jan 19, 2021 at 4:03 AM Pan Bian [off-list ref] wrote:
quoted hunk
Put file f if inode_storage_ptr() returns NULL.

Signed-off-by: Pan Bian <redacted>
---
 kernel/bpf/bpf_inode_storage.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/bpf_inode_storage.c b/kernel/bpf/bpf_inode_storage.c
index 6edff97ad594..089d5071d4fc 100644
--- a/kernel/bpf/bpf_inode_storage.c
+++ b/kernel/bpf/bpf_inode_storage.c
@@ -125,8 +125,12 @@ static int bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key,

        fd = *(int *)key;
        f = fget_raw(fd);
-       if (!f || !inode_storage_ptr(f->f_inode))
+       if (!f)
+               return -EBADF;
+       if (!inode_storage_ptr(f->f_inode)) {
+               fput(f);
                return -EBADF;
+       }
Good catch.
Somehow the patch is not in patchwork.
Could you please resubmit with Fixes tag and reduce cc list?
I guess it's hitting some spam filters in vger.

Re: [PATCH] bpf: put file handler if no storage found

From: KP Singh <kpsingh@kernel.org>
Date: 2021-01-20 21:36:35

On Wed, Jan 20, 2021 at 8:23 PM Alexei Starovoitov
[off-list ref] wrote:
On Tue, Jan 19, 2021 at 4:03 AM Pan Bian [off-list ref] wrote:
quoted
Put file f if inode_storage_ptr() returns NULL.

Signed-off-by: Pan Bian <redacted>
Thanks for fixing this! (You can add my ack with the fixes tag when
you resubmit)

Fixes: 8ea636848aca ("bpf: Implement bpf_local_storage for inodes")
Acked-by: KP Singh <kpsingh@kernel.org>
quoted
---
 kernel/bpf/bpf_inode_storage.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/bpf_inode_storage.c b/kernel/bpf/bpf_inode_storage.c
index 6edff97ad594..089d5071d4fc 100644
--- a/kernel/bpf/bpf_inode_storage.c
+++ b/kernel/bpf/bpf_inode_storage.c
@@ -125,8 +125,12 @@ static int bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key,

        fd = *(int *)key;
        f = fget_raw(fd);
-       if (!f || !inode_storage_ptr(f->f_inode))
+       if (!f)
+               return -EBADF;
+       if (!inode_storage_ptr(f->f_inode)) {
+               fput(f);
                return -EBADF;
+       }
Good catch.
Somehow the patch is not in patchwork.
Could you please resubmit with Fixes tag and reduce cc list?
I guess it's hitting some spam filters in vger.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help