lkml.org 
[lkml]   [2015]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v5] hexdump: fix for non-aligned buffers
From
On Tue, Jul 14, 2015 at 12:23 AM, Horacio Mijail Anton Quiles
<hmijail@gmail.com> wrote:
> An hexdump with a buf not aligned to the groupsize causes
> non-naturally-aligned memory accesses. This was causing a kernel panic
> on the processor BlackFin BF527, when such an unaligned buffer was fed
> by the function ubifs_scanned_corruption in fs/ubifs/scan.c .
>
> To fix this, change accesses to the contents of the buffer so they go
> through get_unaligned(). This change should be harmless to unaligned-
> access-capable architectures, and any performance hit should be anyway
> dwarfed by the snprintf() processing time.
>
> Signed-off-by: Horacio Mijail Antón Quiles <hmijail@gmail.com>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

> --- a/lib/hexdump.c
> +++ b/lib/hexdump.c
> @@ -11,6 +11,7 @@

> @@ -139,7 +140,8 @@ int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, int groupsize,
> for (j = 0; j < ngroups; j++) {
> ret = snprintf(linebuf + lx, linebuflen - lx,
> "%s%16.16llx", j ? " " : "",
> - (unsigned long long)*(ptr8 + j));
> + (unsigned long long)
> + get_unaligned(ptr8 + j));

I think the cast to "unsigned long long" dates back to the days u64 was
"unsigned long" on some 64-bit architectures.

As u64 is now "unsigned long long", it can be removed. Would you mind sending
a follow-up patch to just do that?

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


\
 
 \ /
  Last update: 2015-07-14 09:01    [W:0.034 / U:1.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site