]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
char: raw: do not leak CONFIG_MAX_RAW_DEVS to userspace
authorMasahiro Yamada <masahiroy@kernel.org>
Wed, 17 Jun 2020 08:33:13 +0000 (17:33 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Jul 2020 12:50:51 +0000 (14:50 +0200)
include/uapi/linux/raw.h leaks CONFIG_MAX_RAW_DEVS to userspace.

Userspace programs cannot use MAX_RAW_MINORS since CONFIG_MAX_RAW_DEVS
is not available anyway.

Remove the MAX_RAW_MINORS definition from the exported header, and use
CONFIG_MAX_RAW_DEVS in drivers/char/raw.c

While I was here, I converted printk(KERN_WARNING ...) to pr_warn(...)
and stretched the warning message.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Link: https://lore.kernel.org/r/20200617083313.183184-1-masahiroy@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/raw.c
include/uapi/linux/raw.h
scripts/headers_install.sh

index 3484e9145aea631c47f34cae2585cd44981de08f..380bf518338ef7d903264d940bf9131cb006448e 100644 (file)
@@ -37,7 +37,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_DEVS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,9 +317,9 @@ static int __init raw_init(void)
        int ret;
 
        if (max_raw_minors < 1 || max_raw_minors > 65536) {
-               printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-                       " between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-               max_raw_minors = MAX_RAW_MINORS;
+               pr_warn("raw: invalid max_raw_minors (must be between 1 and 65536), using %d\n",
+                       CONFIG_MAX_RAW_DEVS);
+               max_raw_minors = CONFIG_MAX_RAW_DEVS;
        }
 
        raw_devices = vzalloc(array_size(max_raw_minors,
index dc96dda479d64045969a583a8737b8cb0e0884f6..47874919d0b9a1562636e30088dc5fc6938c1f6d 100644 (file)
@@ -14,6 +14,4 @@ struct raw_config_request
        __u64   block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
-
 #endif /* __LINUX_RAW_H */
index 224f51012b6e887c4bf7ea081998a078deb7726d..cdd66038818c77349d71f7c0509a4fecf542bc83 100755 (executable)
@@ -90,7 +90,6 @@ include/uapi/linux/elfcore.h:CONFIG_BINFMT_ELF_FDPIC
 include/uapi/linux/eventpoll.h:CONFIG_PM_SLEEP
 include/uapi/linux/hw_breakpoint.h:CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
 include/uapi/linux/pktcdvd.h:CONFIG_CDROM_PKTCDVD_WCACHE
-include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS
 "
 
 for c in $configs