Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423341Ab3CVVyw (ORCPT ); Fri, 22 Mar 2013 17:54:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44224 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422936Ab3CVVyv (ORCPT ); Fri, 22 Mar 2013 17:54:51 -0400 Date: Fri, 22 Mar 2013 14:54:48 -0700 From: Andrew Morton To: Kees Cook Cc: Josh Boyer , Eric Paris , Linus Torvalds , Christian Kujau , "# 3.4.x" , LKML Subject: Re: [PATCH] kmsg: Honor dmesg_restrict sysctl on /dev/kmsg Message-Id: <20130322145448.f44f9d10a36620c1c11535b7@linux-foundation.org> In-Reply-To: References: <20130222181856.GA2419@hansolo.jdub.homelinux.org> <20130227175427.GQ26411@outflux.net> <20130227180145.GH2071@hansolo.jdub.homelinux.org> <1361998001.2110.22.camel@localhost> <20130227221954.GJ2071@hansolo.jdub.homelinux.org> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2081 Lines: 57 poke. Nothing got applied. I'll drop kmsg-honor-dmesg_restrict-sysctl-on-dev-kmsg.patch, see if that has any effect ;) From: Josh Boyer Subject: kmsg: honor dmesg_restrict sysctl on /dev/kmsg Originally, the addition of dmesg_restrict covered both the syslog method of accessing dmesg, as well as /dev/kmsg itself. This was done indirectly by security_syslog calling cap_syslog before doing any LSM checks. However, commit 12b3052c3ee ("capabilities/syslog: open code cap_syslog logic to fix build failure") moved the code around and pushed the checks into the caller itself. That seems to have inadvertently dropped the checks for dmesg_restrict on /dev/kmsg. Most people haven't noticed because util-linux dmesg(1) defaults to using the syslog method for access in older versions. With util-linux 2.22 and a kernel newer than 3.5, dmesg(1) defaults to reading directly from /dev/kmsg. Fix this by making an explicit check in the devkmsg_open function. This fixes https://bugzilla.redhat.com/show_bug.cgi?id=903192 Signed-off-by: Josh Boyer Reported-by: Christian Kujau Cc: Eric Paris Cc: James Morris Cc: Signed-off-by: Andrew Morton --- kernel/printk.c | 3 +++ 1 file changed, 3 insertions(+) diff -puN kernel/printk.c~kmsg-honor-dmesg_restrict-sysctl-on-dev-kmsg kernel/printk.c --- a/kernel/printk.c~kmsg-honor-dmesg_restrict-sysctl-on-dev-kmsg +++ a/kernel/printk.c @@ -620,6 +620,9 @@ static int devkmsg_open(struct inode *in struct devkmsg_user *user; int err; + if (dmesg_restrict && !capable(CAP_SYSLOG)) + return -EACCES; + /* write-only does not need any file context */ if ((file->f_flags & O_ACCMODE) == O_WRONLY) return 0; _ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/