On Tue, Jul 14, 2015 at 12:23 AM, Horacio Mijail Anton Quiles
<[email protected]> 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 <[email protected]>

Acked-by: Geert Uytterhoeven <[email protected]>

> --- 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 -- [email protected]

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to