All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-crypto@vger.kernel.org, Neil Horman <nhorman@tuxdriver.com>,
	Corentin Labbe <clabbe@baylibre.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] crypto: rng - fix crypto_rng_reset() refcounting when !CRYPTO_STATS
Date: Mon, 22 Mar 2021 10:33:01 +0300	[thread overview]
Message-ID: <20210322073300.GF1667@kadam> (raw)
In-Reply-To: <YFgyaeeY6k6Pltw7@sol.localdomain>

On Sun, Mar 21, 2021 at 11:00:09PM -0700, Eric Biggers wrote:
> On Mon, Mar 22, 2021 at 08:45:22AM +0300, Dan Carpenter wrote:
> > On Sun, Mar 21, 2021 at 10:07:48PM -0700, Eric Biggers wrote:
> > > From: Eric Biggers <ebiggers@google.com>
> > > 
> > > crypto_stats_get() is a no-op when the kernel is compiled without
> > > CONFIG_CRYPTO_STATS, so pairing it with crypto_alg_put() unconditionally
> > > (as crypto_rng_reset() does) is wrong.
> > > 
> > 
> > Presumably the intention was that _get() and _put() should always pair.
> > It's really ugly and horrible that they don't. We could have
> > predicted bug like this would happen and will continue to happen until
> > the crypto_stats_get() is renamed.
> > 
> 
> Well, the crypto stats stuff has always been pretty broken, so I don't think
> people have looked at it too closely.  Currently crypto_stats_get() pairs with
> one of the functions that tallies the statistics, such as
> crypto_stats_rng_seed() or crypto_stats_aead_encrypt().  What change are you
> suggesting, exactly?  Maybe moving the conditional crypto_alg_put() into a new
> function crypto_stats_put() and moving it into the callers?  Or do you think the
> functions should just be renamed to something like crypto_stats_begin() and
> crypto_stats_end_{rng_seed,aead_encrypt}()?

To be honest, I misread the crypto_alg_put() thinking that it was
crypto_*stats*_put().  My favourite fix would be to introduce a
crypto_stats_put() which is a mirror of crypto_stats_get() and ifdeffed
out if we don't have CONFIG_CRYPTO_STATS.

regards,
dan carpenter


  reply	other threads:[~2021-03-22  7:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22  5:07 [PATCH] crypto: rng - fix crypto_rng_reset() refcounting when !CRYPTO_STATS Eric Biggers
2021-03-22  5:45 ` Dan Carpenter
2021-03-22  6:00   ` Eric Biggers
2021-03-22  7:33     ` Dan Carpenter [this message]
2021-03-22 12:13       ` LABBE Corentin
2021-04-02  9:03 ` Herbert Xu

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=20210322073300.GF1667@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=clabbe@baylibre.com \
    --cc=ebiggers@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.