Re: [PATCH v4 02/29] rxrpc: Avoid using stack memory in SG lists in rxkad
From: Herbert Xu
Date: Tue Jun 28 2016 - 03:55:56 EST
On Tue, Jun 28, 2016 at 08:52:20AM +0100, David Howells wrote:
> Andy Lutomirski <luto@xxxxxxxxxx> wrote:
>
> > - skcipher_request_set_crypt(req, &sg[1], &sg[0], sizeof(tmpbuf), iv.x);
> > + skcipher_request_set_crypt(req, &sg, &sg, sizeof(tmpbuf), iv.x);
>
> Don't the sg's have to be different? Aren't they both altered by the process
> of reading/writing from them?
No they don't have to be different.
> > struct rxrpc_skb_priv *sp;
> > ...
> > + swap(tmpbuf.xl, *(__be64 *)sp);
> > +
> > + sg_init_one(&sg, sp, sizeof(tmpbuf));
>
> ???? I assume you're assuming that the rxrpc_skb_priv struct contents can
> arbitrarily replaced temporarily...
Of course you can, it's per-skb state.
> And using an XCHG-equivalent instruction? This won't work on a 32-bit arch
> (apart from one that sports CMPXCHG8 or similar).
No this is not using an atomic xchg, whatever gave you that idea?
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt