mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vitaly Chikunov <vt@altlinux.org>
To: "Herbert Xu" <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	"David Howells" <dhowells@redhat.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@st.com>,
	"Horia Geantă" <horia.geanta@nxp.com>,
	"Aymen Sghaier" <aymen.sghaier@nxp.com>,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Gary Hook" <gary.hook@amd.com>,
	"Giovanni Cabiddu" <giovanni.cabiddu@intel.com>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	keyrings@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org, qat-linux@intel.com
Subject: Re: [RFC PATCH v4] akcipher: new verify API for public key algorithms
Date: Mon, 4 Feb 2019 17:00:40 +0300	[thread overview]
Message-ID: <20190204140040.wpxoojf4rgx56ppu@altlinux.org> (raw)
In-Reply-To: <20190201070922.nvopn4kxz7jbcoey@altlinux.org>

Herbert,

On Fri, Feb 01, 2019 at 10:09:23AM +0300, Vitaly Chikunov wrote:
> On Fri, Feb 01, 2019 at 02:26:55PM +0800, Herbert Xu wrote:
> > On Fri, Jan 25, 2019 at 09:01:16PM +0300, Vitaly Chikunov wrote:
> > >
> > > @@ -781,36 +780,17 @@ static int tpm_key_verify_signature(const struct key *key,
> > >  	if (!req)
> > >  		goto error_free_tfm;
> > >  
> > > -	ret = -ENOMEM;
> > > -	outlen = crypto_akcipher_maxsize(tfm);
> > > -	output = kmalloc(outlen, GFP_KERNEL);
> > > -	if (!output)
> > > -		goto error_free_req;
> > > -
> > > -	sg_init_one(&sig_sg, sig->s, sig->s_size);
> > > -	sg_init_one(&digest_sg, output, outlen);
> > > -	akcipher_request_set_crypt(req, &sig_sg, &digest_sg, sig->s_size,
> > > -				   outlen);
> > > +	sg_init_table(&src_sg, 2);
> > > +	sg_set_buf(&src_sg[0], sig->s, sig->s_size);
> > > +	sg_set_buf(&src_sg[1], sig->digest, sig->digest_size);
> > > +	akcipher_request_set_crypt(req, &src_sg, NULL, sig->s_size,
> > > +				   sig->digest_size);
> > 
> > It's not clear that sig->digest is guaranteed to be kmalloc memory.
> > In any case, it's best not to mix unrelated changes in a single
> > patch.  So please keep the kmalloc on output and then copy
> > sig->digest into it and put output into the SG list.

I will do that.

Thanks,

> It is not guaranteed that sig->s will be kmalloc memory either. (Except
> we know it for sure like we know the same about sig->digest).
> 
> You can see in public_key_signature_free() that both fields are kfree'd
> together.
> 
> So, I don't understand why we should treat sig->digest differently than
> sig->s.
> 
> I was just removing kmalloc'ed output as crypto_akcipher_verify() does
> not need any output anymore. So, it's not some sort of mixing unrelated
> changes, from my point of view.
> 
> Thanks,
> 
> > 
> > Thanks,
> > -- 
> > Email: Herbert Xu <herbert@gondor.apana.org.au>
> > Home Page: http://gondor.apana.org.au/~herbert/
> > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2019-02-04 14:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25 18:01 Vitaly Chikunov
2019-02-01  6:26 ` Herbert Xu
2019-02-01  7:09   ` Vitaly Chikunov
2019-02-04 14:00     ` Vitaly Chikunov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190204140040.wpxoojf4rgx56ppu@altlinux.org \
    --to=vt@altlinux.org \
    --cc=alexandre.torgue@st.com \
    --cc=aymen.sghaier@nxp.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=gary.hook@amd.com \
    --cc=giovanni.cabiddu@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=horia.geanta@nxp.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=qat-linux@intel.com \
    --cc=thomas.lendacky@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome