From: Eric Biggers <ebiggers@kernel.org>
To: Corentin Labbe <clabbe@baylibre.com>
Cc: davem@davemloft.net, herbert@gondor.apana.org.au,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] crypto: crypto_user_stat: convert all stats from u32 to u64
Date: Mon, 5 Nov 2018 17:42:42 -0800 [thread overview]
Message-ID: <20181106014242.GD28490@gmail.com> (raw)
In-Reply-To: <1541422274-40060-3-git-send-email-clabbe@baylibre.com>
Hi Corentin,
On Mon, Nov 05, 2018 at 12:51:11PM +0000, Corentin Labbe wrote:
> All the 32-bit fields need to be 64-bit. In some cases, UINT32_MAX crypto
> operations can be done in seconds.
>
> Reported-by: Eric Biggers <ebiggers@kernel.org>
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
> crypto/algapi.c | 10 +--
> crypto/crypto_user_stat.c | 114 +++++++++++++++-----------------
> include/crypto/acompress.h | 8 +--
> include/crypto/aead.h | 8 +--
> include/crypto/akcipher.h | 16 ++---
> include/crypto/hash.h | 6 +-
> include/crypto/kpp.h | 12 ++--
> include/crypto/rng.h | 8 +--
> include/crypto/skcipher.h | 8 +--
> include/linux/crypto.h | 46 ++++++-------
> include/uapi/linux/cryptouser.h | 38 +++++------
> 11 files changed, 133 insertions(+), 141 deletions(-)
>
> diff --git a/crypto/algapi.c b/crypto/algapi.c
> index f5396c88e8cd..42fe316f80ee 100644
> --- a/crypto/algapi.c
> +++ b/crypto/algapi.c
> @@ -259,13 +259,13 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
> list_add(&larval->alg.cra_list, &crypto_alg_list);
>
> #ifdef CONFIG_CRYPTO_STATS
> - atomic_set(&alg->encrypt_cnt, 0);
> - atomic_set(&alg->decrypt_cnt, 0);
> + atomic64_set(&alg->encrypt_cnt, 0);
> + atomic64_set(&alg->decrypt_cnt, 0);
> atomic64_set(&alg->encrypt_tlen, 0);
> atomic64_set(&alg->decrypt_tlen, 0);
> - atomic_set(&alg->verify_cnt, 0);
> - atomic_set(&alg->cipher_err_cnt, 0);
> - atomic_set(&alg->sign_cnt, 0);
> + atomic64_set(&alg->verify_cnt, 0);
> + atomic64_set(&alg->cipher_err_cnt, 0);
> + atomic64_set(&alg->sign_cnt, 0);
> #endif
>
> out:
> diff --git a/crypto/crypto_user_stat.c b/crypto/crypto_user_stat.c
> index a6fb2e6f618d..352569f378a0 100644
> --- a/crypto/crypto_user_stat.c
> +++ b/crypto/crypto_user_stat.c
> @@ -35,22 +35,21 @@ static int crypto_report_aead(struct sk_buff *skb, struct crypto_alg *alg)
> {
> struct crypto_stat raead;
> u64 v64;
> - u32 v32;
>
> memset(&raead, 0, sizeof(raead));
>
> strscpy(raead.type, "aead", sizeof(raead.type));
>
> - v32 = atomic_read(&alg->encrypt_cnt);
> - raead.stat_encrypt_cnt = v32;
> + v64 = atomic64_read(&alg->encrypt_cnt);
> + raead.stat_encrypt_cnt = v64;
> v64 = atomic64_read(&alg->encrypt_tlen);
> raead.stat_encrypt_tlen = v64;
> - v32 = atomic_read(&alg->decrypt_cnt);
> - raead.stat_decrypt_cnt = v32;
> + v64 = atomic64_read(&alg->decrypt_cnt);
> + raead.stat_decrypt_cnt = v64;
> v64 = atomic64_read(&alg->decrypt_tlen);
> raead.stat_decrypt_tlen = v64;
> - v32 = atomic_read(&alg->aead_err_cnt);
> - raead.stat_aead_err_cnt = v32;
> + v64 = atomic64_read(&alg->aead_err_cnt);
> + raead.stat_aead_err_cnt = v64;
>
> return nla_put(skb, CRYPTOCFGA_STAT_AEAD, sizeof(raead), &raead);
> }
Why not assign the result of atomic64_read() directly?
I don't see the point of the 'v64' variable.
- Eric
next prev parent reply other threads:[~2018-11-06 11:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-05 12:51 [PATCH 0/5] crypto: crypto_user_stat: misc enhancement Corentin Labbe
2018-11-05 12:51 ` [PATCH 1/5] crypto: crypto_user_stat: made crypto_user_stat optional Corentin Labbe
2018-11-06 1:41 ` Eric Biggers
2018-11-07 18:55 ` LABBE Corentin
2018-11-05 12:51 ` [PATCH 2/5] crypto: crypto_user_stat: convert all stats from u32 to u64 Corentin Labbe
2018-11-06 1:42 ` Eric Biggers [this message]
2018-11-07 18:58 ` LABBE Corentin
2018-11-05 12:51 ` [PATCH 3/5] crypto: crypto_user_stat: split user space crypto stat structures Corentin Labbe
2018-11-06 1:44 ` Eric Biggers
2018-11-07 19:13 ` LABBE Corentin
2018-11-05 12:51 ` [PATCH 4/5] crypto: tool: getstat: convert user space example to the new crypto_user_stat uapi Corentin Labbe
2018-11-05 12:51 ` [PATCH 5/5] crypto: crypto_user_stat: fix use_after_free of struct xxx_request Corentin Labbe
2018-11-06 1:49 ` Eric Biggers
2018-11-07 19:34 ` LABBE Corentin
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=20181106014242.GD28490@gmail.com \
--to=ebiggers@kernel.org \
--cc=clabbe@baylibre.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).