bcachefs: Fix encryption path on arm
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 24 May 2022 02:37:01 +0000 (22:37 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:33 +0000 (17:09 -0400)
flush_dcache_page() is not a noop on arm, but we were using
virt_to_page() instead of vmalloc_to_page() for an address on the kernel
stack - vmalloc memory, leading to an oops in flush_dcache_page().

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/checksum.c

index 50157b4013a5d6b0d138d21cbee3a71d763be96d..317efd047a463a0f12b214b826d144671f5438dc 100644 (file)
@@ -116,7 +116,12 @@ static inline int do_encrypt(struct crypto_sync_skcipher *tfm,
 {
        struct scatterlist sg;
 
-       sg_init_one(&sg, buf, len);
+       sg_init_table(&sg, 1);
+       sg_set_page(&sg,
+                   is_vmalloc_addr(buf)
+                   ? vmalloc_to_page(buf)
+                   : virt_to_page(buf),
+                   len, offset_in_page(buf));
        return do_encrypt_sg(tfm, nonce, &sg, len);
 }