Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp33062imu; Thu, 10 Jan 2019 16:28:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN522lWfu4Z42eh/Iycr3cr4Zcl6wFahWjcnyo2L/mu0Ic+xQZIHROr28M+gzLF9iHk0qdCM X-Received: by 2002:a17:902:6f09:: with SMTP id w9mr12719510plk.309.1547166493096; Thu, 10 Jan 2019 16:28:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547166493; cv=none; d=google.com; s=arc-20160816; b=Ej+F5OCFdhaZFR78kka+vCGKmNYK1q0MhLXXP6Y5e2yJ2mtnUIVmnmIlbZYA1M4xb/ 3sFyUn2A8TRQ5ydV6CZEribL/U6hTU8vk1OYC6msARgyZwKZIl9n0TiAtfATMtDt8F1D lsCflCYhzdS6K/4tsmtirCbpLEqfp2TPbzm727fVxBg77aE5zQaXhrfMPcIIPY1v0XAo oxW1/uF44IK+/pHmNy84NP0UgJ+szarFCLmmrRAgoW4jyGn0cLURhYLmN6Dw0XX28dsA ugSpOAim5Br2mRN7gDCp3WjaXC4GByjtKbDfmGrfvRG3QJamc/7hbjSImIwiKxOFtUNx t8qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=n89FDzv8ScYuOEf0lD+qI+Z0mEEDaHiyMuH+f2Xi1/M=; b=O7hZcfNNMzc+l8K7v6dW67+aCeoAloLWxSRqkg1nXdo2WlO8KmUnsvTbsA6eLneDQy x9pVTPEUQl/Jb1edYN6xmtStiD1ZM8nEvzyLPQMXT+FYFza7fcSzba9f+3y/dMXofdyb sTS/qDPxjdDFV9u9kvD0X617C1VjX50uXM0OwDI1c1EDCJk0rjKzJ/5DoEDOyApTkG9B QaGh+ThHeocqXfdNdjeSM3DfNkxuHIEKE5ZnvloRXeNl1OmBHRX44CQr8MUUT7vb8Xld ExYBuCP4jfjWs3IvHWBTMLybury+9/d0QxURBDh3wzraQcvntQSERomiK9TLRCIDTAD4 QKsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uA13TDL6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y27si69007681pga.459.2019.01.10.16.27.58; Thu, 10 Jan 2019 16:28:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uA13TDL6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728763AbfAJXBS (ORCPT + 99 others); Thu, 10 Jan 2019 18:01:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:47388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727780AbfAJXBR (ORCPT ); Thu, 10 Jan 2019 18:01:17 -0500 Received: from gmail.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 74937208E3; Thu, 10 Jan 2019 23:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547161276; bh=OlT6NhEtYojy9FEGQlWdAZqJtHPp9nCUnKUyJ5VzcZY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uA13TDL6N9k+0c49KAHk8lno9N/jVyG6i+RsLsOdsvUs+3v+lGZe5x5ZVzZe94FGt uD/Heau29qve86oj/A5NTku7vp4dDj/qWbTxY2AxusBtoSe6isQD69LKg8BeO9ovB6 ySwEoj3PnNshs65LMkSRZEGu6ATku/SmoDHlv0eI= Date: Thu, 10 Jan 2019 15:01:14 -0800 From: Eric Biggers To: Aaro Koskinen Cc: David Howells , "Theodore Y. Ts'o" , Jaegeuk Kim , linux-fscrypt@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org Subject: Re: Bug report: unaligned access with ext4 encryption Message-ID: <20190110230114.GF149637@gmail.com> References: <20190103171659.GA208343@gmail.com> <20181230162906.GI27785@darkstar.musicnaut.iki.fi> <17391.1546622882@warthog.procyon.org.uk> <20190110222928.GB22416@darkstar.musicnaut.iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190110222928.GB22416@darkstar.musicnaut.iki.fi> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 11, 2019 at 12:29:28AM +0200, Aaro Koskinen wrote: > Hi, > > On Fri, Jan 04, 2019 at 05:28:02PM +0000, David Howells wrote: > > Eric Biggers wrote: > > > Hi Aaro, thanks for the bug report! I think you're on the right track; it makes > > > much more sense to have the keyrings subsystem store the payload with better > > > alignment, than to work around the 2-byte alignment in fscrypt. > > > > > > But how about '__aligned(__alignof__(u64))' instead? 4 bytes may not be enough. > > > > > > David, what do you think? > > > > Does that even work? > > That should work. > > > Might be better to just insert 6 bytes of padding with a comment, but yes I > > agree that it's probably better to align it to at least machine word size. > > Padding is fragile, e.g. if struct rcu_head changes. Using __aligned should > make it always right automatically. > > A. I agree that __aligned is better. It should work; see 'struct crypto_tfm' in include/linux/crypto.h for another example of a struct that uses __aligned on a flexible array at the end. Aaro, can you send a formal patch? If you don't I'll do so, but I figure I'll ask first. Thanks, - Eric