Skip to content

Commit 04aaca1

Browse files
masahir0ygregkh
authored andcommitted
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>
1 parent 51d501e commit 04aaca1

3 files changed

Lines changed: 4 additions & 7 deletions

File tree

‎drivers/char/raw.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static struct raw_device_data *raw_devices;
3737
static DEFINE_MUTEX(raw_mutex);
3838
static const struct file_operations raw_ctl_fops; /* forward declaration */
3939

40-
static int max_raw_minors = MAX_RAW_MINORS;
40+
static int max_raw_minors = CONFIG_MAX_RAW_DEVS;
4141

4242
module_param(max_raw_minors, int, 0);
4343
MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,9 +317,9 @@ static int __init raw_init(void)
317317
int ret;
318318

319319
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;
323323
}
324324

325325
raw_devices = vzalloc(array_size(max_raw_minors,

‎include/uapi/linux/raw.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@ struct raw_config_request
1414
__u64 block_minor;
1515
};
1616

17-
#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
18-
1917
#endif /* __LINUX_RAW_H */

‎scripts/headers_install.sh‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ include/uapi/linux/elfcore.h:CONFIG_BINFMT_ELF_FDPIC
9090
include/uapi/linux/eventpoll.h:CONFIG_PM_SLEEP
9191
include/uapi/linux/hw_breakpoint.h:CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
9292
include/uapi/linux/pktcdvd.h:CONFIG_CDROM_PKTCDVD_WCACHE
93-
include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS
9493
"
9594

9695
for c in $configs

0 commit comments

Comments
 (0)