Skip to contentSkip to conversation

bcachefs: Fix general protection fault in bch2_checksum

PATCH New Camila Alvarez 1 participant 1 message Jul 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcachefs: Fix general protection fault in bch2_checksum

Checksum for types BCH_CSUM_chacha20_poly1305_80 and BCH_CSUM_chacha20_poly1305_128 are only computed when c is not NULL because they require the chacha20 cypher stored in c

---
 fs/bcachefs/checksum.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/bcachefs/checksum.c +3 -2
index 3bd3aba90d8f..77b29c73d7a0 100644
@@ -220,10 +220,11 @@ struct bch_csum bch2_checksum(struct bch_fs *c, unsigned type,
 
 	case BCH_CSUM_chacha20_poly1305_80:
 	case BCH_CSUM_chacha20_poly1305_128: {
+		struct bch_csum ret = { 0 };
+		if (!c)
+			return ret;
 		SHASH_DESC_ON_STACK(desc, c->poly1305);
 		u8 digest[POLY1305_DIGEST_SIZE];
-		struct bch_csum ret = { 0 };
-
 		gen_poly_key(c, desc, nonce);
 
 		crypto_shash_update(desc, data, len);
Signature · 1 line
2.34.1