linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpf: put file handler if no storage found
@ 2021-01-21  2:08 Pan Bian
  2021-01-22 22:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 4+ messages in thread
From: Pan Bian @ 2021-01-21  2:08 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh
  Cc: netdev, bpf, linux-kernel, Pan Bian

Put file f if inode_storage_ptr() returns NULL.

Fixes: 8ea636848aca ("bpf: Implement bpf_local_storage for inodes")
Acked-by: KP Singh <kpsingh@kernel.org>
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 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;
+	}
 
 	sdata = bpf_local_storage_update(f->f_inode,
 					 (struct bpf_local_storage_map *)map,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] bpf: put file handler if no storage found
  2021-01-21  2:08 [PATCH] bpf: put file handler if no storage found Pan Bian
@ 2021-01-22 22:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-01-22 22:20 UTC (permalink / raw)
  To: Pan Bian
  Cc: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, netdev, bpf, linux-kernel

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

On Wed, 20 Jan 2021 18:08:56 -0800 you wrote:
> Put file f if inode_storage_ptr() returns NULL.
> 
> Fixes: 8ea636848aca ("bpf: Implement bpf_local_storage for inodes")
> Acked-by: KP Singh <kpsingh@kernel.org>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
>  kernel/bpf/bpf_inode_storage.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Here is the summary with links:
  - bpf: put file handler if no storage found
    https://git.kernel.org/bpf/bpf/c/524db191d2f5

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bpf: put file handler if no storage found
  2021-01-20 19:23 ` Alexei Starovoitov
@ 2021-01-20 21:10   ` KP Singh
  0 siblings, 0 replies; 4+ messages in thread
From: KP Singh @ 2021-01-20 21:10 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Pan Bian, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	Network Development, bpf, LKML

On Wed, Jan 20, 2021 at 8:23 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Tue, Jan 19, 2021 at 4:03 AM Pan Bian <bianpan2016@163.com> wrote:
> >
> > Put file f if inode_storage_ptr() returns NULL.
> >
> > Signed-off-by: Pan Bian <bianpan2016@163.com>

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>

> > ---
> >  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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bpf: put file handler if no storage found
       [not found] <20210119114624.60400-1-bianpan2016@163.com>
@ 2021-01-20 19:23 ` Alexei Starovoitov
  2021-01-20 21:10   ` KP Singh
  0 siblings, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2021-01-20 19:23 UTC (permalink / raw)
  To: Pan Bian
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Network Development, bpf, LKML

On Tue, Jan 19, 2021 at 4:03 AM Pan Bian <bianpan2016@163.com> wrote:
>
> Put file f if inode_storage_ptr() returns NULL.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
>  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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-22 22:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21  2:08 [PATCH] bpf: put file handler if no storage found Pan Bian
2021-01-22 22:20 ` patchwork-bot+netdevbpf
     [not found] <20210119114624.60400-1-bianpan2016@163.com>
2021-01-20 19:23 ` Alexei Starovoitov
2021-01-20 21:10   ` KP Singh

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