From: Randy Dunlap <randy.dunlap@oracle.com>
To: Zack Weinberg <zackw@panix.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
jmorris@namei.org, Chris Wright <chrisw@sous-sol.org>,
linux-kernel@vger.kernel.org
Subject: Re: [patch 2/4] permission mapping for sys_syslog operations
Date: Thu, 14 Dec 2006 17:02:29 -0800 [thread overview]
Message-ID: <20061214170229.d0f06a57.randy.dunlap@oracle.com> (raw)
In-Reply-To: <20061215002334.039728000@panix.com>
On Thu, 14 Dec 2006 16:16:41 -0800 Zack Weinberg wrote:
> As suggested by Stephen Smalley: map the various sys_syslog operations
> to a smaller set of privilege codes before calling security modules.
> This patch changes the security module interface! There should be no
> change in the actual security semantics enforced by dummy, capability,
> nor SELinux (with one exception, clearly marked in sys_syslog).
>
> Change from previous version of patch: the privilege codes are now
> in linux/security.h instead of linux/klog.h, and use the LSM_* naming
> convention used for other such constants in that file.
>
>
> Index: linux-2.6/kernel/printk.c
> ===================================================================
> --- linux-2.6.orig/kernel/printk.c 2006-12-13 16:06:22.000000000 -0800
> +++ linux-2.6/kernel/printk.c 2006-12-13 16:08:30.000000000 -0800
> @@ -164,6 +164,12 @@
>
> __setup("log_buf_len=", log_buf_len_setup);
>
> +#define security_syslog_or_fail(type) do { \
> + int error = security_syslog(type); \
> + if (error) \
> + return error; \
> + } while (0)
> +
>From Documentation/CodingStyle:
Things to avoid when using macros:
1) macros that affect control flow: ...
> /* See linux/klog.h for the command numbers passed as the first argument. */
> int do_syslog(int type, char __user *buf, int len)
> {
> @@ -172,16 +178,15 @@
> char c;
> int error = 0;
>
> - error = security_syslog(type);
> - if (error)
> - return error;
> -
> switch (type) {
> case KLOG_CLOSE:
> + security_syslog_or_fail(LSM_KLOG_READ);
> break;
> case KLOG_OPEN:
> + security_syslog_or_fail(LSM_KLOG_READ);
> break;
> case KLOG_READ:
> + security_syslog_or_fail(LSM_KLOG_READ);
> error = -EINVAL;
> if (!buf || len < 0)
> goto out;
> @@ -213,9 +218,11 @@
> error = i;
> break;
> case KLOG_READ_CLEAR_HIST:
> + security_syslog_or_fail(LSM_KLOG_CLEARHIST);
> do_clear = 1;
> /* FALL THRU */
> case KLOG_READ_HIST:
> + security_syslog_or_fail(LSM_KLOG_READHIST);
> error = -EINVAL;
> if (!buf || len < 0)
> goto out;
> @@ -269,15 +276,19 @@
> }
> break;
> case KLOG_CLEAR_HIST:
> + security_syslog_or_fail(LSM_KLOG_CLEARHIST);
> logged_chars = 0;
> break;
> case KLOG_DISABLE_CONSOLE:
> + security_syslog_or_fail(LSM_KLOG_CONSOLE);
> console_loglevel = minimum_console_loglevel;
> break;
> case KLOG_ENABLE_CONSOLE:
> + security_syslog_or_fail(LSM_KLOG_CONSOLE);
> console_loglevel = default_console_loglevel;
> break;
> case KLOG_SET_CONSOLE_LVL:
> + security_syslog_or_fail(LSM_KLOG_CONSOLE);
> error = -EINVAL;
> if (len < 1 || len > 8)
> goto out;
> @@ -287,9 +298,18 @@
> error = 0;
> break;
> case KLOG_GET_UNREAD:
> + security_syslog_or_fail(LSM_KLOG_READ);
> error = log_end - log_start;
> break;
---
~Randy
next prev parent reply other threads:[~2006-12-15 1:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-15 0:16 [patch 0/4] /proc/kmsg permissions, take three Zack Weinberg
2006-12-15 0:16 ` [patch 1/4] Add <linux/klog.h> Zack Weinberg
2006-12-15 0:59 ` Randy Dunlap
2006-12-15 1:21 ` Zack Weinberg
2006-12-15 0:16 ` [patch 2/4] permission mapping for sys_syslog operations Zack Weinberg
2006-12-15 1:02 ` Randy Dunlap [this message]
2006-12-15 1:21 ` Zack Weinberg
2006-12-15 17:08 ` Randy Dunlap
2006-12-15 0:16 ` [patch 3/4] Refactor do_syslog interface Zack Weinberg
2006-12-15 0:16 ` [patch 4/4] Distinguish /proc/kmsg access from sys_syslog Zack Weinberg
-- strict thread matches above, loose matches on Subject: below --
2006-12-24 20:22 [patch 0/4] /proc/kmsg permissions, take four Zack Weinberg
2006-12-24 20:22 ` [patch 2/4] permission mapping for sys_syslog operations Zack Weinberg
2006-11-13 6:40 [patch 0/4] Syslog permissions, revised Zack Weinberg
2006-11-13 6:40 ` [patch 2/4] permission mapping for sys_syslog operations Zack Weinberg
2006-11-13 9:25 ` Arjan van de Ven
2006-11-13 9:29 ` Zack Weinberg
2006-11-13 9:47 ` Arjan van de Ven
2006-11-13 17:17 ` Zack Weinberg
2006-11-13 17:22 ` Arjan van de Ven
2006-11-13 21:13 ` Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061214170229.d0f06a57.randy.dunlap@oracle.com \
--to=randy.dunlap@oracle.com \
--cc=chrisw@sous-sol.org \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sds@tycho.nsa.gov \
--cc=zackw@panix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome