mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] bcachefs: Fix general protection fault in bch2_checksum
@ 2024-07-17 21:56 Camila Alvarez
  0 siblings, 0 replies; only message in thread
From: Camila Alvarez @ 2024-07-17 21:56 UTC (permalink / raw)
  To: Kent Overstreet
  Cc: Brian Foster, linux-bcachefs, linux-kernel,
	syzbot+dd3d9835055dacb66f35, Camila Alvarez

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

Reported-by: syzbot+dd3d9835055dacb66f35@syzkaller.appspotmail.com
Signed-off-by: Camila Alvarez <cam.alvarez.i@gmail.com>
---
 fs/bcachefs/checksum.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/bcachefs/checksum.c b/fs/bcachefs/checksum.c
index 3bd3aba90d8f..77b29c73d7a0 100644
--- a/fs/bcachefs/checksum.c
+++ b/fs/bcachefs/checksum.c
@@ -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);
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-07-17 21:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-17 21:56 [PATCH] bcachefs: Fix general protection fault in bch2_checksum Camila Alvarez

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®