2021-04-06 10:29:10

by Kees Cook

[permalink] [raw]
Subject: [PATCH] debugfs: Make debugfs_allow RO after init

Since debugfs_allow is only set at boot time during __init, make it
read-only after being set.

Cc: Peter Enderborg <[email protected]>
Fixes: a24c6f7bc923 ("debugfs: Add access restriction option")
Signed-off-by: Kees Cook <[email protected]>
---
fs/debugfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 22e86ae4dd5a..1d252164d97b 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -35,7 +35,7 @@
static struct vfsmount *debugfs_mount;
static int debugfs_mount_count;
static bool debugfs_registered;
-static unsigned int debugfs_allow = DEFAULT_DEBUGFS_ALLOW_BITS;
+static unsigned int debugfs_allow __ro_after_init = DEFAULT_DEBUGFS_ALLOW_BITS;

/*
* Don't allow access attributes to be changed whilst the kernel is locked down
--
2.25.1


2021-04-06 16:03:14

by peter enderborg

[permalink] [raw]
Subject: Re: [PATCH] debugfs: Make debugfs_allow RO after init

On 4/5/21 11:39 PM, Kees Cook wrote:
> Since debugfs_allow is only set at boot time during __init, make it
> read-only after being set.
>
> Cc: Peter Enderborg <[email protected]>
> Fixes: a24c6f7bc923 ("debugfs: Add access restriction option")
> Signed-off-by: Kees Cook <[email protected]>
> ---
> fs/debugfs/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
> index 22e86ae4dd5a..1d252164d97b 100644
> --- a/fs/debugfs/inode.c
> +++ b/fs/debugfs/inode.c
> @@ -35,7 +35,7 @@
> static struct vfsmount *debugfs_mount;
> static int debugfs_mount_count;
> static bool debugfs_registered;
> -static unsigned int debugfs_allow = DEFAULT_DEBUGFS_ALLOW_BITS;
> +static unsigned int debugfs_allow __ro_after_init = DEFAULT_DEBUGFS_ALLOW_BITS;
>
> /*
> * Don't allow access attributes to be changed whilst the kernel is locked down

Tnx. Looks good to me.

You can add:

Reviewed-by: Peter Enderborg <[email protected]>