Getting rid of alignment faults in userspace

Arnd Bergmann arnd at
Fri Jun 17 12:58:48 UTC 2011

On Friday 17 June 2011 14:10:11 Dave Martin wrote:

> As part of the general effort to make open source on ARM better, I think 
> it would be great if we can disable the alignment fixups (or at least
> enable logging) and work with upstreams to get the affected packages
> fixed.
> For release images we might want to be more forgiving, but for development
> we have the option of being more aggressive.

Yes, makes sense.

> These apps typically generate hundreds or thousands of faults per session,
> but not millions, but it's still quite a lot of noise in syslog.

Then we should make sure that an appropriate rate limiting is in place,
like the patch below (untested) would do.


ARM: Add rate-limiting to alignment trap printk

Malicious or buggy applications can easily flood syslog by accessing unaligned
data. Better use printk_ratelimited for the warning to prevent this while also
allowing us to see the important output.

Signed-off-by: Arnd Bergmann <arnd at>

diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index 724ba3b..462b98d 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -873,9 +873,9 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 	ai_user += 1;
 	if (ai_usermode & UM_WARN)
-		printk("Alignment trap: %s (%d) PC=0x%08lx Instr=0x%0*lx "
-		       "Address=0x%08lx FSR 0x%03x\n", current->comm,
-			task_pid_nr(current), instrptr,
+		printk_ratelimited("Alignment trap: %s (%d) PC=0x%08lx "
+			"Instr=0x%0*lx Address=0x%08lx FSR 0x%03x\n",
+			current->comm, task_pid_nr(current), instrptr,
 			isize << 1,
 			isize == 2 ? tinstr : instr,
 		        addr, fsr);

More information about the ubuntu-devel mailing list