linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avadhut Naik <avadnaik@amd.com>
To: Greg KH <gregkh@linuxfoundation.org>, Alexey Kardashevskiy <aik@amd.com>
Cc: Avadhut Naik <Avadhut.Naik@amd.com>,
	rafael@kernel.org, lenb@kernel.org, linux-acpi@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, yazen.ghannam@amd.com,
	alexey.kardashevskiy@amd.com, linux-kernel@vger.kernel.org
Subject: [RFC PATCH v3 2/3] fs: debugfs: Add write functionality to debugfs blobs
Date: Tue, 13 Jun 2023 17:35:11 -0500	[thread overview]
Message-ID: <417346e2-09cc-3b33-e4cf-57d00a8edbbe@amd.com> (raw)
In-Reply-To: <2023061329-splinter-rundown-a61a@gregkh>

Hi,

	Thanks for reviewing!	

On 6/13/2023 05:22, Greg KH wrote:
> On Tue, Jun 13, 2023 at 08:05:41PM +1000, Alexey Kardashevskiy wrote:
>>
>>
>> On 13/6/23 17:59, Greg KH wrote:
>>> On Mon, Jun 12, 2023 at 09:51:38PM +0000, Avadhut Naik wrote:
>>>>   /**
>>>> - * debugfs_create_blob - create a debugfs file that is used to read a binary blob
>>>> + * debugfs_create_blob - create a debugfs file that is used to read and write
>>>> + * a binary blob
>>>>    * @name: a pointer to a string containing the name of the file to create.
>>>> - * @mode: the read permission that the file should have (other permissions are
>>>> - *	  masked out)
>>>> + * @mode: the permission that the file should have
>>>>    * @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.
>>>> @@ -992,7 +1010,7 @@ static const struct file_operations fops_blob = {
>>>>    *
>>>>    * This function creates a file in debugfs with the given name that exports
>>>>    * @blob->data as a binary blob. If the @mode variable is so set it can be
>>>> - * read from. Writing is not supported.
>>>> + * read from and written to.
>>>>    *
>>>>    * This function will return a pointer to a dentry if it succeeds.  This
>>>>    * pointer must be passed to the debugfs_remove() function when the file is
>>>> @@ -1007,7 +1025,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 & 0444, parent, blob, &fops_blob);
>>>> +	return debugfs_create_file_unsafe(name, mode, parent, blob, &fops_blob);
>>>
>>> Have you audited all calls to this function to verify that you haven't
>>> just turned on write access to some debugfs files?
>>
>> I just did, it is one of S_IRUGO/S_IRUSR/0444/0400/(S_IFREG | 0444). So we
>> are quite safe here. Except (S_IFREG | 0444) in
>> drivers/platform/chrome/cros_ec_debugfs.c which seems wrong as debugfs files
>> are not regular files.
>>
>>> Why not rename this to debugfs_create_blob_wo() and then make a new
>>> debugfs_create_blob_rw() call to ensure that it all is ok?
>>
>> It is already taking the mode for this purpose. imho just
>> cros_ec_create_panicinfo()'s debugfs_create_blob("panicinfo", S_IFREG |
>> 0444,...) needs fixing.
> 
> Yes, well it's taking the mode, but silently modifying it :)
> 
> Ok, thanks for the audit, respin this with that fix and then I don't
> have a problem with it (other than binary debugfs files fill me with
> dread, what could go wrong...)
> 
	Will add the fix for cros_ec_create_panicinfo()'s debugfs_create_blob()
usage.

Thanks,
Avadhut Naik

> thanks,
> 
> greg k-h

-- 

  reply	other threads:[~2023-06-13 22:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 21:51 [RFC PATCH v3 0/3] Add support for Vendor Defined Error Types in Einj Module Avadhut Naik
2023-06-12 21:51 ` [RFC PATCH v3 1/3] ACPI: APEI: EINJ: Refactor available_error_type_show() Avadhut Naik
2023-06-12 21:51 ` [RFC PATCH v3 2/3] fs: debugfs: Add write functionality to debugfs blobs Avadhut Naik
2023-06-13  7:59   ` Greg KH
2023-06-13 10:05     ` Alexey Kardashevskiy
2023-06-13 10:22       ` Greg KH
2023-06-13 22:35         ` Avadhut Naik [this message]
2023-06-12 21:51 ` [RFC PATCH v3 3/3] ACPI: APEI: EINJ: Add support for vendor defined error types Avadhut Naik
2023-06-13  8:01 ` [RFC PATCH v3 0/3] Add support for Vendor Defined Error Types in Einj Module Greg KH
2023-06-13 22:34   ` Avadhut Naik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=417346e2-09cc-3b33-e4cf-57d00a8edbbe@amd.com \
    --to=avadnaik@amd.com \
    --cc=Avadhut.Naik@amd.com \
    --cc=aik@amd.com \
    --cc=alexey.kardashevskiy@amd.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=yazen.ghannam@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).