Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7

From: Jan Stancek
Date: Tue Sep 27 2016 - 05:01:38 EST






----- Original Message -----
> From: "Herbert Xu" <herbert@xxxxxxxxxxxxxxxxxxx>
> To: "Marcelo Cerri" <marcelo.cerri@xxxxxxxxxxxxx>
> Cc: "Jan Stancek" <jstancek@xxxxxxxxxx>, "rui y wang" <rui.y.wang@xxxxxxxxx>, mhcerri@xxxxxxxxxxxxxxxxxx,
> leosilva@xxxxxxxxxxxxxxxxxx, pfsmorigo@xxxxxxxxxxxxxxxxxx, linux-crypto@xxxxxxxxxxxxxxx,
> linuxppc-dev@xxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
> Sent: Tuesday, 27 September, 2016 5:08:26 AM
> Subject: Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7
>
> On Mon, Sep 26, 2016 at 02:43:17PM -0300, Marcelo Cerri wrote:
> >
> > Wouldn't be enough to provide a pair of import/export functions as the
> > padlock-sha driver does?
>
> I don't think that will help as ultimately you need to call the
> export function on the fallback and that's what requires the extra
> memory. In fact very operation involving the fallback will need
> that extra memory too.

So, if we extended p8_ghash_desc_ctx to accommodate fallback_desc's ctx
and then provided statesize/import/export, would that be acceptable?

struct p8_ghash_desc_ctx {
...
struct shash_desc fallback_desc;
+ char fallback_ctx[sizeof(struct ghash_desc_ctx)];


Also, does that mean that padlock_sha has similar problem?
It does not seem to reserve any space for fallback __ctx and it calls
init()/update()/export() with padlock_sha_desc's fallback:

struct padlock_sha_desc {
struct shash_desc fallback;
};

static struct shash_alg sha1_alg = {
.descsize = sizeof(struct padlock_sha_desc),

Regards,
Jan

>
> Cheers,
> --
> Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
>