powerpc/powernv: Restrict OPAL symbol map to only be readable by root
authorAndrew Donnellan <ajd@linux.ibm.com>
Fri, 3 May 2019 07:52:53 +0000 (17:52 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 5 Aug 2019 08:53:04 +0000 (18:53 +1000)
Currently the OPAL symbol map is globally readable, which seems bad as
it contains physical addresses.

Restrict it to root.

Fixes: c8742f85125d ("powerpc/powernv: Expose OPAL firmware symbol map")
Cc: stable@vger.kernel.org # v3.19+
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190503075253.22798-1-ajd@linux.ibm.com
arch/powerpc/platforms/powernv/opal.c

index aba443be7daafd07f80016b969fa957694050e42..d271accf224b5b0e9b78718c4cc7d206205a99be 100644 (file)
@@ -705,7 +705,10 @@ static ssize_t symbol_map_read(struct file *fp, struct kobject *kobj,
                                       bin_attr->size);
 }
 
-static BIN_ATTR_RO(symbol_map, 0);
+static struct bin_attribute symbol_map_attr = {
+       .attr = {.name = "symbol_map", .mode = 0400},
+       .read = symbol_map_read
+};
 
 static void opal_export_symmap(void)
 {
@@ -722,10 +725,10 @@ static void opal_export_symmap(void)
                return;
 
        /* Setup attributes */
-       bin_attr_symbol_map.private = __va(be64_to_cpu(syms[0]));
-       bin_attr_symbol_map.size = be64_to_cpu(syms[1]);
+       symbol_map_attr.private = __va(be64_to_cpu(syms[0]));
+       symbol_map_attr.size = be64_to_cpu(syms[1]);
 
-       rc = sysfs_create_bin_file(opal_kobj, &bin_attr_symbol_map);
+       rc = sysfs_create_bin_file(opal_kobj, &symbol_map_attr);
        if (rc)
                pr_warn("Error %d creating OPAL symbols file\n", rc);
 }