Skip to content

Commit

Permalink
nvmem: core: limit cell sysfs permissions to main attribute ones
Browse files Browse the repository at this point in the history
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: 0331c61 ("nvmem: core: Expose cells through sysfs")
Cc: [email protected]
Signed-off-by: Thomas Weißschuh <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
t-8ch authored and gregkh committed Jul 3, 2024
1 parent 0ba424c commit 6bef98b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/nvmem/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,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);
attrs[i].size = entry->bytes;
attrs[i].read = &nvmem_cell_attr_read;
attrs[i].private = entry;
Expand Down

0 comments on commit 6bef98b

Please sign in to comment.