Re: [PATCH 2/2] debugfs: only allow root access to debugginginterfaces

From: Henrique de Moraes Holschuh
Date: Tue Feb 22 2011 - 15:59:07 EST


On Tue, 22 Feb 2011, Dan Carpenter wrote:
> On Tue, Feb 22, 2011 at 11:33:14AM -0800, Greg KH wrote:
> > Again, let's fix the real problems here, world-writable debugfs files.
>
> We could just ban them?

Eh, if you're serious, maybe add an WARN_ONCE so that the source of the
unwanted DAC bits gets cleaned up?

I do wish this went in. debugfs is a hazard, both security-wise and
kernel-quality wise. Anything that has to end up enabled in a distro
kernel really does not belong in debugfs. In fact, if you would object
to a kernel taint if a feature is used, IMO it certainly don't belong on
debugfs.

> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
> index e7a7a2f..03ae095 100644
> --- a/fs/debugfs/inode.c
> +++ b/fs/debugfs/inode.c
> @@ -223,6 +223,9 @@ struct dentry *debugfs_create_file(const char *name, mode_t mode,
>
> pr_debug("debugfs: creating file '%s'\n",name);
>
> + /* don't allow world writable files */
> + mode &= ~S_IWOTH;
> +
> error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
> &debugfs_mount_count);
> if (error)
>
>

--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/