linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] debugfs: only accept read attributes for blobs
@ 2021-05-04 12:17 Wolfram Sang
  2021-05-04 12:59 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2021-05-04 12:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-renesas-soc, Wolfram Sang, Greg Kroah-Hartman, Rafael J. Wysocki

Blobs can only be read. So, keep only 'read' file attributes because the
others will not work and only confuse users.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

I was confused for a second, thinking blobs can be written to. I will
fix the few in-kernel users doing it wrong seperately.

 fs/debugfs/file.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 686e0ad28788..d6aa6e04b7af 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -890,7 +890,8 @@ static const struct file_operations fops_blob = {
 /**
  * debugfs_create_blob - create a debugfs file that is used to read a binary blob
  * @name: a pointer to a string containing the name of the file to create.
- * @mode: the permission that the file should have
+ * @mode: the read permission that the file should have (other permissions are
+ * 	  masked out)
  * @parent: a pointer to the parent dentry for this file.  This should be a
  *          directory dentry if set.  If this parameter is %NULL, then the
  *          file will be created in the root of the debugfs filesystem.
@@ -914,7 +915,7 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode,
 				   struct dentry *parent,
 				   struct debugfs_blob_wrapper *blob)
 {
-	return debugfs_create_file_unsafe(name, mode, parent, blob, &fops_blob);
+	return debugfs_create_file_unsafe(name, mode & S_IRUGO, parent, blob, &fops_blob);
 }
 EXPORT_SYMBOL_GPL(debugfs_create_blob);
 
-- 
2.30.0


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

* Re: [PATCH] debugfs: only accept read attributes for blobs
  2021-05-04 12:17 [PATCH] debugfs: only accept read attributes for blobs Wolfram Sang
@ 2021-05-04 12:59 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2021-05-04 12:59 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-kernel, linux-renesas-soc, Rafael J. Wysocki

On Tue, May 04, 2021 at 02:17:20PM +0200, Wolfram Sang wrote:
> Blobs can only be read. So, keep only 'read' file attributes because the
> others will not work and only confuse users.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> I was confused for a second, thinking blobs can be written to. I will
> fix the few in-kernel users doing it wrong seperately.
> 
>  fs/debugfs/file.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
> index 686e0ad28788..d6aa6e04b7af 100644
> --- a/fs/debugfs/file.c
> +++ b/fs/debugfs/file.c
> @@ -890,7 +890,8 @@ static const struct file_operations fops_blob = {
>  /**
>   * debugfs_create_blob - create a debugfs file that is used to read a binary blob
>   * @name: a pointer to a string containing the name of the file to create.
> - * @mode: the permission that the file should have
> + * @mode: the read permission that the file should have (other permissions are
> + * 	  masked out)
>   * @parent: a pointer to the parent dentry for this file.  This should be a
>   *          directory dentry if set.  If this parameter is %NULL, then the
>   *          file will be created in the root of the debugfs filesystem.
> @@ -914,7 +915,7 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode,
>  				   struct dentry *parent,
>  				   struct debugfs_blob_wrapper *blob)
>  {
> -	return debugfs_create_file_unsafe(name, mode, parent, blob, &fops_blob);
> +	return debugfs_create_file_unsafe(name, mode & S_IRUGO, parent, blob, &fops_blob);

Can you use an octal number for this?  I think checkpatch.pl will
complain here.

thanks,

greg k-h

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

end of thread, other threads:[~2021-05-04 13:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04 12:17 [PATCH] debugfs: only accept read attributes for blobs Wolfram Sang
2021-05-04 12:59 ` Greg Kroah-Hartman

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