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.
Unified · Split
| @@ -514,7 +514,7 @@ int sys32_ni_syscall(int call) · 513 unmodified lines | ||
| 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 @@ long sys32_vm86_warning(void) · 395 unmodified lines | ||
| 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 @@ · 54 unmodified lines | ||
| 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 @@ static void compat_ioctl_error(struct file *filp, unsigned int fd, · 298 unmodified lines | ||
| 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, |
| @@ -226,5 +226,7 @@ static inline int compat_timespec_compare(struct compat_timespec *lhs, · 225 unmodified lines | ||
| 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 */ |
| @@ -148,9 +148,11 @@ enum · 147 unmodified lines | ||
| 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 | }; |
| 152 | 153 | |
| 153 | 154 | |
| 155 | + | |
| 154 | 156 | /* CTL_VM names: */ |
| 155 | 157 | enum |
| 156 | 158 | { |
| @@ -73,6 +73,7 @@ extern int printk_ratelimit_burst; · 72 unmodified lines | ||
| 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; |
| @@ -676,6 +677,16 @@ static ctl_table kern_table[] = { · 597 unmodified lines | ||
| 676 | 677 | .mode = 0644, |
| 677 | 678 | .proc_handler = &proc_dointvec, |
| 678 | 679 | }, |
| 680 | +#endif | |
| 681 | +#ifdef CONFIG_COMPAT | |
| 682 | + { | |
| 683 | + .ctl_name = KERN_COMPAT_LOG, | |
| 684 | + .procname = "compat-log", | |
| 685 | + .data = &compat_log, | |
| 686 | + .maxlen = sizeof (int), | |
| 687 | + .mode = 0644, | |
| 688 | + .proc_handler = &proc_dointvec, | |
| 689 | + }, | |
| 679 | 690 | #endif |
| 680 | 691 | { .ctl_name = 0 } |
| 681 | 692 | }; |