2018-07-24 20:04:04

by Zubin Mithra

[permalink] [raw]
Subject: [PATCH] tracefs: Annotate tracefs_ops with __ro_after_init

tracefs_ops is initialized inside tracefs_create_instance_dir and not
modified after. tracefs_create_instance_dir allows for initialization
only once, and is called from create_trace_instances(marked __init),
which is called from tracer_init_tracefs(marked __init).

Signed-off-by: Zubin Mithra <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
---
fs/tracefs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index bea8ad876bf9..20e965873f27 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = {
static struct tracefs_dir_ops {
int (*mkdir)(const char *name);
int (*rmdir)(const char *name);
-} tracefs_ops;
+} tracefs_ops __ro_after_init;

static char *get_dname(struct dentry *dentry)
{
--
2.18.0.233.g985f88cf7e-goog



2018-07-24 22:08:28

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] tracefs: Annotate tracefs_ops with __ro_after_init

Adding Steven (maintainer) and Al (fs) to CC...

On Tue, Jul 24, 2018 at 1:02 PM, Zubin Mithra <[email protected]> wrote:
> tracefs_ops is initialized inside tracefs_create_instance_dir and not
> modified after. tracefs_create_instance_dir allows for initialization
> only once, and is called from create_trace_instances(marked __init),
> which is called from tracer_init_tracefs(marked __init).
>
> Signed-off-by: Zubin Mithra <[email protected]>
> Reviewed-by: Kees Cook <[email protected]>

Who's tree should this go through?

Thanks!

-Kees

> ---
> fs/tracefs/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> index bea8ad876bf9..20e965873f27 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = {
> static struct tracefs_dir_ops {
> int (*mkdir)(const char *name);
> int (*rmdir)(const char *name);
> -} tracefs_ops;
> +} tracefs_ops __ro_after_init;
>
> static char *get_dname(struct dentry *dentry)
> {
> --
> 2.18.0.233.g985f88cf7e-goog
>



--
Kees Cook
Pixel Security

2018-07-24 22:40:47

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] tracefs: Annotate tracefs_ops with __ro_after_init

On Tue, 24 Jul 2018 15:07:18 -0700
Kees Cook <[email protected]> wrote:

> Adding Steven (maintainer) and Al (fs) to CC...

Thanks, first I've seen of this.

>
> On Tue, Jul 24, 2018 at 1:02 PM, Zubin Mithra <[email protected]> wrote:
> > tracefs_ops is initialized inside tracefs_create_instance_dir and not
> > modified after. tracefs_create_instance_dir allows for initialization
> > only once, and is called from create_trace_instances(marked __init),
> > which is called from tracer_init_tracefs(marked __init).

Then, especially with this change, we should mark
tracefs_create_instance_dir() as init, as it would fail any other time.

> >
> > Signed-off-by: Zubin Mithra <[email protected]>
> > Reviewed-by: Kees Cook <[email protected]>
>
> Who's tree should this go through?

I can take it or someone else can, and I'll ack it if need be.

-- Steve


>
> Thanks!
>
> -Kees
>
> > ---
> > fs/tracefs/inode.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> > index bea8ad876bf9..20e965873f27 100644
> > --- a/fs/tracefs/inode.c
> > +++ b/fs/tracefs/inode.c
> > @@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = {
> > static struct tracefs_dir_ops {
> > int (*mkdir)(const char *name);
> > int (*rmdir)(const char *name);
> > -} tracefs_ops;
> > +} tracefs_ops __ro_after_init;
> >
> > static char *get_dname(struct dentry *dentry)
> > {
> > --
> > 2.18.0.233.g985f88cf7e-goog
> >
>
>
>