Re: Bug report: unaligned access with ext4 encryption

From: Aaro Koskinen
Date: Thu Jan 10 2019 - 17:29:33 EST


Hi,

On Fri, Jan 04, 2019 at 05:28:02PM +0000, David Howells wrote:
> Eric Biggers <ebiggers@xxxxxxxxxx> 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.