Skip to content

Commit b25a7c5

Browse files
committed
module: Do not expose section addresses to non-CAP_SYSLOG
The printing of section addresses in /sys/module/*/sections/* was not using the correct credentials to evaluate visibility. Before: # cat /sys/module/*/sections/.*text 0xffffffffc0458000 ... # capsh --drop=CAP_SYSLOG -- -c "cat /sys/module/*/sections/.*text" 0xffffffffc0458000 ... After: # cat /sys/module/*/sections/*.text 0xffffffffc0458000 ... # capsh --drop=CAP_SYSLOG -- -c "cat /sys/module/*/sections/.*text" 0x0000000000000000 ... Additionally replaces the existing (safe) /proc/modules check with file->f_cred for consistency. Reported-by: Dominik Czarnota <[email protected]> Fixes: be71eda ("module: Fix display of wrong module .text address") Cc: [email protected] Tested-by: Jessica Yu <[email protected]> Acked-by: Jessica Yu <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent ed66f99 commit b25a7c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/module.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,8 +1530,8 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
15301530
if (pos != 0)
15311531
return -EINVAL;
15321532

1533-
return sprintf(buf, "0x%px\n", kptr_restrict < 2 ?
1534-
(void *)sattr->address : NULL);
1533+
return sprintf(buf, "0x%px\n",
1534+
kallsyms_show_value(file->f_cred) ? (void *)sattr->address : NULL);
15351535
}
15361536

15371537
static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
@@ -4380,7 +4380,7 @@ static int modules_open(struct inode *inode, struct file *file)
43804380

43814381
if (!err) {
43824382
struct seq_file *m = file->private_data;
4383-
m->private = kallsyms_show_value(current_cred()) ? NULL : (void *)8ul;
4383+
m->private = kallsyms_show_value(file->f_cred) ? NULL : (void *)8ul;
43844384
}
43854385

43864386
return err;

0 commit comments

Comments
 (0)