History

[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.

Jes Sorensen committed 20 years ago

Commit d2b176e1 parent c8c16353 files · +43 −3Browse files

Unified · Split

3 files
  1. arch/ia64/kernel/unaligned.c +28 −3
  2. include/linux/sysctl.h +1 −0
  3. kernel/sysctl.c +14 −0
arch/ia64/kernel/unaligned.c+28−3
@@ -52,6 +52,15 @@ dump (const char *str, void *vp, size_t len) · 51 unmodified lines
5252 #define IA64_FIRST_ROTATING_FR 32
5353 #define SIGN_EXT9 0xffffffffffffff00ul
5454
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+
5564 /*
5665 * For M-unit:
5766 *
@@ -1324,8 +1333,9 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs) · 1266 unmodified lines
13241333 if ((current->thread.flags & IA64_THREAD_UAC_SIGBUS) != 0)
13251334 goto force_sigbus;
13261335
1327− if (!(current->thread.flags & IA64_THREAD_UAC_NOPRINT)
1328− && within_logging_rate_limit())
1336+ if (!no_unaligned_warning &&
1337+ !(current->thread.flags & IA64_THREAD_UAC_NOPRINT) &&
1338+ within_logging_rate_limit())
13291339 {
13301340 char buf[200]; /* comm[] is at most 16 bytes... */
13311341 size_t len;
@@ -1340,7 +1350,22 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs) · 8 unmodified lines
13401350 if (user_mode(regs))
13411351 tty_write_message(current->signal->tty, buf);
13421352 buf[len-1] = '\0'; /* drop '\r' */
1343− printk(KERN_WARNING "%s", buf); /* watch for command names containing %s */
1353+ /* watch for command names containing %s */
1354+ printk(KERN_WARNING "%s", buf);
1355+ } else {
1356+ if (no_unaligned_warning && !noprint_warning) {
1357+ noprint_warning = 1;
1358+ printk(KERN_WARNING "%s(%d) encountered an "
1359+ "unaligned exception which required\n"
1360+ "kernel assistance, which degrades "
1361+ "the performance of the application.\n"
1362+ "Unaligned exception warnings have "
1363+ "been disabled by the system "
1364+ "administrator\n"
1365+ "echo 0 > /proc/sys/kernel/ignore-"
1366+ "unaligned-usertrap to re-enable\n",
1367+ current->comm, current->pid);
1368+ }
13441369 }
13451370 } else {
13461371 if (within_logging_rate_limit())
include/linux/sysctl.h+1−0
@@ -147,6 +147,7 @@ enum · 146 unmodified lines
147147 KERN_SETUID_DUMPABLE=69, /* int: behaviour of dumps for setuid core */
148148 KERN_SPIN_RETRY=70, /* int: number of spinlock retries */
149149 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 */
150151 };
151152
152153
kernel/sysctl.c+14−0
@@ -124,6 +124,10 @@ extern int sysctl_hz_timer; · 123 unmodified lines
124124 extern int acct_parm[];
125125 #endif
126126
127+#ifdef CONFIG_IA64
128+extern int no_unaligned_warning;
129+#endif
130+
127131 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
128132 ctl_table *, void **);
129133 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
@@ -665,6 +669,16 @@ static ctl_table kern_table[] = { · 535 unmodified lines
665669 .mode = 0644,
666670 .proc_handler = &proc_dointvec,
667671 },
672+#endif
673+#ifdef CONFIG_IA64
674+ {
675+ .ctl_name = KERN_IA64_UNALIGNED,
676+ .procname = "ignore-unaligned-usertrap",
677+ .data = &no_unaligned_warning,
678+ .maxlen = sizeof (int),
679+ .mode = 0644,
680+ .proc_handler = &proc_dointvec,
681+ },
668682 #endif
669683 { .ctl_name = 0 }
670684 };