* [syzbot] [crypto?] KMSAN: kernel-infoleak in rng_recvmsg
@ 2025-08-08 8:07 syzbot
2025-08-09 9:59 ` [PATCH] crypto: Prevent " Edward Adam Davis
0 siblings, 1 reply; 15+ messages in thread
From: syzbot @ 2025-08-08 8:07 UTC (permalink / raw)
To: davem, herbert, linux-crypto, linux-kernel, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 6e64f4580381 Merge tag 'input-for-v6.17-rc0' of git://git...
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=14a181a2580000
kernel config: https://syzkaller.appspot.com/x/.config?x=b6003cf8ecb92ff2
dashboard link: https://syzkaller.appspot.com/bug?extid=e8bcd7ee3db6cb5cb875
compiler: Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=117fa1a2580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=105e9058580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/3d9a1192a7cc/disk-6e64f458.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/8f363fe8f54a/vmlinux-6e64f458.xz
kernel image: https://storage.googleapis.com/syzbot-assets/10b73833a575/bzImage-6e64f458.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
=====================================================
BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:114 [inline]
BUG: KMSAN: kernel-infoleak in copy_to_user_iter lib/iov_iter.c:24 [inline]
BUG: KMSAN: kernel-infoleak in iterate_ubuf include/linux/iov_iter.h:30 [inline]
BUG: KMSAN: kernel-infoleak in iterate_and_advance2 include/linux/iov_iter.h:300 [inline]
BUG: KMSAN: kernel-infoleak in iterate_and_advance include/linux/iov_iter.h:328 [inline]
BUG: KMSAN: kernel-infoleak in _copy_to_iter+0xf0e/0x33f0 lib/iov_iter.c:185
instrument_copy_to_user include/linux/instrumented.h:114 [inline]
copy_to_user_iter lib/iov_iter.c:24 [inline]
iterate_ubuf include/linux/iov_iter.h:30 [inline]
iterate_and_advance2 include/linux/iov_iter.h:300 [inline]
iterate_and_advance include/linux/iov_iter.h:328 [inline]
_copy_to_iter+0xf0e/0x33f0 lib/iov_iter.c:185
copy_to_iter include/linux/uio.h:220 [inline]
memcpy_to_msg include/linux/skbuff.h:4202 [inline]
_rng_recvmsg crypto/algif_rng.c:101 [inline]
rng_recvmsg+0x1af/0x2d0 crypto/algif_rng.c:114
sock_recvmsg_nosec net/socket.c:1065 [inline]
sock_recvmsg+0x2df/0x390 net/socket.c:1087
sock_read_iter+0x2c8/0x360 net/socket.c:1157
new_sync_read fs/read_write.c:491 [inline]
vfs_read+0x857/0xf00 fs/read_write.c:572
ksys_read fs/read_write.c:715 [inline]
__do_sys_read fs/read_write.c:724 [inline]
__se_sys_read fs/read_write.c:722 [inline]
__x64_sys_read+0x1fb/0x4d0 fs/read_write.c:722
x64_sys_call+0x2f9c/0x3e20 arch/x86/include/generated/asm/syscalls_64.h:1
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
<Zero or more stacks not recorded to save memory>
Uninit was stored to memory at:
crypto_sha3_finup+0x136/0xe00 crypto/sha3_generic.c:202
crypto_shash_op_and_zero crypto/shash.c:105 [inline]
crypto_shash_finup+0x327/0xe80 crypto/shash.c:171
jent_hash_time+0x247/0x590 crypto/jitterentropy-kcapi.c:138
jent_condition_data+0x4f0/0x510 crypto/jitterentropy.c:438
jent_measure_jitter+0x547/0x770 crypto/jitterentropy.c:541
jent_gen_entropy+0x209/0x450 crypto/jitterentropy.c:569
jent_read_entropy+0x353/0xeb0 crypto/jitterentropy.c:615
jent_kcapi_random+0x6c/0x250 crypto/jitterentropy-kcapi.c:284
crypto_rng_generate include/crypto/rng.h:144 [inline]
_rng_recvmsg crypto/algif_rng.c:97 [inline]
rng_recvmsg+0x149/0x2d0 crypto/algif_rng.c:114
sock_recvmsg_nosec net/socket.c:1065 [inline]
sock_recvmsg+0x2df/0x390 net/socket.c:1087
sock_read_iter+0x2c8/0x360 net/socket.c:1157
new_sync_read fs/read_write.c:491 [inline]
vfs_read+0x857/0xf00 fs/read_write.c:572
ksys_read fs/read_write.c:715 [inline]
__do_sys_read fs/read_write.c:724 [inline]
__se_sys_read fs/read_write.c:722 [inline]
__x64_sys_read+0x1fb/0x4d0 fs/read_write.c:722
x64_sys_call+0x2f9c/0x3e20 arch/x86/include/generated/asm/syscalls_64.h:1
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
crypto_shash_finup+0xc5a/0xe80 crypto/shash.c:162
crypto_shash_update include/crypto/hash.h:994 [inline]
jent_hash_time+0x1de/0x590 crypto/jitterentropy-kcapi.c:136
jent_condition_data+0x4f0/0x510 crypto/jitterentropy.c:438
jent_measure_jitter+0x547/0x770 crypto/jitterentropy.c:541
jent_gen_entropy+0x209/0x450 crypto/jitterentropy.c:569
jent_read_entropy+0x353/0xeb0 crypto/jitterentropy.c:615
jent_kcapi_random+0x6c/0x250 crypto/jitterentropy-kcapi.c:284
crypto_rng_generate include/crypto/rng.h:144 [inline]
_rng_recvmsg crypto/algif_rng.c:97 [inline]
rng_recvmsg+0x149/0x2d0 crypto/algif_rng.c:114
sock_recvmsg_nosec net/socket.c:1065 [inline]
sock_recvmsg+0x2df/0x390 net/socket.c:1087
sock_read_iter+0x2c8/0x360 net/socket.c:1157
new_sync_read fs/read_write.c:491 [inline]
vfs_read+0x857/0xf00 fs/read_write.c:572
ksys_read fs/read_write.c:715 [inline]
__do_sys_read fs/read_write.c:724 [inline]
__se_sys_read fs/read_write.c:722 [inline]
__x64_sys_read+0x1fb/0x4d0 fs/read_write.c:722
x64_sys_call+0x2f9c/0x3e20 arch/x86/include/generated/asm/syscalls_64.h:1
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
put_unaligned_le64 include/linux/unaligned.h:43 [inline]
crypto_sha3_finup+0xc98/0xe00 crypto/sha3_generic.c:213
crypto_shash_op_and_zero crypto/shash.c:105 [inline]
crypto_shash_finup+0x327/0xe80 crypto/shash.c:171
jent_hash_time+0x247/0x590 crypto/jitterentropy-kcapi.c:138
jent_condition_data+0x4f0/0x510 crypto/jitterentropy.c:438
jent_measure_jitter+0x547/0x770 crypto/jitterentropy.c:541
jent_gen_entropy+0x209/0x450 crypto/jitterentropy.c:569
jent_read_entropy+0x353/0xeb0 crypto/jitterentropy.c:615
jent_kcapi_random+0x6c/0x250 crypto/jitterentropy-kcapi.c:284
crypto_rng_generate include/crypto/rng.h:144 [inline]
_rng_recvmsg crypto/algif_rng.c:97 [inline]
rng_recvmsg+0x149/0x2d0 crypto/algif_rng.c:114
sock_recvmsg_nosec net/socket.c:1065 [inline]
sock_recvmsg+0x2df/0x390 net/socket.c:1087
sock_read_iter+0x2c8/0x360 net/socket.c:1157
new_sync_read fs/read_write.c:491 [inline]
vfs_read+0x857/0xf00 fs/read_write.c:572
ksys_read fs/read_write.c:715 [inline]
__do_sys_read fs/read_write.c:724 [inline]
__se_sys_read fs/read_write.c:722 [inline]
__x64_sys_read+0x1fb/0x4d0 fs/read_write.c:722
x64_sys_call+0x2f9c/0x3e20 arch/x86/include/generated/asm/syscalls_64.h:1
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
keccakf_round crypto/sha3_generic.c:-1 [inline]
keccakf+0x1efb/0x2110 crypto/sha3_generic.c:155
crypto_sha3_finup+0x772/0xe00 crypto/sha3_generic.c:210
crypto_shash_op_and_zero crypto/shash.c:105 [inline]
crypto_shash_finup+0x327/0xe80 crypto/shash.c:171
jent_hash_time+0x247/0x590 crypto/jitterentropy-kcapi.c:138
jent_condition_data+0x4f0/0x510 crypto/jitterentropy.c:438
jent_measure_jitter+0x547/0x770 crypto/jitterentropy.c:541
jent_gen_entropy+0x209/0x450 crypto/jitterentropy.c:569
jent_read_entropy+0x353/0xeb0 crypto/jitterentropy.c:615
jent_kcapi_random+0x6c/0x250 crypto/jitterentropy-kcapi.c:284
crypto_rng_generate include/crypto/rng.h:144 [inline]
_rng_recvmsg crypto/algif_rng.c:97 [inline]
rng_recvmsg+0x149/0x2d0 crypto/algif_rng.c:114
sock_recvmsg_nosec net/socket.c:1065 [inline]
sock_recvmsg+0x2df/0x390 net/socket.c:1087
sock_read_iter+0x2c8/0x360 net/socket.c:1157
new_sync_read fs/read_write.c:491 [inline]
vfs_read+0x857/0xf00 fs/read_write.c:572
ksys_read fs/read_write.c:715 [inline]
__do_sys_read fs/read_write.c:724 [inline]
__se_sys_read fs/read_write.c:722 [inline]
__x64_sys_read+0x1fb/0x4d0 fs/read_write.c:722
x64_sys_call+0x2f9c/0x3e20 arch/x86/include/generated/asm/syscalls_64.h:1
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
crypto_sha3_finup+0x5be/0xe00 crypto/sha3_generic.c:207
crypto_shash_op_and_zero crypto/shash.c:105 [inline]
crypto_shash_finup+0x327/0xe80 crypto/shash.c:171
jent_hash_time+0x247/0x590 crypto/jitterentropy-kcapi.c:138
jent_condition_data+0x4f0/0x510 crypto/jitterentropy.c:438
jent_measure_jitter+0x547/0x770 crypto/jitterentropy.c:541
jent_gen_entropy+0x209/0x450 crypto/jitterentropy.c:569
jent_read_entropy+0x353/0xeb0 crypto/jitterentropy.c:615
jent_kcapi_random+0x6c/0x250 crypto/jitterentropy-kcapi.c:284
crypto_rng_generate include/crypto/rng.h:144 [inline]
_rng_recvmsg crypto/algif_rng.c:97 [inline]
rng_recvmsg+0x149/0x2d0 crypto/algif_rng.c:114
sock_recvmsg_nosec net/socket.c:1065 [inline]
sock_recvmsg+0x2df/0x390 net/socket.c:1087
sock_read_iter+0x2c8/0x360 net/socket.c:1157
new_sync_read fs/read_write.c:491 [inline]
vfs_read+0x857/0xf00 fs/read_write.c:572
ksys_read fs/read_write.c:715 [inline]
__do_sys_read fs/read_write.c:724 [inline]
__se_sys_read fs/read_write.c:722 [inline]
__x64_sys_read+0x1fb/0x4d0 fs/read_write.c:722
x64_sys_call+0x2f9c/0x3e20 arch/x86/include/generated/asm/syscalls_64.h:1
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
crypto_sha3_finup+0x136/0xe00 crypto/sha3_generic.c:202
crypto_shash_op_and_zero crypto/shash.c:105 [inline]
crypto_shash_finup+0x327/0xe80 crypto/shash.c:171
jent_hash_time+0x247/0x590 crypto/jitterentropy-kcapi.c:138
jent_condition_data+0x4f0/0x510 crypto/jitterentropy.c:438
jent_measure_jitter+0x547/0x770 crypto/jitterentropy.c:541
jent_gen_entropy+0x209/0x450 crypto/jitterentropy.c:569
jent_read_entropy+0x353/0xeb0 crypto/jitterentropy.c:615
jent_kcapi_random+0x6c/0x250 crypto/jitterentropy-kcapi.c:284
crypto_rng_generate include/crypto/rng.h:144 [inline]
_rng_recvmsg crypto/algif_rng.c:97 [inline]
rng_recvmsg+0x149/0x2d0 crypto/algif_rng.c:114
sock_recvmsg_nosec net/socket.c:1065 [inline]
sock_recvmsg+0x2df/0x390 net/socket.c:1087
sock_read_iter+0x2c8/0x360 net/socket.c:1157
new_sync_read fs/read_write.c:491 [inline]
vfs_read+0x857/0xf00 fs/read_write.c:572
ksys_read fs/read_write.c:715 [inline]
__do_sys_read fs/read_write.c:724 [inline]
__se_sys_read fs/read_write.c:722 [inline]
__x64_sys_read+0x1fb/0x4d0 fs/read_write.c:722
x64_sys_call+0x2f9c/0x3e20 arch/x86/include/generated/asm/syscalls_64.h:1
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
crypto_shash_finup+0xc5a/0xe80 crypto/shash.c:162
crypto_shash_update include/crypto/hash.h:994 [inline]
jent_hash_time+0x1de/0x590 crypto/jitterentropy-kcapi.c:136
jent_condition_data+0x4f0/0x510 crypto/jitterentropy.c:438
jent_measure_jitter+0x547/0x770 crypto/jitterentropy.c:541
jent_gen_entropy+0x209/0x450 crypto/jitterentropy.c:569
jent_read_entropy+0x353/0xeb0 crypto/jitterentropy.c:615
jent_kcapi_random+0x6c/0x250 crypto/jitterentropy-kcapi.c:284
crypto_rng_generate include/crypto/rng.h:144 [inline]
_rng_recvmsg crypto/algif_rng.c:97 [inline]
rng_recvmsg+0x149/0x2d0 crypto/algif_rng.c:114
sock_recvmsg_nosec net/socket.c:1065 [inline]
sock_recvmsg+0x2df/0x390 net/socket.c:1087
sock_read_iter+0x2c8/0x360 net/socket.c:1157
new_sync_read fs/read_write.c:491 [inline]
vfs_read+0x857/0xf00 fs/read_write.c:572
ksys_read fs/read_write.c:715 [inline]
__do_sys_read fs/read_write.c:724 [inline]
__se_sys_read fs/read_write.c:722 [inline]
__x64_sys_read+0x1fb/0x4d0 fs/read_write.c:722
x64_sys_call+0x2f9c/0x3e20 arch/x86/include/generated/asm/syscalls_64.h:1
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable intermediary created at:
jent_hash_time+0x9b/0x590 crypto/jitterentropy-kcapi.c:110
jent_condition_data+0x4f0/0x510 crypto/jitterentropy.c:438
Bytes 0-23 of 24 are uninitialized
Memory access of size 24 starts at ffff88811855fb70
Data copied to user address 00002000000001c0
CPU: 1 UID: 0 PID: 5820 Comm: syz-executor170 Not tainted 6.16.0-syzkaller-11952-g6e64f4580381 #0 PREEMPT(none)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
=====================================================
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH] crypto: Prevent kernel-infoleak in rng_recvmsg
2025-08-08 8:07 [syzbot] [crypto?] KMSAN: kernel-infoleak in rng_recvmsg syzbot
@ 2025-08-09 9:59 ` Edward Adam Davis
2025-08-16 9:17 ` Herbert Xu
0 siblings, 1 reply; 15+ messages in thread
From: Edward Adam Davis @ 2025-08-09 9:59 UTC (permalink / raw)
To: syzbot+e8bcd7ee3db6cb5cb875
Cc: davem, herbert, linux-crypto, linux-kernel, syzkaller-bugs
Initialize the intermediary array member to 0 to prevent the kernel from
leaking uninitialized data to user space.
Reported-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e8bcd7ee3db6cb5cb875
Tested-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
crypto/jitterentropy-kcapi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
index c24d4ff2b4a8..9e9e069f55af 100644
--- a/crypto/jitterentropy-kcapi.c
+++ b/crypto/jitterentropy-kcapi.c
@@ -107,7 +107,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
{
struct shash_desc *hash_state_desc = (struct shash_desc *)hash_state;
SHASH_DESC_ON_STACK(desc, hash_state_desc->tfm);
- u8 intermediary[SHA3_256_DIGEST_SIZE];
+ u8 intermediary[SHA3_256_DIGEST_SIZE] = { 0 };
__u64 j = 0;
int ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] crypto: Prevent kernel-infoleak in rng_recvmsg
2025-08-09 9:59 ` [PATCH] crypto: Prevent " Edward Adam Davis
@ 2025-08-16 9:17 ` Herbert Xu
2025-08-17 8:51 ` Herbert Xu
2025-08-26 13:51 ` [PATCH] crypto: Prevent kernel-infoleak in rng_recvmsg Ard Biesheuvel
0 siblings, 2 replies; 15+ messages in thread
From: Herbert Xu @ 2025-08-16 9:17 UTC (permalink / raw)
To: Edward Adam Davis
Cc: syzbot+e8bcd7ee3db6cb5cb875, davem, linux-crypto, linux-kernel,
syzkaller-bugs
On Sat, Aug 09, 2025 at 05:59:43PM +0800, Edward Adam Davis wrote:
> Initialize the intermediary array member to 0 to prevent the kernel from
> leaking uninitialized data to user space.
>
> Reported-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=e8bcd7ee3db6cb5cb875
> Tested-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> crypto/jitterentropy-kcapi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
> index c24d4ff2b4a8..9e9e069f55af 100644
> --- a/crypto/jitterentropy-kcapi.c
> +++ b/crypto/jitterentropy-kcapi.c
> @@ -107,7 +107,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
> {
> struct shash_desc *hash_state_desc = (struct shash_desc *)hash_state;
> SHASH_DESC_ON_STACK(desc, hash_state_desc->tfm);
> - u8 intermediary[SHA3_256_DIGEST_SIZE];
> + u8 intermediary[SHA3_256_DIGEST_SIZE] = { 0 };
This is not a leak! The stack memroy is hashed and fed into the
entropy pool. If you can recover the original kernel memory from
the result, then we have much bigger problems :)
Please find a way to mark this as a false positive.
Thanks,
--
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] crypto: Prevent kernel-infoleak in rng_recvmsg
2025-08-16 9:17 ` Herbert Xu
@ 2025-08-17 8:51 ` Herbert Xu
2025-08-17 10:59 ` [PATCH V2] crypto: Mark intermediary memory as clean Edward Adam Davis
2025-08-26 13:51 ` [PATCH] crypto: Prevent kernel-infoleak in rng_recvmsg Ard Biesheuvel
1 sibling, 1 reply; 15+ messages in thread
From: Herbert Xu @ 2025-08-17 8:51 UTC (permalink / raw)
To: Edward Adam Davis
Cc: syzbot+e8bcd7ee3db6cb5cb875, davem, linux-crypto, linux-kernel,
syzkaller-bugs
On Sat, Aug 16, 2025 at 05:17:01PM +0800, Herbert Xu wrote:
> On Sat, Aug 09, 2025 at 05:59:43PM +0800, Edward Adam Davis wrote:
>
> > diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
> > index c24d4ff2b4a8..9e9e069f55af 100644
> > --- a/crypto/jitterentropy-kcapi.c
> > +++ b/crypto/jitterentropy-kcapi.c
> > @@ -107,7 +107,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
> > {
> > struct shash_desc *hash_state_desc = (struct shash_desc *)hash_state;
> > SHASH_DESC_ON_STACK(desc, hash_state_desc->tfm);
> > - u8 intermediary[SHA3_256_DIGEST_SIZE];
> > + u8 intermediary[SHA3_256_DIGEST_SIZE] = { 0 };
>
> This is not a leak! The stack memroy is hashed and fed into the
> entropy pool. If you can recover the original kernel memory from
> the result, then we have much bigger problems :)
>
> Please find a way to mark this as a false positive.
I think kmsan_unpoison_memory is the function that you should call.
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH V2] crypto: Mark intermediary memory as clean
2025-08-17 8:51 ` Herbert Xu
@ 2025-08-17 10:59 ` Edward Adam Davis
2025-08-17 11:40 ` Herbert Xu
0 siblings, 1 reply; 15+ messages in thread
From: Edward Adam Davis @ 2025-08-17 10:59 UTC (permalink / raw)
To: herbert
Cc: davem, eadavis, linux-crypto, linux-kernel,
syzbot+e8bcd7ee3db6cb5cb875, syzkaller-bugs
This is not a leak! The stack memroy is hashed and fed into the
entropy pool. We can't recover the original kernel memory from it.
Reported-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e8bcd7ee3db6cb5cb875
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
V1 -> V2: mark it as unpoison
crypto/jitterentropy-kcapi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
index 1266eb790708..4020a6e41b0e 100644
--- a/crypto/jitterentropy-kcapi.c
+++ b/crypto/jitterentropy-kcapi.c
@@ -117,6 +117,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
pr_warn_ratelimited("Unexpected digest size\n");
return -EINVAL;
}
+ kmsan_unpoison_memory(intermediary, SHA3_256_DIGEST_SIZE);
/*
* This loop fills a buffer which is injected into the entropy pool.
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH V2] crypto: Mark intermediary memory as clean
2025-08-17 10:59 ` [PATCH V2] crypto: Mark intermediary memory as clean Edward Adam Davis
@ 2025-08-17 11:40 ` Herbert Xu
2025-08-18 12:17 ` Edward Adam Davis
0 siblings, 1 reply; 15+ messages in thread
From: Herbert Xu @ 2025-08-17 11:40 UTC (permalink / raw)
To: Edward Adam Davis
Cc: davem, linux-crypto, linux-kernel, syzbot+e8bcd7ee3db6cb5cb875,
syzkaller-bugs
On Sun, Aug 17, 2025 at 06:59:15PM +0800, Edward Adam Davis wrote:
> This is not a leak! The stack memroy is hashed and fed into the
> entropy pool. We can't recover the original kernel memory from it.
>
> Reported-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=e8bcd7ee3db6cb5cb875
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> V1 -> V2: mark it as unpoison
>
> crypto/jitterentropy-kcapi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
> index 1266eb790708..4020a6e41b0e 100644
> --- a/crypto/jitterentropy-kcapi.c
> +++ b/crypto/jitterentropy-kcapi.c
> @@ -117,6 +117,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
> pr_warn_ratelimited("Unexpected digest size\n");
> return -EINVAL;
> }
> + kmsan_unpoison_memory(intermediary, SHA3_256_DIGEST_SIZE);
Please change SHA3_256_DIGEST_SIZE to sizeof(intermediary).
Thanks,
--
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH V2] crypto: Mark intermediary memory as clean
2025-08-17 11:40 ` Herbert Xu
@ 2025-08-18 12:17 ` Edward Adam Davis
2025-08-18 12:30 ` Herbert Xu
0 siblings, 1 reply; 15+ messages in thread
From: Edward Adam Davis @ 2025-08-18 12:17 UTC (permalink / raw)
To: herbert
Cc: davem, eadavis, linux-crypto, linux-kernel,
syzbot+e8bcd7ee3db6cb5cb875, syzkaller-bugs
On Sun, 17 Aug 2025 19:40:56 +0800, Herbert Xu wrote:
> > diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
> > index 1266eb790708..4020a6e41b0e 100644
> > --- a/crypto/jitterentropy-kcapi.c
> > +++ b/crypto/jitterentropy-kcapi.c
> > @@ -117,6 +117,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
> > pr_warn_ratelimited("Unexpected digest size\n");
> > return -EINVAL;
> > }
> > + kmsan_unpoison_memory(intermediary, SHA3_256_DIGEST_SIZE);
>
> Please change SHA3_256_DIGEST_SIZE to sizeof(intermediary).
Why?
Their values are equal, so why use sizeof to calculate?
Similarly, "if (sizeof(intermediary) != crypto_shash_digestsize(desc->tfm)) {",
why not just use SHA3_256_DIGEST_SIZE?
BR,
Edward
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH V2] crypto: Mark intermediary memory as clean
2025-08-18 12:17 ` Edward Adam Davis
@ 2025-08-18 12:30 ` Herbert Xu
2025-08-18 12:43 ` Edward Adam Davis
0 siblings, 1 reply; 15+ messages in thread
From: Herbert Xu @ 2025-08-18 12:30 UTC (permalink / raw)
To: Edward Adam Davis
Cc: davem, linux-crypto, linux-kernel, syzbot+e8bcd7ee3db6cb5cb875,
syzkaller-bugs
On Mon, Aug 18, 2025 at 08:17:17PM +0800, Edward Adam Davis wrote:
>
> Their values are equal, so why use sizeof to calculate?
> Similarly, "if (sizeof(intermediary) != crypto_shash_digestsize(desc->tfm)) {",
> why not just use SHA3_256_DIGEST_SIZE?
Please be consistent with the existing code, every other place
in the function uses sizeof(intermediary) so your patch is the
odd one out.
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH V2] crypto: Mark intermediary memory as clean
2025-08-18 12:30 ` Herbert Xu
@ 2025-08-18 12:43 ` Edward Adam Davis
2025-08-18 13:13 ` Stephan Mueller
0 siblings, 1 reply; 15+ messages in thread
From: Edward Adam Davis @ 2025-08-18 12:43 UTC (permalink / raw)
To: smueller
Cc: herbert, davem, eadavis, linux-crypto, linux-kernel,
syzbot+e8bcd7ee3db6cb5cb875, syzkaller-bugs
On Mon, 18 Aug 2025 20:30:29 +0800, Herbert Xu wrote:
> Their values are equal, so why use sizeof to calculate?
> Similarly, "if (sizeof(intermediary) != crypto_shash_digestsize(desc->tfm)) {",
> why not just use SHA3_256_DIGEST_SIZE?
Hi Stephan Mueller, can you explain it?
BR,
Edward
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH V2] crypto: Mark intermediary memory as clean
2025-08-18 12:43 ` Edward Adam Davis
@ 2025-08-18 13:13 ` Stephan Mueller
2025-08-18 13:24 ` [PATCH V3] " Edward Adam Davis
0 siblings, 1 reply; 15+ messages in thread
From: Stephan Mueller @ 2025-08-18 13:13 UTC (permalink / raw)
To: Edward Adam Davis
Cc: herbert, davem, eadavis, linux-crypto, linux-kernel,
syzbot+e8bcd7ee3db6cb5cb875, syzkaller-bugs
Am Montag, 18. August 2025, 14:43:36 Mitteleuropäische Sommerzeit schrieb
Edward Adam Davis:
Hi Edward,
> On Mon, 18 Aug 2025 20:30:29 +0800, Herbert Xu wrote:
> > Their values are equal, so why use sizeof to calculate?
> > Similarly, "if (sizeof(intermediary) !=
> > crypto_shash_digestsize(desc->tfm)) {", why not just use
> > SHA3_256_DIGEST_SIZE?
>
> Hi Stephan Mueller, can you explain it?
If the question is why using sizeof(intermediary) instead of
SHA3_256_DIGEST_SIZE, then it is very trivial: I always want to avoid any kind
of double work. If for any reason the buffer size of intermediary changes, the
current code only requires *one* location to fix it.
When changing the branching condition to use SHA3_256_DIGEST_SIZE, we would
have to change *two* locations which is more error-prone than to change one.
This approach is my common coding style to try to minimize the possibilities
where inconsistencies can occur.
Ciao
Stephan
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH V3] crypto: Mark intermediary memory as clean
2025-08-18 13:13 ` Stephan Mueller
@ 2025-08-18 13:24 ` Edward Adam Davis
2025-08-18 13:32 ` Stephan Mueller
2025-08-30 8:45 ` Herbert Xu
0 siblings, 2 replies; 15+ messages in thread
From: Edward Adam Davis @ 2025-08-18 13:24 UTC (permalink / raw)
To: smueller
Cc: davem, eadavis, herbert, linux-crypto, linux-kernel,
syzbot+e8bcd7ee3db6cb5cb875, syzkaller-bugs
This is not a leak! The stack memroy is hashed and fed into the
entropy pool. We can't recover the original kernel memory from it.
Reported-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e8bcd7ee3db6cb5cb875
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
V1 -> V2: mark it as unpoison
V2 -> V3: replace to sizeof, minimize the possibilities where inconsistencies can occur
crypto/jitterentropy-kcapi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
index 1266eb790708..4020a6e41b0e 100644
--- a/crypto/jitterentropy-kcapi.c
+++ b/crypto/jitterentropy-kcapi.c
@@ -117,6 +117,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
pr_warn_ratelimited("Unexpected digest size\n");
return -EINVAL;
}
+ kmsan_unpoison_memory(intermediary, sizeof(intermediary));
/*
* This loop fills a buffer which is injected into the entropy pool.
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH V3] crypto: Mark intermediary memory as clean
2025-08-18 13:24 ` [PATCH V3] " Edward Adam Davis
@ 2025-08-18 13:32 ` Stephan Mueller
2025-08-30 8:45 ` Herbert Xu
1 sibling, 0 replies; 15+ messages in thread
From: Stephan Mueller @ 2025-08-18 13:32 UTC (permalink / raw)
To: Edward Adam Davis
Cc: davem, eadavis, herbert, linux-crypto, linux-kernel,
syzbot+e8bcd7ee3db6cb5cb875, syzkaller-bugs
Am Montag, 18. August 2025, 15:24:17 Mitteleuropäische Sommerzeit schrieb
Edward Adam Davis:
Hi Edward,
> This is not a leak! The stack memroy is hashed and fed into the
> entropy pool. We can't recover the original kernel memory from it.
>
> Reported-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=e8bcd7ee3db6cb5cb875
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
Thank you for the patch. Just for the records:
- the intermediary buffer could be initialized to 0 without any effect on the
Jitter RNG, because all it wants is actually the execution of the Keccak
operation as part of crypto_shhash_finup.
- the intermediary buffer is inserted into the Jitter RNG state to ensure that
the compiler cannot optimize away the loop if the intermediary buffer would
not be used at all
- the intermediary buffer is not credited with any entropy as we only want the
Keccak operation
- by keeping the intermediary uninitialized, the Jitter RNG may get some
variations from the uninitialized buffer so that its internal state may
benefit from it
That said, I am fine with this current patch. But if there is still lingering
concern, I am equally fine to have it initialized to zero.
Thanks a lot
Stephan
> ---
> V1 -> V2: mark it as unpoison
> V2 -> V3: replace to sizeof, minimize the possibilities where
> inconsistencies can occur
>
> crypto/jitterentropy-kcapi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
> index 1266eb790708..4020a6e41b0e 100644
> --- a/crypto/jitterentropy-kcapi.c
> +++ b/crypto/jitterentropy-kcapi.c
> @@ -117,6 +117,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8
> *addtl, pr_warn_ratelimited("Unexpected digest size\n");
> return -EINVAL;
> }
> + kmsan_unpoison_memory(intermediary, sizeof(intermediary));
>
> /*
> * This loop fills a buffer which is injected into the entropy pool.
Ciao
Stephan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] crypto: Prevent kernel-infoleak in rng_recvmsg
2025-08-16 9:17 ` Herbert Xu
2025-08-17 8:51 ` Herbert Xu
@ 2025-08-26 13:51 ` Ard Biesheuvel
2025-08-26 16:58 ` Kees Cook
1 sibling, 1 reply; 15+ messages in thread
From: Ard Biesheuvel @ 2025-08-26 13:51 UTC (permalink / raw)
To: Herbert Xu, linux-hardening, Kees Cook
Cc: Edward Adam Davis, syzbot+e8bcd7ee3db6cb5cb875, davem,
linux-crypto, linux-kernel, syzkaller-bugs
(cc Kees)
On Sat, 16 Aug 2025 at 11:17, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Sat, Aug 09, 2025 at 05:59:43PM +0800, Edward Adam Davis wrote:
> > Initialize the intermediary array member to 0 to prevent the kernel from
> > leaking uninitialized data to user space.
> >
> > Reported-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
> > Closes: https://syzkaller.appspot.com/bug?extid=e8bcd7ee3db6cb5cb875
> > Tested-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
> > Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> > ---
> > crypto/jitterentropy-kcapi.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
> > index c24d4ff2b4a8..9e9e069f55af 100644
> > --- a/crypto/jitterentropy-kcapi.c
> > +++ b/crypto/jitterentropy-kcapi.c
> > @@ -107,7 +107,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
> > {
> > struct shash_desc *hash_state_desc = (struct shash_desc *)hash_state;
> > SHASH_DESC_ON_STACK(desc, hash_state_desc->tfm);
> > - u8 intermediary[SHA3_256_DIGEST_SIZE];
> > + u8 intermediary[SHA3_256_DIGEST_SIZE] = { 0 };
>
> This is not a leak! The stack memroy is hashed and fed into the
> entropy pool.
Is there still a point to doing this now that the compiler
zero-initializes automatic variables? Or does that not apply to u8
arrays? (asking Kees)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] crypto: Prevent kernel-infoleak in rng_recvmsg
2025-08-26 13:51 ` [PATCH] crypto: Prevent kernel-infoleak in rng_recvmsg Ard Biesheuvel
@ 2025-08-26 16:58 ` Kees Cook
0 siblings, 0 replies; 15+ messages in thread
From: Kees Cook @ 2025-08-26 16:58 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Herbert Xu, linux-hardening, Edward Adam Davis,
syzbot+e8bcd7ee3db6cb5cb875, davem, linux-crypto, linux-kernel,
syzkaller-bugs
On Tue, Aug 26, 2025 at 03:51:04PM +0200, Ard Biesheuvel wrote:
> (cc Kees)
>
> On Sat, 16 Aug 2025 at 11:17, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> >
> > On Sat, Aug 09, 2025 at 05:59:43PM +0800, Edward Adam Davis wrote:
> > > Initialize the intermediary array member to 0 to prevent the kernel from
> > > leaking uninitialized data to user space.
> > >
> > > Reported-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
> > > Closes: https://syzkaller.appspot.com/bug?extid=e8bcd7ee3db6cb5cb875
> > > Tested-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
> > > Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> > > ---
> > > crypto/jitterentropy-kcapi.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
> > > index c24d4ff2b4a8..9e9e069f55af 100644
> > > --- a/crypto/jitterentropy-kcapi.c
> > > +++ b/crypto/jitterentropy-kcapi.c
> > > @@ -107,7 +107,7 @@ int jent_hash_time(void *hash_state, __u64 time, u8 *addtl,
> > > {
> > > struct shash_desc *hash_state_desc = (struct shash_desc *)hash_state;
> > > SHASH_DESC_ON_STACK(desc, hash_state_desc->tfm);
> > > - u8 intermediary[SHA3_256_DIGEST_SIZE];
> > > + u8 intermediary[SHA3_256_DIGEST_SIZE] = { 0 };
> >
> > This is not a leak! The stack memroy is hashed and fed into the
> > entropy pool.
>
> Is there still a point to doing this now that the compiler
> zero-initializes automatic variables? Or does that not apply to u8
> arrays? (asking Kees)
Wait, the jitterentropy _depends_ on "uninitialized" stack contents?
That is not a safe way to get entropy (especially since the stack
contents are likely predictable). But regardless, yes, arrays would be
fully wiped by zero-initialized automatic variables.
To force it to be uninit, use __uninitialized.
--
Kees Cook
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH V3] crypto: Mark intermediary memory as clean
2025-08-18 13:24 ` [PATCH V3] " Edward Adam Davis
2025-08-18 13:32 ` Stephan Mueller
@ 2025-08-30 8:45 ` Herbert Xu
1 sibling, 0 replies; 15+ messages in thread
From: Herbert Xu @ 2025-08-30 8:45 UTC (permalink / raw)
To: Edward Adam Davis
Cc: smueller, davem, linux-crypto, linux-kernel,
syzbot+e8bcd7ee3db6cb5cb875, syzkaller-bugs
On Mon, Aug 18, 2025 at 09:24:17PM +0800, Edward Adam Davis wrote:
> This is not a leak! The stack memroy is hashed and fed into the
> entropy pool. We can't recover the original kernel memory from it.
>
> Reported-by: syzbot+e8bcd7ee3db6cb5cb875@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=e8bcd7ee3db6cb5cb875
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> V1 -> V2: mark it as unpoison
> V2 -> V3: replace to sizeof, minimize the possibilities where inconsistencies can occur
>
> crypto/jitterentropy-kcapi.c | 1 +
> 1 file changed, 1 insertion(+)
Patch applied. Thanks.
--
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
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2025-08-30 8:45 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-08 8:07 [syzbot] [crypto?] KMSAN: kernel-infoleak in rng_recvmsg syzbot
2025-08-09 9:59 ` [PATCH] crypto: Prevent " Edward Adam Davis
2025-08-16 9:17 ` Herbert Xu
2025-08-17 8:51 ` Herbert Xu
2025-08-17 10:59 ` [PATCH V2] crypto: Mark intermediary memory as clean Edward Adam Davis
2025-08-17 11:40 ` Herbert Xu
2025-08-18 12:17 ` Edward Adam Davis
2025-08-18 12:30 ` Herbert Xu
2025-08-18 12:43 ` Edward Adam Davis
2025-08-18 13:13 ` Stephan Mueller
2025-08-18 13:24 ` [PATCH V3] " Edward Adam Davis
2025-08-18 13:32 ` Stephan Mueller
2025-08-30 8:45 ` Herbert Xu
2025-08-26 13:51 ` [PATCH] crypto: Prevent kernel-infoleak in rng_recvmsg Ard Biesheuvel
2025-08-26 16:58 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).