From: "Thomas Weißschuh " <thomas@t-8ch.de>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: "Thomas Weißschuh" <linux@weissschuh.net>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Marco Felsch" <m.felsch@pengutronix.de>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] nvmem: core: limit cell sysfs permissions to main attribute ones
Date: Sat, 22 Jun 2024 12:38:34 +0200 (GMT+02:00) [thread overview]
Message-ID: <8d8387d3-e0a2-4fc7-ab46-d099c43935f0@t-8ch.de> (raw)
In-Reply-To: <9af37f6c-cd44-4a57-8a34-969e23b0342f@linaro.org>
Jun 22, 2024 12:11:04 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>:
>
>
> On 19/06/2024 19:09, Thomas Weißschuh wrote:
>> The cell sysfs attribute should not provide more access to the nvmem
>> data than the main attribute itself.
>> For example if nvme_config::root_only was set, the cell attribute
>> would still provide read access to everybody.
>> Mask out permissions not available on the main attribute.
>> Fixes: 0331c611949f ("nvmem: core: Expose cells through sysfs")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
>> ---
>> This was also discussed as part of
>> "[PATCH] nvmem: core: add sysfs cell write support" [0].
>> But there haven't been updates to that patch and this is arguably a
>> standalone bugfix.
>> [0] https://lore.kernel.org/lkml/20240223154129.1902905-1-m.felsch@pengutronix.de/
>> ---
>> drivers/nvmem/core.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
>> index e1ec3b7200d7..acfea1e56849 100644
>> --- a/drivers/nvmem/core.c
>> +++ b/drivers/nvmem/core.c
>> @@ -463,7 +463,7 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem)
>> "%s@%x,%x", entry->name,
>> entry->offset,
>> entry->bit_offset);
>> - attrs[i].attr.mode = 0444;
>> + attrs[i].attr.mode = 0444 & nvmem_bin_attr_get_umode(nvmem);
> Why not just
> attrs[i].attr.mode = nvmem_bin_attr_get_umode(nvmem);
Because nvmem_bin_attr_get_umode() will include write permissions
if the base nvmem device is writable.
But (for now) the cell sysfs attributes do not implement writes.
> ?
>
> --srini
>> attrs[i].size = entry->bytes;
>> attrs[i].read = &nvmem_cell_attr_read;
>> attrs[i].private = entry;
>> ---
>> base-commit: 92e5605a199efbaee59fb19e15d6cc2103a04ec2
>> change-id: 20240619-nvmem-cell-sysfs-perm-156fde0d7460
>> Best regards,
next prev parent reply other threads:[~2024-06-22 10:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 18:09 [PATCH] nvmem: core: limit cell sysfs permissions to main attribute ones Thomas Weißschuh
2024-06-22 10:10 ` Srinivas Kandagatla
2024-06-22 10:38 ` Thomas Weißschuh [this message]
2024-06-22 10:55 ` Srinivas Kandagatla
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=8d8387d3-e0a2-4fc7-ab46-d099c43935f0@t-8ch.de \
--to=thomas@t-8ch.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=m.felsch@pengutronix.de \
--cc=miquel.raynal@bootlin.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=stable@vger.kernel.org \
/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