Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 221725
b: refs/heads/master
c: eaf06b2
h: refs/heads/master
i:
  221723: e6ec877
v: v3
  • Loading branch information
Dan Rosenberg authored and Linus Torvalds committed Nov 12, 2010
1 parent 235e920 commit 20bb529
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 203f40a5a030ed4048cd40e3bd9ab5df6c5df589
refs/heads/master: eaf06b241b091357e72b76863ba16e89610d31bd
14 changes: 14 additions & 0 deletions trunk/Documentation/sysctl/kernel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ show up in /proc/sys/kernel:
- core_uses_pid
- ctrl-alt-del
- dentry-state
- dmesg_restrict
- domainname
- hostname
- hotplug
Expand Down Expand Up @@ -213,6 +214,19 @@ to decide what to do with it.

==============================================================

dmesg_restrict:

This toggle indicates whether unprivileged users are prevented from using
dmesg(8) to view messages from the kernel's log buffer. When
dmesg_restrict is set to (0) there are no restrictions. When
dmesg_restrict is set set to (1), users must have CAP_SYS_ADMIN to use
dmesg(8).

The kernel config option CONFIG_SECURITY_DMESG_RESTRICT sets the default
value of dmesg_restrict.

==============================================================

domainname & hostname:

These files can be used to set the NIS/YP domainname and the
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
unsigned int interval_msec);

extern int printk_delay_msec;
extern int dmesg_restrict;

/*
* Print a one-time message (analogous to WARN_ONCE() et al):
Expand Down
6 changes: 6 additions & 0 deletions trunk/kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ static inline void boot_delay_msec(void)
}
#endif

#ifdef CONFIG_SECURITY_DMESG_RESTRICT
int dmesg_restrict = 1;
#else
int dmesg_restrict;
#endif

int do_syslog(int type, char __user *buf, int len, bool from_file)
{
unsigned i, j, limit, count;
Expand Down
9 changes: 9 additions & 0 deletions trunk/kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,15 @@ static struct ctl_table kern_table[] = {
.extra2 = &ten_thousand,
},
#endif
{
.procname = "dmesg_restrict",
.data = &dmesg_restrict,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
},
{
.procname = "ngroups_max",
.data = &ngroups_max,
Expand Down
12 changes: 12 additions & 0 deletions trunk/security/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ config KEYS_DEBUG_PROC_KEYS

If you are unsure as to whether this is required, answer N.

config SECURITY_DMESG_RESTRICT
bool "Restrict unprivileged access to the kernel syslog"
default n
help
This enforces restrictions on unprivileged users reading the kernel
syslog via dmesg(8).

If this option is not selected, no restrictions will be enforced
unless the dmesg_restrict sysctl is explicitly set to (1).

If you are unsure how to answer this question, answer N.

config SECURITY
bool "Enable different security models"
depends on SYSFS
Expand Down
2 changes: 2 additions & 0 deletions trunk/security/commoncap.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ int cap_syslog(int type, bool from_file)
{
if (type != SYSLOG_ACTION_OPEN && from_file)
return 0;
if (dmesg_restrict && !capable(CAP_SYS_ADMIN))
return -EPERM;
if ((type != SYSLOG_ACTION_READ_ALL &&
type != SYSLOG_ACTION_SIZE_BUFFER) && !capable(CAP_SYS_ADMIN))
return -EPERM;
Expand Down

0 comments on commit 20bb529

Please sign in to comment.