From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965613AbcBRUK3 (ORCPT ); Thu, 18 Feb 2016 15:10:29 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:33134 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965396AbcBRUKY (ORCPT ); Thu, 18 Feb 2016 15:10:24 -0500 From: Rasmus Villemoes To: Al Viro Cc: Jeff Layton , "J. Bruce Fields" , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] vfs: make sure struct filename->iname is word-aligned Organization: D03 References: <1455662966-7977-1-git-send-email-linux@rasmusvillemoes.dk> <20160216225738.GD17997@ZenIV.linux.org.uk> X-Hashcash: 1:20:160218:linux-kernel@vger.kernel.org::ffdPFbzqh3eHXkxF:0000000000000000000000000000000000hXO X-Hashcash: 1:20:160218:jlayton@poochiereds.net::sv2JQCB9L78oi3ub:000000000000000000000000000000000000000jtO X-Hashcash: 1:20:160218:viro@zeniv.linux.org.uk::P/jCsOeLRNtkoGU6:000000000000000000000000000000000000001ebQ X-Hashcash: 1:20:160218:bfields@fieldses.org::HxLiIyguNDe0HM75:000000000000000000000000000000000000000005wdf X-Hashcash: 1:20:160218:torvalds@linux-foundation.org::nsoAPscD+j5peTi4:000000000000000000000000000000005hJd X-Hashcash: 1:20:160218:linux-fsdevel@vger.kernel.org::NNuSo9Mtg/2I3+Wb:000000000000000000000000000000008gQ7 Date: Thu, 18 Feb 2016 21:10:21 +0100 In-Reply-To: <20160216225738.GD17997@ZenIV.linux.org.uk> (Al Viro's message of "Tue, 16 Feb 2016 22:57:38 +0000") Message-ID: <878u2heq4y.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 16 2016, Al Viro wrote: > On Tue, Feb 16, 2016 at 11:49:24PM +0100, Rasmus Villemoes wrote: >> I noticed that offsetof(struct filename, iname) is actually 28 on 64 >> bit platforms, so we always pass an unaligned pointer to >> strncpy_from_user. This is mostly a problem for those 64 bit platforms >> without HAVE_EFFICIENT_UNALIGNED_ACCESS, but even on x86_64, unaligned >> accesses carry a penalty, especially when done in a loop. >> >> Let's try to ensure we always pass an aligned destination pointer to >> strncpy_from_user. I considered making refcnt a long instead of doing >> the union thing, and mostly ended up tossing a coin. > > Why not swap it with the previous field, then? Sure, that would work as well. I don't really care how ->iname is pushed out to offset 32, but I'd like to know if it's worth it. Rasmus