From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932114AbbFUQrS (ORCPT ); Sun, 21 Jun 2015 12:47:18 -0400 Received: from smtprelay0222.hostedemail.com ([216.40.44.222]:47686 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753183AbbFUQrJ (ORCPT ); Sun, 21 Jun 2015 12:47:09 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3870:3871:4321:5007:6261:7903:8603:8660:8957:10004:10400:10848:11026:11232:11473:11658:11914:12043:12114:12438:12517:12519:12740:13069:13148:13230:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: angle70_20f35a9dd5e15 X-Filterd-Recvd-Size: 1854 Message-ID: <1434905225.9808.3.camel@perches.com> Subject: Re: [PATCH] hexdump: fix for non-naturally-aligned buffers From: Joe Perches To: Horacio Mijail =?ISO-8859-1?Q?Ant=F3n?= Quiles Cc: Andrew Morton , Andy Shevchenko , David Howells , Vivek Goyal , linux-kernel@vger.kernel.org, trivial@kernel.org Date: Sun, 21 Jun 2015 09:47:05 -0700 In-Reply-To: <20150621163657.GA324@mija-VirtualBox> References: <20150621163657.GA324@mija-VirtualBox> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2015-06-21 at 18:36 +0200, =?UTF-8?q?Horacio=20Mijail=20Ant=C3=B3n=20Quiles?= wrote: > Calling hex_dump_to_buffer() with a buffer non-naturally-aligned to the > groupsize causes non-naturally-aligned memory accesses. This was causing > a kernel panic on the BlackFin BF527, when such a call was made by > ubifs_scanned_corruption() in fs/ubifs/scan.c . [] > diff --git a/lib/hexdump.c b/lib/hexdump.c [] > @@ -123,6 +123,11 @@ int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, int groupsize, > groupsize = 1; > if ((len % groupsize) != 0) /* no mixed size output */ > groupsize = 1; > + > + /* fall back to 1-byte groups if buf is not naturally aligned */ > + if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && > + (((uintptr_t)buf % groupsize) != 0)) > + groupsize = 1; Maybe !IS_ALIGNED(buf, groupsize) reads better. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/