Re: [PATCH 1/3] kvm-s390: Fix printk on SIGP set arch

Amit Shah
2009-01-22T11:41:47Z

On (Thu) Jan 22 2009 [10:27:38], Christian Borntraeger wrote:
> From: Christian Borntraeger <borntraeger@de.ibm.com>
>
> KVM on s390 does not support the ESA/390 architecture. We refuse to
> change the architecture mode and print a warning. While testing a
> crashme for kvm, I spotted two problems with the printk:
>
> o A malicious can flood host dmesg
> o There was no newline at the end of the printk
>
> This patch fixes both problems.
>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> arch/s390/kvm/sigp.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> Index: kvm/arch/s390/kvm/sigp.c
> ===================================================================
> --- kvm.orig/arch/s390/kvm/sigp.c
> +++ kvm/arch/s390/kvm/sigp.c
> @@ -153,8 +153,9 @@ static int __sigp_set_arch(struct kvm_vc
>
> switch (parameter & 0xff) {
> case 0:
> - printk(KERN_WARNING "kvm: request to switch to ESA/390 mode"
> - " not supported");
> + if (printk_ratelimit())
> + printk(KERN_WARNING "kvm: request to switch to ESA/390"
> + " mode not supported\n");

Breaking printk lines isn't encouraged just to keep the column width at
80. It makes grepping the sources for the source of the message
difficult to find.