Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964817AbcDYTof (ORCPT ); Mon, 25 Apr 2016 15:44:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55063 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933408AbcDYToe (ORCPT ); Mon, 25 Apr 2016 15:44:34 -0400 Date: Mon, 25 Apr 2016 12:44:32 -0700 From: Andrew Morton To: Peter Zijlstra Cc: Greg Kroah-Hartman , Steven Rostedt , Linus Torvalds , LKML , Ingo Molnar , Borislav Petkov , Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= Subject: Re: [PATCH v2] printk: Add kernel parameter to disable writes to /dev/kmsg Message-Id: <20160425124432.9eae987575b01a7028ed0bda@linux-foundation.org> In-Reply-To: <20160425192435.GM3430@twins.programming.kicks-ass.net> References: <20160425145606.598329f2@gandalf.local.home> <20160425190651.GL3448@twins.programming.kicks-ass.net> <20160425191815.GA24761@kroah.com> <20160425192435.GM3430@twins.programming.kicks-ass.net> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; 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: 2020 Lines: 53 On Mon, 25 Apr 2016 21:24:35 +0200 Peter Zijlstra wrote: > On Mon, Apr 25, 2016 at 12:18:15PM -0700, Greg Kroah-Hartman wrote: > > On Mon, Apr 25, 2016 at 09:06:51PM +0200, Peter Zijlstra wrote: > > > On Mon, Apr 25, 2016 at 02:56:06PM -0400, Steven Rostedt wrote: > > > > +static bool __read_mostly devkmsg_disabled; > > > > +static int __init disable_devkmsg(char *str) > > > > +{ > > > > + devkmsg_disabled = true; > > > > + return 0; > > > > +} > > > > +__setup("printk.disable_kmsg_write", disable_devkmsg); > > > > > > Again, please default enable and use an easier name to toggle this. > > > Userspace flooding this with junk is really insane. > > > > If you default enable, you break working systems today that want to log > > stuff through this interface, sorry. > > Oh, you mean those 'working' systems that livelocked my box because I > had console to serial enabled which could not keep up with the endless > flood of shite? > > This systemd exposure has seriously eroded your sanity. I'm trying to remember why we added /dev/kmsg in the first place - it seems a quite stupid idea. Why the heck should userspace be able to diddle with the kernel->userspace messaging stream? Sigh. This: commit e1b19d6e06a98874018c66990465dcc69b69c4bf Author: Andrew Morton Date: Tue Aug 13 06:12:54 2002 -0700 [PATCH] printk from userspace The patch allows userspace to issue printk's, via sys_syslog(). The main use of this is within hpa's klibc - initial userspace needs a way of logging information and this API allows that information to be captured into the printk ringbuffer. It ends up in /var/log/messages. Messages are truncated at 1024 characters by printk's vsprintf(). Requires CAP_SYS_ADMIN. This later got reverted and was replaced with /dev/kmsg and /proc/kmsg. I guess that's a legitimate enough reason but in retrospect we should have found a way of just shutting it off after booting has completed.