Re: [PATCH V2] crypto: Mark intermediary memory as clean

From: Edward Adam Davis
Date: Mon Aug 18 2025 - 08:32:10 EST


On Sun, 17 Aug 2025 19:40:56 +0800, Herbert Xu wrote:
> > diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
> > index 1266eb790708..4020a6e41b0e 100644
> > --- a/crypto/jitterentropy-kcapi.c
> > +++ b/crypto/jitterentropy-kcapi.c
> > @@ -117,6 +117,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
> > pr_warn_ratelimited("Unexpected digest size\n");
> > return -EINVAL;
> > }
> > + kmsan_unpoison_memory(intermediary, SHA3_256_DIGEST_SIZE);
>
> Please change SHA3_256_DIGEST_SIZE to sizeof(intermediary).
Why?
Their values are equal, so why use sizeof to calculate?
Similarly, "if (sizeof(intermediary) != crypto_shash_digestsize(desc->tfm)) {",
why not just use SHA3_256_DIGEST_SIZE?

BR,
Edward