88453e83cca726ab2f3aab565cd60e6fe4b1adc2
[openwrt/staging/xback.git] /
1 From 6bef98bafd82903a8d461463f9594f19f1fd6a85 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <linux@weissschuh.net>
3 Date: Fri, 28 Jun 2024 12:37:04 +0100
4 Subject: [PATCH] nvmem: core: limit cell sysfs permissions to main attribute
5 ones
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 The cell sysfs attribute should not provide more access to the nvmem
11 data than the main attribute itself.
12 For example if nvme_config::root_only was set, the cell attribute
13 would still provide read access to everybody.
14
15 Mask out permissions not available on the main attribute.
16
17 Fixes: 0331c611949f ("nvmem: core: Expose cells through sysfs")
18 Cc: stable@vger.kernel.org
19 Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
20 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
21 Link: https://lore.kernel.org/r/20240628113704.13742-5-srinivas.kandagatla@linaro.org
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 ---
24 drivers/nvmem/core.c | 2 +-
25 1 file changed, 1 insertion(+), 1 deletion(-)
26
27 --- a/drivers/nvmem/core.c
28 +++ b/drivers/nvmem/core.c
29 @@ -462,7 +462,7 @@ static int nvmem_populate_sysfs_cells(st
30 attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL,
31 "%s@%x", entry->name,
32 entry->offset);
33 - attrs[i].attr.mode = 0444;
34 + attrs[i].attr.mode = 0444 & nvmem_bin_attr_get_umode(nvmem);
35 attrs[i].size = entry->bytes;
36 attrs[i].read = &nvmem_cell_attr_read;
37 attrs[i].private = entry;