summaryrefslogtreecommitdiff
path: root/arch/powerpc/kernel/secvar-sysfs.c
diff options
context:
space:
mode:
authorAndrew Donnellan <ajd@linux.ibm.com>2023-02-10 19:03:47 +1100
committerMichael Ellerman <mpe@ellerman.id.au>2023-02-12 22:12:37 +1100
commit6d64c497a31bd888110785def44529ebb96bce49 (patch)
tree2d1ff52bfcfa5a284095d63d4f52972259f20b24 /arch/powerpc/kernel/secvar-sysfs.c
parent50a466bf3e6f6f177dc0aeefa46a2f8927075a1d (diff)
powerpc/secvar: Warn when PAGE_SIZE is smaller than max object size
Due to sysfs constraints, when writing to a variable, we can only handle writes of up to PAGE_SIZE. It's possible that the maximum object size is larger than PAGE_SIZE, in which case, print a warning on boot so that the user is aware. Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Signed-off-by: Russell Currey <ruscur@russell.cc> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20230210080401.345462-13-ajd@linux.ibm.com
Diffstat (limited to 'arch/powerpc/kernel/secvar-sysfs.c')
-rw-r--r--arch/powerpc/kernel/secvar-sysfs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secvar-sysfs.c
index bfb19f22c6ba..6ba23b2bb9da 100644
--- a/arch/powerpc/kernel/secvar-sysfs.c
+++ b/arch/powerpc/kernel/secvar-sysfs.c
@@ -225,6 +225,7 @@ static int secvar_sysfs_load_static(void)
static int secvar_sysfs_init(void)
{
+ u64 max_size;
int rc;
if (!secvar_ops) {
@@ -274,6 +275,14 @@ static int secvar_sysfs_init(void)
goto err;
}
+ // Due to sysfs limitations, we will only ever get a write buffer of
+ // up to 1 page in size. Print a warning if this is potentially going
+ // to cause problems, so that the user is aware.
+ secvar_ops->max_size(&max_size);
+ if (max_size > PAGE_SIZE)
+ pr_warn_ratelimited("PAGE_SIZE (%lu) is smaller than maximum object size (%llu), writes are limited to PAGE_SIZE\n",
+ PAGE_SIZE, max_size);
+
return 0;
err:
kobject_put(secvar_kobj);