From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/2] kvm: pr_guest: don't let guest invoke printk() on host Date: Tue, 24 Jul 2007 13:19:01 +0300 Message-ID: <46A5D215.5030301@qumranet.com> References: <1185259677.1803.239.camel@localhost.localdomain> <1185260620.1803.245.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel To: Rusty Russell Return-path: In-Reply-To: <1185260620.1803.245.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Rusty Russell wrote: > If the guest can invoke a printk(), it can potentially flood the logs, > causing a host DoS. We should also indicate *which* guest we're > talking about. > > This patch adds pr_guest (analogous to pr_debug) which ratelimits. > Not all printk's were replaced: some are only printed once and others > should probably be replaced by BUG(). I removed the kvm_printf in > init_rmode_tss: it says nothing that the return value doesn't say. > > Coders should be aware that printing in the logs is not particularly > useful except to give feedback to developers. ie. "should not be used > for chit-chat". > > int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module); > void kvm_exit_arch(void); > diff -r 3f158ee9df43 drivers/kvm/kvm_main.c > --- a/drivers/kvm/kvm_main.c Tue Jul 24 16:22:39 2007 +1000 > +++ b/drivers/kvm/kvm_main.c Tue Jul 24 16:28:33 2007 +1000 > @@ -425,8 +425,8 @@ inject_gp(struct kvm_vcpu *vcpu, const c > va_list args; > > va_start(args, why_fmt); > - printk(KERN_DEBUG "kvm: #GP "); > - vprintk(why_fmt, args); > + if (pr_guest(vcpu, "#GP ")) > + vprintk(why_fmt, args); > va_end(args); > kvm_arch_ops->inject_gp(vcpu, 0); > } > Why go through this optimization? If it happens frequently, we can just remove the printk(). The printk()s are mostly on not-expected-to-happen exceptions, and should just be removed if guests do exercise them. -- error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/