[RFC,44/62] bpf: switch to ->free_inode()
diff mbox series

Message ID 20190416175340.21068-44-viro@ZenIV.linux.org.uk
State New
Headers show
Series
  • [RFC,01/62] securityfs: fix use-after-free on symlink traversal
Related show

Commit Message

Al Viro April 16, 2019, 5:53 p.m. UTC
From: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 kernel/bpf/inode.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Comments

Alexei Starovoitov April 16, 2019, 6:07 p.m. UTC | #1
On Tue, Apr 16, 2019 at 10:55 AM Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> From: Al Viro <viro@zeniv.linux.org.uk>
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Acked-by: Alexei Starovoitov <ast@kernel.org>

> ---
>  kernel/bpf/inode.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
> index 4a8f390a2b82..bc53e5b20ddc 100644
> --- a/kernel/bpf/inode.c
> +++ b/kernel/bpf/inode.c
> @@ -566,9 +566,8 @@ static int bpf_show_options(struct seq_file *m, struct dentry *root)
>         return 0;
>  }
>
> -static void bpf_destroy_inode_deferred(struct rcu_head *head)
> +static void bpf_free_inode(struct inode *inode)
>  {
> -       struct inode *inode = container_of(head, struct inode, i_rcu);
>         enum bpf_type type;
>
>         if (S_ISLNK(inode->i_mode))
> @@ -578,16 +577,11 @@ static void bpf_destroy_inode_deferred(struct rcu_head *head)
>         free_inode_nonrcu(inode);
>  }
>
> -static void bpf_destroy_inode(struct inode *inode)
> -{
> -       call_rcu(&inode->i_rcu, bpf_destroy_inode_deferred);
> -}
> -
>  static const struct super_operations bpf_super_ops = {
>         .statfs         = simple_statfs,
>         .drop_inode     = generic_delete_inode,
>         .show_options   = bpf_show_options,
> -       .destroy_inode  = bpf_destroy_inode,
> +       .free_inode     = bpf_free_inode,
>  };
>
>  enum {
> --
> 2.11.0
>
Song Liu April 16, 2019, 9:34 p.m. UTC | #2
On Tue, Apr 16, 2019 at 11:07 AM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Tue, Apr 16, 2019 at 10:55 AM Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > From: Al Viro <viro@zeniv.linux.org.uk>
> >
> > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
>
> Acked-by: Alexei Starovoitov <ast@kernel.org>

Acked-by: Song Liu <songliubraving@fb.com>

>
> > ---
> >  kernel/bpf/inode.c | 10 ++--------
> >  1 file changed, 2 insertions(+), 8 deletions(-)
> >
> > diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
> > index 4a8f390a2b82..bc53e5b20ddc 100644
> > --- a/kernel/bpf/inode.c
> > +++ b/kernel/bpf/inode.c
> > @@ -566,9 +566,8 @@ static int bpf_show_options(struct seq_file *m, struct dentry *root)
> >         return 0;
> >  }
> >
> > -static void bpf_destroy_inode_deferred(struct rcu_head *head)
> > +static void bpf_free_inode(struct inode *inode)
> >  {
> > -       struct inode *inode = container_of(head, struct inode, i_rcu);
> >         enum bpf_type type;
> >
> >         if (S_ISLNK(inode->i_mode))
> > @@ -578,16 +577,11 @@ static void bpf_destroy_inode_deferred(struct rcu_head *head)
> >         free_inode_nonrcu(inode);
> >  }
> >
> > -static void bpf_destroy_inode(struct inode *inode)
> > -{
> > -       call_rcu(&inode->i_rcu, bpf_destroy_inode_deferred);
> > -}
> > -
> >  static const struct super_operations bpf_super_ops = {
> >         .statfs         = simple_statfs,
> >         .drop_inode     = generic_delete_inode,
> >         .show_options   = bpf_show_options,
> > -       .destroy_inode  = bpf_destroy_inode,
> > +       .free_inode     = bpf_free_inode,
> >  };
> >
> >  enum {
> > --
> > 2.11.0
> >

Patch
diff mbox series

diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 4a8f390a2b82..bc53e5b20ddc 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -566,9 +566,8 @@  static int bpf_show_options(struct seq_file *m, struct dentry *root)
 	return 0;
 }
 
-static void bpf_destroy_inode_deferred(struct rcu_head *head)
+static void bpf_free_inode(struct inode *inode)
 {
-	struct inode *inode = container_of(head, struct inode, i_rcu);
 	enum bpf_type type;
 
 	if (S_ISLNK(inode->i_mode))
@@ -578,16 +577,11 @@  static void bpf_destroy_inode_deferred(struct rcu_head *head)
 	free_inode_nonrcu(inode);
 }
 
-static void bpf_destroy_inode(struct inode *inode)
-{
-	call_rcu(&inode->i_rcu, bpf_destroy_inode_deferred);
-}
-
 static const struct super_operations bpf_super_ops = {
 	.statfs		= simple_statfs,
 	.drop_inode	= generic_delete_inode,
 	.show_options	= bpf_show_options,
-	.destroy_inode	= bpf_destroy_inode,
+	.free_inode	= bpf_free_inode,
 };
 
 enum {