aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/kernel/unaligned.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ia64/kernel/unaligned.c')
-rw-r--r--arch/ia64/kernel/unaligned.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/arch/ia64/kernel/unaligned.c b/arch/ia64/kernel/unaligned.c
index 43b45b65ee..1e357550c7 100644
--- a/arch/ia64/kernel/unaligned.c
+++ b/arch/ia64/kernel/unaligned.c
@@ -24,7 +24,7 @@
24#include <asm/uaccess.h> 24#include <asm/uaccess.h>
25#include <asm/unaligned.h> 25#include <asm/unaligned.h>
26 26
27extern void die_if_kernel(char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn)); 27extern void die_if_kernel(char *str, struct pt_regs *regs, long err);
28 28
29#undef DEBUG_UNALIGNED_TRAP 29#undef DEBUG_UNALIGNED_TRAP
30 30
@@ -53,6 +53,15 @@ dump (const char *str, void *vp, size_t len)
53#define SIGN_EXT9 0xffffffffffffff00ul 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 */
61int no_unaligned_warning;
62static int noprint_warning;
63
64/*
56 * For M-unit: 65 * For M-unit:
57 * 66 *
58 * opcode | m | x6 | 67 * opcode | m | x6 |
@@ -1283,8 +1292,9 @@ within_logging_rate_limit (void)
1283 1292
1284 if (jiffies - last_time > 5*HZ) 1293 if (jiffies - last_time > 5*HZ)
1285 count = 0; 1294 count = 0;
1286 if (++count < 5) { 1295 if (count < 5) {
1287 last_time = jiffies; 1296 last_time = jiffies;
1297 count++;
1288 return 1; 1298 return 1;
1289 } 1299 }
1290 return 0; 1300 return 0;
@@ -1323,8 +1333,9 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
1323 if ((current->thread.flags & IA64_THREAD_UAC_SIGBUS) != 0) 1333 if ((current->thread.flags & IA64_THREAD_UAC_SIGBUS) != 0)
1324 goto force_sigbus; 1334 goto force_sigbus;
1325 1335
1326 if (!(current->thread.flags & IA64_THREAD_UAC_NOPRINT) 1336 if (!no_unaligned_warning &&
1327 && within_logging_rate_limit()) 1337 !(current->thread.flags & IA64_THREAD_UAC_NOPRINT) &&
1338 within_logging_rate_limit())
1328 { 1339 {
1329 char buf[200]; /* comm[] is at most 16 bytes... */ 1340 char buf[200]; /* comm[] is at most 16 bytes... */
1330 size_t len; 1341 size_t len;
@@ -1339,7 +1350,22 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
1339 if (user_mode(regs)) 1350 if (user_mode(regs))
1340 tty_write_message(current->signal->tty, buf); 1351 tty_write_message(current->signal->tty, buf);
1341 buf[len-1] = '\0'; /* drop '\r' */ 1352 buf[len-1] = '\0'; /* drop '\r' */
1342 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 }
1343 } 1369 }
1344 } else { 1370 } else {
1345 if (within_logging_rate_limit()) 1371 if (within_logging_rate_limit())