From: Herbert Xu <herbert@gondor.apana.org.au>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
stable@vger.kernel.org
Subject: Re: [PATCH v2] crypto: af_alg - Fix incorrect boolean values in af_alg_ctx
Date: Thu, 25 Sep 2025 09:58:03 +0800 [thread overview]
Message-ID: <aNShq_wAowyu4q2n@gondor.apana.org.au> (raw)
In-Reply-To: <20250924201822.9138-1-ebiggers@kernel.org>
On Wed, Sep 24, 2025 at 01:18:22PM -0700, Eric Biggers wrote:
> Commit 1b34cbbf4f01 ("crypto: af_alg - Disallow concurrent writes in
> af_alg_sendmsg") changed some fields from bool to 1-bit bitfields of
> type u32. However, some assignments to these fields, specifically
> 'more' and 'merge', assign values greater than 1. These relied on C's
> implicit conversion to bool, such that zero becomes false and nonzero
> becomes true. With a 1-bit bitfields of type u32 instead, mod 2 of the
> value is taken instead, resulting in 0 being assigned in some cases when
> 1 was intended. Fix this by restoring the bool type.
>
> Fixes: 1b34cbbf4f01 ("crypto: af_alg - Disallow concurrent writes in af_alg_sendmsg")
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> ---
>
> v2: keep the bitfields and just change the type, as suggested by Linus
>
> include/crypto/if_alg.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks for catching this and fixing it. I wish there was a warning
for this. Gcc will warn if a constant like 2 is assigned to the
bitfield, but there are no warnings if you assign an int to it.
Cheers,
--
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
prev parent reply other threads:[~2025-09-25 1:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-24 20:18 Eric Biggers
2025-09-24 21:44 ` Linus Torvalds
2025-09-25 1:58 ` Herbert Xu [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=aNShq_wAowyu4q2n@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=ebiggers@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®