Summary: | geli: NULL encryption algorithm instapanics "IV_SEPARATE set when IV isn't used" | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Alan Somers <asomers> | ||||
Component: | kern | Assignee: | John Baldwin <jhb> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Many People | CC: | markj | ||||
Priority: | --- | ||||||
Version: | CURRENT | ||||||
Hardware: | Any | ||||||
OS: | Any | ||||||
Attachments: |
|
Description
Alan Somers
2020-07-13 15:42:08 UTC
jhb, could you please take a look at this? I think it's pretty likely that the bug was introduced by r359374. A NULL mode should not exist anyway. Hmm, I could either relax the assertion or we'd have to omit the flag for NULL. Arguably things that want to use a NULL transform should just not create an OCF session at all but instead handle it directly. IPsec mandates a NULL cipher for testing (but only for testing.) Presumably NULL doesn't need to use keys either. Hmm, try this: Index: geom/eli/g_eli_integrity.c =================================================================== --- geom/eli/g_eli_integrity.c (revision 361855) +++ geom/eli/g_eli_integrity.c (working copy) @@ -536,13 +536,15 @@ crp->crp_digest_start = 0; crp->crp_payload_start = sc->sc_alen; crp->crp_payload_length = data_secsize; - crp->crp_flags |= CRYPTO_F_IV_SEPARATE; if ((sc->sc_flags & G_ELI_FLAG_FIRST_KEY) == 0) { crp->crp_cipher_key = g_eli_key_hold(sc, dstoff, encr_secsize); } - g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv, - sizeof(crp->crp_iv)); + if (g_eli_ivlen(sc->sc_ealgo) != 0) { + crp->crp_flags |= CRYPTO_F_IV_SEPARATE; + g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv, + sizeof(crp->crp_iv)); + } g_eli_auth_keygen(sc, dstoff, authkey); crp->crp_auth_key = authkey; Index: geom/eli/g_eli_privacy.c =================================================================== --- geom/eli/g_eli_privacy.c (revision 361855) +++ geom/eli/g_eli_privacy.c (working copy) @@ -281,13 +281,15 @@ crp->crp_payload_start = 0; crp->crp_payload_length = secsize; - crp->crp_flags |= CRYPTO_F_IV_SEPARATE; if ((sc->sc_flags & G_ELI_FLAG_SINGLE_KEY) == 0) { crp->crp_cipher_key = g_eli_key_hold(sc, dstoff, secsize); } - g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv, - sizeof(crp->crp_iv)); + if (g_eli_ivlen(sc->sc_ealgo) != 0) { + crp->crp_flags |= CRYPTO_F_IV_SEPARATE; + g_eli_crypto_ivgen(sc, dstoff, crp->crp_iv, + sizeof(crp->crp_iv)); + } error = crypto_dispatch(crp); KASSERT(error == 0, ("crypto_dispatch() failed (error=%d)", Created attachment 216613 [details]
Fix geli's null cipher, and add a test case
Your fix works for me, jhb. I've combined it with a regression test in the attached patch.
Comment on attachment 216613 [details]
Fix geli's null cipher, and add a test case
Looks good to me.
A commit references this bug: Author: asomers Date: Tue Jul 21 19:18:30 UTC 2020 New revision: 363402 URL: https://svnweb.freebsd.org/changeset/base/363402 Log: Fix geli's null cipher, and add a test case PR: 247954 Submitted by: jhb (sys), asomers (tests) Reviewed by: jhb (tests), asomers (sys) MFC after: 2 weeks Sponsored by: Axcient Changes: head/sys/geom/eli/g_eli_integrity.c head/sys/geom/eli/g_eli_privacy.c head/tests/sys/geom/class/eli/onetime_test.sh A commit references this bug: Author: lwhsu Date: Wed Jul 22 17:37:11 UTC 2020 New revision: 363423 URL: https://svnweb.freebsd.org/changeset/base/363423 Log: Fix sys.geom.class.eli.onetime_test.onetime after r363402 PR: 247954 X-MFC with: r363402 Sponsored by: The FreeBSD Foundation Changes: head/tests/sys/geom/class/eli/onetime_test.sh No need to MFC. Bug does not exist on stable/12. |