Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

char: raw: do not leak CONFIG_MAX_RAW_DEVS to userspace

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>

authored by

Masahiro Yamada and committed by
Greg Kroah-Hartman
04aaca19 51d501e5

+4 -7
+4 -4
drivers/char/raw.c
··· 37 37 static DEFINE_MUTEX(raw_mutex); 38 38 static const struct file_operations raw_ctl_fops; /* forward declaration */ 39 39 40 - static int max_raw_minors = MAX_RAW_MINORS; 40 + static int max_raw_minors = CONFIG_MAX_RAW_DEVS; 41 41 42 42 module_param(max_raw_minors, int, 0); 43 43 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)"); ··· 317 317 int ret; 318 318 319 319 if (max_raw_minors < 1 || max_raw_minors > 65536) { 320 - printk(KERN_WARNING "raw: invalid max_raw_minors (must be" 321 - " between 1 and 65536), using %d\n", MAX_RAW_MINORS); 322 - max_raw_minors = MAX_RAW_MINORS; 320 + pr_warn("raw: invalid max_raw_minors (must be between 1 and 65536), using %d\n", 321 + CONFIG_MAX_RAW_DEVS); 322 + max_raw_minors = CONFIG_MAX_RAW_DEVS; 323 323 } 324 324 325 325 raw_devices = vzalloc(array_size(max_raw_minors,
-2
include/uapi/linux/raw.h
··· 14 14 __u64 block_minor; 15 15 }; 16 16 17 - #define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS 18 - 19 17 #endif /* __LINUX_RAW_H */
-1
scripts/headers_install.sh
··· 90 90 include/uapi/linux/eventpoll.h:CONFIG_PM_SLEEP 91 91 include/uapi/linux/hw_breakpoint.h:CONFIG_HAVE_MIXED_BREAKPOINTS_REGS 92 92 include/uapi/linux/pktcdvd.h:CONFIG_CDROM_PKTCDVD_WCACHE 93 - include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS 94 93 " 95 94 96 95 for c in $configs