Commit bebfa1013eee1d91b3242e5801cc8fbdfaf148ec

Authored by Andi Kleen
Committed by Linus Torvalds
1 parent f201611fce

[PATCH] x86_64: Add compat_printk and sysctl to turn off compat layer warnings

Sometimes e.g. with crashme the compat layer warnings can be noisy.
Add a way to turn them off by gating all output through compat_printk
that checks a global sysctl. The default is not changed.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 5 changed files with 32 additions and 3 deletions Side-by-side Diff

arch/x86_64/ia32/sys_ia32.c
... ... @@ -514,7 +514,7 @@
514 514 static char lastcomm[sizeof(me->comm)];
515 515  
516 516 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
517   - printk(KERN_INFO "IA32 syscall %d from %s not implemented\n",
  517 + compat_printk(KERN_INFO "IA32 syscall %d from %s not implemented\n",
518 518 call, me->comm);
519 519 strncpy(lastcomm, me->comm, sizeof(lastcomm));
520 520 }
... ... @@ -916,7 +916,7 @@
916 916 struct task_struct *me = current;
917 917 static char lastcomm[sizeof(me->comm)];
918 918 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
919   - printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n",
  919 + compat_printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n",
920 920 me->comm);
921 921 strncpy(lastcomm, me->comm, sizeof(lastcomm));
922 922 }
... ... @@ -55,6 +55,20 @@
55 55  
56 56 extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
57 57  
  58 +int compat_log = 1;
  59 +
  60 +int compat_printk(const char *fmt, ...)
  61 +{
  62 + va_list ap;
  63 + int ret;
  64 + if (!compat_log)
  65 + return 0;
  66 + va_start(ap, fmt);
  67 + ret = vprintk(fmt, ap);
  68 + va_end(ap);
  69 + return ret;
  70 +}
  71 +
58 72 /*
59 73 * Not all architectures have sys_utime, so implement this in terms
60 74 * of sys_utimes.
... ... @@ -359,7 +373,7 @@
359 373 sprintf(buf,"'%c'", (cmd>>24) & 0x3f);
360 374 if (!isprint(buf[1]))
361 375 sprintf(buf, "%02x", buf[1]);
362   - printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
  376 + compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
363 377 "cmd(%08x){%s} arg(%08x) on %s\n",
364 378 current->comm, current->pid,
365 379 (int)fd, (unsigned int)cmd, buf,
include/linux/compat.h
... ... @@ -226,6 +226,8 @@
226 226  
227 227 asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
228 228  
  229 +extern int compat_printk(const char *fmt, ...);
  230 +
229 231 #endif /* CONFIG_COMPAT */
230 232 #endif /* _LINUX_COMPAT_H */
include/linux/sysctl.h
... ... @@ -148,7 +148,9 @@
148 148 KERN_SPIN_RETRY=70, /* int: number of spinlock retries */
149 149 KERN_ACPI_VIDEO_FLAGS=71, /* int: flags for setting up video after ACPI sleep */
150 150 KERN_IA64_UNALIGNED=72, /* int: ia64 unaligned userland trap enable */
  151 + KERN_COMPAT_LOG=73, /* int: print compat layer messages */
151 152 };
  153 +
152 154  
153 155  
154 156 /* CTL_VM names: */
... ... @@ -73,6 +73,7 @@
73 73 extern int pid_max_min, pid_max_max;
74 74 extern int sysctl_drop_caches;
75 75 extern int percpu_pagelist_fraction;
  76 +extern int compat_log;
76 77  
77 78 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
78 79 int unknown_nmi_panic;
... ... @@ -672,6 +673,16 @@
672 673 .ctl_name = KERN_IA64_UNALIGNED,
673 674 .procname = "ignore-unaligned-usertrap",
674 675 .data = &no_unaligned_warning,
  676 + .maxlen = sizeof (int),
  677 + .mode = 0644,
  678 + .proc_handler = &proc_dointvec,
  679 + },
  680 +#endif
  681 +#ifdef CONFIG_COMPAT
  682 + {
  683 + .ctl_name = KERN_COMPAT_LOG,
  684 + .procname = "compat-log",
  685 + .data = &compat_log,
675 686 .maxlen = sizeof (int),
676 687 .mode = 0644,
677 688 .proc_handler = &proc_dointvec,