Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[IA64] sysctl option to silence unaligned trap warnings

Allow sysadmin to disable all warnings about userland apps
making unaligned accesses by using:
# echo 1 > /proc/sys/kernel/ignore-unaligned-usertrap
Rather than having to use prctl on a process by process basis.

Default behaivour leaves the warnings enabled.

Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>

authored by

Jes Sorensen and committed by
Tony Luck
d2b176ed c8c1635f

+43 -3
+28 -3
arch/ia64/kernel/unaligned.c
··· 53 53 #define SIGN_EXT9 0xffffffffffffff00ul 54 54 55 55 /* 56 + * sysctl settable hook which tells the kernel whether to honor the 57 + * IA64_THREAD_UAC_NOPRINT prctl. Because this is user settable, we want 58 + * to allow the super user to enable/disable this for security reasons 59 + * (i.e. don't allow attacker to fill up logs with unaligned accesses). 60 + */ 61 + int no_unaligned_warning; 62 + static int noprint_warning; 63 + 64 + /* 56 65 * For M-unit: 57 66 * 58 67 * opcode | m | x6 | ··· 1333 1324 if ((current->thread.flags & IA64_THREAD_UAC_SIGBUS) != 0) 1334 1325 goto force_sigbus; 1335 1326 1336 - if (!(current->thread.flags & IA64_THREAD_UAC_NOPRINT) 1337 - && within_logging_rate_limit()) 1327 + if (!no_unaligned_warning && 1328 + !(current->thread.flags & IA64_THREAD_UAC_NOPRINT) && 1329 + within_logging_rate_limit()) 1338 1330 { 1339 1331 char buf[200]; /* comm[] is at most 16 bytes... */ 1340 1332 size_t len; ··· 1350 1340 if (user_mode(regs)) 1351 1341 tty_write_message(current->signal->tty, buf); 1352 1342 buf[len-1] = '\0'; /* drop '\r' */ 1353 - printk(KERN_WARNING "%s", buf); /* watch for command names containing %s */ 1343 + /* watch for command names containing %s */ 1344 + printk(KERN_WARNING "%s", buf); 1345 + } else { 1346 + if (no_unaligned_warning && !noprint_warning) { 1347 + noprint_warning = 1; 1348 + printk(KERN_WARNING "%s(%d) encountered an " 1349 + "unaligned exception which required\n" 1350 + "kernel assistance, which degrades " 1351 + "the performance of the application.\n" 1352 + "Unaligned exception warnings have " 1353 + "been disabled by the system " 1354 + "administrator\n" 1355 + "echo 0 > /proc/sys/kernel/ignore-" 1356 + "unaligned-usertrap to re-enable\n", 1357 + current->comm, current->pid); 1358 + } 1354 1359 } 1355 1360 } else { 1356 1361 if (within_logging_rate_limit())
+1
include/linux/sysctl.h
··· 147 147 KERN_SETUID_DUMPABLE=69, /* int: behaviour of dumps for setuid core */ 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 + KERN_IA64_UNALIGNED=72, /* int: ia64 unaligned userland trap enable */ 150 151 }; 151 152 152 153
+14
kernel/sysctl.c
··· 124 124 extern int acct_parm[]; 125 125 #endif 126 126 127 + #ifdef CONFIG_IA64 128 + extern int no_unaligned_warning; 129 + #endif 130 + 127 131 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t, 128 132 ctl_table *, void **); 129 133 static int proc_doutsstring(ctl_table *table, int write, struct file *filp, ··· 667 663 .data = &acpi_video_flags, 668 664 .maxlen = sizeof (unsigned long), 669 665 .mode = 0644, 666 + .proc_handler = &proc_dointvec, 667 + }, 668 + #endif 669 + #ifdef CONFIG_IA64 670 + { 671 + .ctl_name = KERN_IA64_UNALIGNED, 672 + .procname = "ignore-unaligned-usertrap", 673 + .data = &no_unaligned_warning, 674 + .maxlen = sizeof (int), 675 + .mode = 0644, 670 676 .proc_handler = &proc_dointvec, 671 677 }, 672 678 #endif