linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [syzbot] [integrity?] [lsm?] KMSAN: uninit-value in ima_add_template_entry (2)
@ 2024-10-02  7:26 syzbot
  2024-10-02  7:56 ` Roberto Sassu
  2024-10-13 19:06 ` syzbot
  0 siblings, 2 replies; 5+ messages in thread
From: syzbot @ 2024-10-02  7:26 UTC (permalink / raw)
  To: dmitry.kasatkin, eric.snowberg, jmorris, linux-integrity,
	linux-kernel, linux-security-module, paul, roberto.sassu, serge,
	syzkaller-bugs, zohar

Hello,

syzbot found the following issue on:

HEAD commit:    ad46e8f95e93 Merge tag 'pm-6.12-rc1-2' of git://git.kernel..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1177d507980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=85d8f50d88ddf2a
dashboard link: https://syzkaller.appspot.com/bug?extid=91ae49e1c1a2634d20c0
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=106026a9980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/265feec46ffa/disk-ad46e8f9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d0f41ea693d3/vmlinux-ad46e8f9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/45082d33d192/bzImage-ad46e8f9.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/5b5b4e4b4ff9/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+91ae49e1c1a2634d20c0@syzkaller.appspotmail.com

=====================================================
BUG: KMSAN: uninit-value in ima_add_template_entry+0x52b/0x880 security/integrity/ima/ima_queue.c:172
 ima_add_template_entry+0x52b/0x880 security/integrity/ima/ima_queue.c:172
 ima_store_template security/integrity/ima/ima_api.c:122 [inline]
 ima_store_measurement+0x36b/0x8d0 security/integrity/ima/ima_api.c:383
 process_measurement+0x2c11/0x3f30 security/integrity/ima/ima_main.c:380
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3127
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

<Zero or more stacks not recorded to save memory>

Uninit was stored to memory at:
 sha256_transform lib/crypto/sha256.c:117 [inline]
 sha256_transform_blocks+0x2dbf/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3127
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 sha256_transform lib/crypto/sha256.c:117 [inline]
 sha256_transform_blocks+0x2dbf/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3127
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 BLEND_OP lib/crypto/sha256.c:61 [inline]
 sha256_transform lib/crypto/sha256.c:91 [inline]
 sha256_transform_blocks+0xf33/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3127
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 BLEND_OP lib/crypto/sha256.c:61 [inline]
 sha256_transform lib/crypto/sha256.c:92 [inline]
 sha256_transform_blocks+0xf7d/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3127
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 BLEND_OP lib/crypto/sha256.c:61 [inline]
 sha256_transform lib/crypto/sha256.c:93 [inline]
 sha256_transform_blocks+0xfb5/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3127
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 LOAD_OP lib/crypto/sha256.c:56 [inline]
 sha256_transform lib/crypto/sha256.c:82 [inline]
 sha256_transform_blocks+0x2c35/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3127
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 memcpy_to_iter lib/iov_iter.c:65 [inline]
 iterate_kvec include/linux/iov_iter.h:86 [inline]
 iterate_and_advance2 include/linux/iov_iter.h:306 [inline]
 iterate_and_advance include/linux/iov_iter.h:328 [inline]
 _copy_to_iter+0x124a/0x2b30 lib/iov_iter.c:185
 copy_page_to_iter+0x419/0x880 lib/iov_iter.c:362
 copy_folio_to_iter include/linux/uio.h:189 [inline]
 filemap_read+0xc13/0x1500 mm/filemap.c:2696
 generic_file_read_iter+0x136/0xad0 mm/filemap.c:2833
 __kernel_read+0x726/0xd30 fs/read_write.c:527
 integrity_kernel_read+0x77/0x90 security/integrity/iint.c:28
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:480 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1731/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3127
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was created at:
 __alloc_pages_noprof+0x9d6/0xe70 mm/page_alloc.c:4756
 alloc_pages_mpol_noprof+0x299/0x990 mm/mempolicy.c:2265
 alloc_pages_noprof mm/mempolicy.c:2345 [inline]
 folio_alloc_noprof+0x1db/0x310 mm/mempolicy.c:2352
 filemap_alloc_folio_noprof+0xa6/0x440 mm/filemap.c:1010
 __filemap_get_folio+0xac4/0x1550 mm/filemap.c:1952
 block_write_begin+0x6e/0x2b0 fs/buffer.c:2226
 exfat_write_begin+0xfb/0x400 fs/exfat/inode.c:434
 exfat_extend_valid_size fs/exfat/file.c:553 [inline]
 exfat_file_write_iter+0x474/0xfb0 fs/exfat/file.c:588
 new_sync_write fs/read_write.c:590 [inline]
 vfs_write+0xb28/0x1540 fs/read_write.c:683
 ksys_write+0x24f/0x4c0 fs/read_write.c:736
 __do_sys_write fs/read_write.c:748 [inline]
 __se_sys_write fs/read_write.c:745 [inline]
 __x64_sys_write+0x93/0xe0 fs/read_write.c:745
 x64_sys_call+0x306a/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:2
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

CPU: 1 UID: 0 PID: 7910 Comm: syz.2.975 Not tainted 6.11.0-syzkaller-11728-gad46e8f95e93 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
=====================================================


---
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] 5+ messages in thread

* Re: [syzbot] [integrity?] [lsm?] KMSAN: uninit-value in ima_add_template_entry (2)
  2024-10-02  7:26 [syzbot] [integrity?] [lsm?] KMSAN: uninit-value in ima_add_template_entry (2) syzbot
@ 2024-10-02  7:56 ` Roberto Sassu
  2024-10-13 19:06 ` syzbot
  1 sibling, 0 replies; 5+ messages in thread
From: Roberto Sassu @ 2024-10-02  7:56 UTC (permalink / raw)
  To: syzbot, dmitry.kasatkin, eric.snowberg, jmorris, linux-integrity,
	linux-kernel, linux-security-module, paul, roberto.sassu, serge,
	syzkaller-bugs, zohar, willy, Yuezhang.Mo

On Wed, 2024-10-02 at 00:26 -0700, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    ad46e8f95e93 Merge tag 'pm-6.12-rc1-2' of git://git.kernel..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1177d507980000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=85d8f50d88ddf2a
> dashboard link: https://syzkaller.appspot.com/bug?extid=91ae49e1c1a2634d20c0
> compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=106026a9980000

At a first look, it seems that IMA is measuring an uninitialized buffer
from exfat.

Uninit was created at:
 __alloc_pages_noprof+0x9d6/0xe70 mm/page_alloc.c:4756
 alloc_pages_mpol_noprof+0x299/0x990 mm/mempolicy.c:2265
 alloc_pages_noprof mm/mempolicy.c:2345 [inline]
 folio_alloc_noprof+0x1db/0x310 mm/mempolicy.c:2352
 filemap_alloc_folio_noprof+0xa6/0x440 mm/filemap.c:1010
 __filemap_get_folio+0xac4/0x1550 mm/filemap.c:1952
 block_write_begin+0x6e/0x2b0 fs/buffer.c:2226

I saw there are some relevant commits in this area from the latest PRs.

Matthew, Yuezhang, could you please have a look?

Thanks!

Roberto

> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/265feec46ffa/disk-ad46e8f9.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/d0f41ea693d3/vmlinux-ad46e8f9.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/45082d33d192/bzImage-ad46e8f9.xz
> mounted in repro: https://storage.googleapis.com/syzbot-assets/5b5b4e4b4ff9/mount_0.gz
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+91ae49e1c1a2634d20c0@syzkaller.appspotmail.com
> 
> =====================================================
> BUG: KMSAN: uninit-value in ima_add_template_entry+0x52b/0x880 security/integrity/ima/ima_queue.c:172
>  ima_add_template_entry+0x52b/0x880 security/integrity/ima/ima_queue.c:172
>  ima_store_template security/integrity/ima/ima_api.c:122 [inline]
>  ima_store_measurement+0x36b/0x8d0 security/integrity/ima/ima_api.c:383
>  process_measurement+0x2c11/0x3f30 security/integrity/ima/ima_main.c:380
>  ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
>  security_file_post_open+0xc6/0x540 security/security.c:3127
>  do_open fs/namei.c:3776 [inline]
>  path_openat+0x58cc/0x6200 fs/namei.c:3933
>  do_filp_open+0x20e/0x590 fs/namei.c:3960
>  do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
>  do_sys_open fs/open.c:1430 [inline]
>  __do_sys_open fs/open.c:1438 [inline]
>  __se_sys_open fs/open.c:1434 [inline]
>  __x64_sys_open+0x275/0x2d0 fs/open.c:1434
>  x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> <Zero or more stacks not recorded to save memory>
> 
> Uninit was stored to memory at:
>  sha256_transform lib/crypto/sha256.c:117 [inline]
>  sha256_transform_blocks+0x2dbf/0x2e90 lib/crypto/sha256.c:127
>  lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
>  sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
>  crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
>  crypto_shash_update+0x79/0xa0 crypto/shash.c:52
>  ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
>  ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
>  ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
>  ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
>  process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
>  ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
>  security_file_post_open+0xc6/0x540 security/security.c:3127
>  do_open fs/namei.c:3776 [inline]
>  path_openat+0x58cc/0x6200 fs/namei.c:3933
>  do_filp_open+0x20e/0x590 fs/namei.c:3960
>  do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
>  do_sys_open fs/open.c:1430 [inline]
>  __do_sys_open fs/open.c:1438 [inline]
>  __se_sys_open fs/open.c:1434 [inline]
>  __x64_sys_open+0x275/0x2d0 fs/open.c:1434
>  x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> Uninit was stored to memory at:
>  sha256_transform lib/crypto/sha256.c:117 [inline]
>  sha256_transform_blocks+0x2dbf/0x2e90 lib/crypto/sha256.c:127
>  lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
>  sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
>  crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
>  crypto_shash_update+0x79/0xa0 crypto/shash.c:52
>  ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
>  ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
>  ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
>  ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
>  process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
>  ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
>  security_file_post_open+0xc6/0x540 security/security.c:3127
>  do_open fs/namei.c:3776 [inline]
>  path_openat+0x58cc/0x6200 fs/namei.c:3933
>  do_filp_open+0x20e/0x590 fs/namei.c:3960
>  do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
>  do_sys_open fs/open.c:1430 [inline]
>  __do_sys_open fs/open.c:1438 [inline]
>  __se_sys_open fs/open.c:1434 [inline]
>  __x64_sys_open+0x275/0x2d0 fs/open.c:1434
>  x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> Uninit was stored to memory at:
>  BLEND_OP lib/crypto/sha256.c:61 [inline]
>  sha256_transform lib/crypto/sha256.c:91 [inline]
>  sha256_transform_blocks+0xf33/0x2e90 lib/crypto/sha256.c:127
>  lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
>  sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
>  crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
>  crypto_shash_update+0x79/0xa0 crypto/shash.c:52
>  ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
>  ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
>  ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
>  ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
>  process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
>  ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
>  security_file_post_open+0xc6/0x540 security/security.c:3127
>  do_open fs/namei.c:3776 [inline]
>  path_openat+0x58cc/0x6200 fs/namei.c:3933
>  do_filp_open+0x20e/0x590 fs/namei.c:3960
>  do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
>  do_sys_open fs/open.c:1430 [inline]
>  __do_sys_open fs/open.c:1438 [inline]
>  __se_sys_open fs/open.c:1434 [inline]
>  __x64_sys_open+0x275/0x2d0 fs/open.c:1434
>  x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> Uninit was stored to memory at:
>  BLEND_OP lib/crypto/sha256.c:61 [inline]
>  sha256_transform lib/crypto/sha256.c:92 [inline]
>  sha256_transform_blocks+0xf7d/0x2e90 lib/crypto/sha256.c:127
>  lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
>  sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
>  crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
>  crypto_shash_update+0x79/0xa0 crypto/shash.c:52
>  ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
>  ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
>  ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
>  ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
>  process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
>  ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
>  security_file_post_open+0xc6/0x540 security/security.c:3127
>  do_open fs/namei.c:3776 [inline]
>  path_openat+0x58cc/0x6200 fs/namei.c:3933
>  do_filp_open+0x20e/0x590 fs/namei.c:3960
>  do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
>  do_sys_open fs/open.c:1430 [inline]
>  __do_sys_open fs/open.c:1438 [inline]
>  __se_sys_open fs/open.c:1434 [inline]
>  __x64_sys_open+0x275/0x2d0 fs/open.c:1434
>  x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> Uninit was stored to memory at:
>  BLEND_OP lib/crypto/sha256.c:61 [inline]
>  sha256_transform lib/crypto/sha256.c:93 [inline]
>  sha256_transform_blocks+0xfb5/0x2e90 lib/crypto/sha256.c:127
>  lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
>  sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
>  crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
>  crypto_shash_update+0x79/0xa0 crypto/shash.c:52
>  ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
>  ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
>  ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
>  ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
>  process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
>  ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
>  security_file_post_open+0xc6/0x540 security/security.c:3127
>  do_open fs/namei.c:3776 [inline]
>  path_openat+0x58cc/0x6200 fs/namei.c:3933
>  do_filp_open+0x20e/0x590 fs/namei.c:3960
>  do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
>  do_sys_open fs/open.c:1430 [inline]
>  __do_sys_open fs/open.c:1438 [inline]
>  __se_sys_open fs/open.c:1434 [inline]
>  __x64_sys_open+0x275/0x2d0 fs/open.c:1434
>  x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> Uninit was stored to memory at:
>  LOAD_OP lib/crypto/sha256.c:56 [inline]
>  sha256_transform lib/crypto/sha256.c:82 [inline]
>  sha256_transform_blocks+0x2c35/0x2e90 lib/crypto/sha256.c:127
>  lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
>  sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
>  crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
>  crypto_shash_update+0x79/0xa0 crypto/shash.c:52
>  ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
>  ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
>  ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
>  ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
>  process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
>  ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
>  security_file_post_open+0xc6/0x540 security/security.c:3127
>  do_open fs/namei.c:3776 [inline]
>  path_openat+0x58cc/0x6200 fs/namei.c:3933
>  do_filp_open+0x20e/0x590 fs/namei.c:3960
>  do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
>  do_sys_open fs/open.c:1430 [inline]
>  __do_sys_open fs/open.c:1438 [inline]
>  __se_sys_open fs/open.c:1434 [inline]
>  __x64_sys_open+0x275/0x2d0 fs/open.c:1434
>  x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> Uninit was stored to memory at:
>  memcpy_to_iter lib/iov_iter.c:65 [inline]
>  iterate_kvec include/linux/iov_iter.h:86 [inline]
>  iterate_and_advance2 include/linux/iov_iter.h:306 [inline]
>  iterate_and_advance include/linux/iov_iter.h:328 [inline]
>  _copy_to_iter+0x124a/0x2b30 lib/iov_iter.c:185
>  copy_page_to_iter+0x419/0x880 lib/iov_iter.c:362
>  copy_folio_to_iter include/linux/uio.h:189 [inline]
>  filemap_read+0xc13/0x1500 mm/filemap.c:2696
>  generic_file_read_iter+0x136/0xad0 mm/filemap.c:2833
>  __kernel_read+0x726/0xd30 fs/read_write.c:527
>  integrity_kernel_read+0x77/0x90 security/integrity/iint.c:28
>  ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:480 [inline]
>  ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
>  ima_calc_file_hash+0x1731/0x3c90 security/integrity/ima/ima_crypto.c:568
>  ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
>  process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
>  ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
>  security_file_post_open+0xc6/0x540 security/security.c:3127
>  do_open fs/namei.c:3776 [inline]
>  path_openat+0x58cc/0x6200 fs/namei.c:3933
>  do_filp_open+0x20e/0x590 fs/namei.c:3960
>  do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
>  do_sys_open fs/open.c:1430 [inline]
>  __do_sys_open fs/open.c:1438 [inline]
>  __se_sys_open fs/open.c:1434 [inline]
>  __x64_sys_open+0x275/0x2d0 fs/open.c:1434
>  x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> Uninit was created at:
>  __alloc_pages_noprof+0x9d6/0xe70 mm/page_alloc.c:4756
>  alloc_pages_mpol_noprof+0x299/0x990 mm/mempolicy.c:2265
>  alloc_pages_noprof mm/mempolicy.c:2345 [inline]
>  folio_alloc_noprof+0x1db/0x310 mm/mempolicy.c:2352
>  filemap_alloc_folio_noprof+0xa6/0x440 mm/filemap.c:1010
>  __filemap_get_folio+0xac4/0x1550 mm/filemap.c:1952
>  block_write_begin+0x6e/0x2b0 fs/buffer.c:2226
>  exfat_write_begin+0xfb/0x400 fs/exfat/inode.c:434
>  exfat_extend_valid_size fs/exfat/file.c:553 [inline]
>  exfat_file_write_iter+0x474/0xfb0 fs/exfat/file.c:588
>  new_sync_write fs/read_write.c:590 [inline]
>  vfs_write+0xb28/0x1540 fs/read_write.c:683
>  ksys_write+0x24f/0x4c0 fs/read_write.c:736
>  __do_sys_write fs/read_write.c:748 [inline]
>  __se_sys_write fs/read_write.c:745 [inline]
>  __x64_sys_write+0x93/0xe0 fs/read_write.c:745
>  x64_sys_call+0x306a/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:2
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> CPU: 1 UID: 0 PID: 7910 Comm: syz.2.975 Not tainted 6.11.0-syzkaller-11728-gad46e8f95e93 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
> =====================================================
> 
> 
> ---
> 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] 5+ messages in thread

* Re: [syzbot] [integrity?] [lsm?] KMSAN: uninit-value in ima_add_template_entry (2)
  2024-10-02  7:26 [syzbot] [integrity?] [lsm?] KMSAN: uninit-value in ima_add_template_entry (2) syzbot
  2024-10-02  7:56 ` Roberto Sassu
@ 2024-10-13 19:06 ` syzbot
  2024-12-12  9:04   ` Yuezhang.Mo
  1 sibling, 1 reply; 5+ messages in thread
From: syzbot @ 2024-10-13 19:06 UTC (permalink / raw)
  To: dmitry.kasatkin, eric.snowberg, jmorris, linux-integrity,
	linux-kernel, linux-security-module, paul, roberto.sassu,
	roberto.sassu, serge, syzkaller-bugs, willy, yuezhang.mo, zohar

syzbot has found a reproducer for the following issue on:

HEAD commit:    36c254515dc6 Merge tag 'powerpc-6.12-4' of git://git.kerne..
git tree:       upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=13ba885f980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=981fe2ff8a1e457a
dashboard link: https://syzkaller.appspot.com/bug?extid=91ae49e1c1a2634d20c0
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=10eb8727980000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=157e5087980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/ea807517ae2f/disk-36c25451.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5f30861c9c3c/vmlinux-36c25451.xz
kernel image: https://storage.googleapis.com/syzbot-assets/8b5ef63bff6f/bzImage-36c25451.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/5402f23c14ef/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+91ae49e1c1a2634d20c0@syzkaller.appspotmail.com

=====================================================
BUG: KMSAN: uninit-value in ima_add_template_entry+0x52b/0x880 security/integrity/ima/ima_queue.c:172
 ima_add_template_entry+0x52b/0x880 security/integrity/ima/ima_queue.c:172
 ima_store_template security/integrity/ima/ima_api.c:122 [inline]
 ima_store_measurement+0x36b/0x8d0 security/integrity/ima/ima_api.c:383
 process_measurement+0x2c11/0x3f30 security/integrity/ima/ima_main.c:380
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3129
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

<Zero or more stacks not recorded to save memory>

Uninit was stored to memory at:
 sha256_transform lib/crypto/sha256.c:117 [inline]
 sha256_transform_blocks+0x2dbf/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3129
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 sha256_transform lib/crypto/sha256.c:117 [inline]
 sha256_transform_blocks+0x2dbf/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3129
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 BLEND_OP lib/crypto/sha256.c:61 [inline]
 sha256_transform lib/crypto/sha256.c:91 [inline]
 sha256_transform_blocks+0xf33/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3129
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 BLEND_OP lib/crypto/sha256.c:61 [inline]
 sha256_transform lib/crypto/sha256.c:92 [inline]
 sha256_transform_blocks+0xf7d/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3129
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 BLEND_OP lib/crypto/sha256.c:61 [inline]
 sha256_transform lib/crypto/sha256.c:93 [inline]
 sha256_transform_blocks+0xfb5/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3129
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 LOAD_OP lib/crypto/sha256.c:56 [inline]
 sha256_transform lib/crypto/sha256.c:82 [inline]
 sha256_transform_blocks+0x2c35/0x2e90 lib/crypto/sha256.c:127
 lib_sha256_base_do_update include/crypto/sha256_base.h:63 [inline]
 sha256_update+0x2ff/0x340 lib/crypto/sha256.c:136
 crypto_sha256_update+0x37/0x60 crypto/sha256_generic.c:39
 crypto_shash_update+0x79/0xa0 crypto/shash.c:52
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:491 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1804/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3129
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was stored to memory at:
 memcpy_to_iter lib/iov_iter.c:65 [inline]
 iterate_kvec include/linux/iov_iter.h:86 [inline]
 iterate_and_advance2 include/linux/iov_iter.h:306 [inline]
 iterate_and_advance include/linux/iov_iter.h:328 [inline]
 _copy_to_iter+0x124a/0x2b30 lib/iov_iter.c:185
 copy_page_to_iter+0x419/0x880 lib/iov_iter.c:362
 copy_folio_to_iter include/linux/uio.h:189 [inline]
 filemap_read+0xc13/0x1500 mm/filemap.c:2696
 generic_file_read_iter+0x136/0xad0 mm/filemap.c:2833
 __kernel_read+0x726/0xd30 fs/read_write.c:527
 integrity_kernel_read+0x77/0x90 security/integrity/iint.c:28
 ima_calc_file_hash_tfm security/integrity/ima/ima_crypto.c:480 [inline]
 ima_calc_file_shash security/integrity/ima/ima_crypto.c:511 [inline]
 ima_calc_file_hash+0x1731/0x3c90 security/integrity/ima/ima_crypto.c:568
 ima_collect_measurement+0x464/0xd20 security/integrity/ima/ima_api.c:293
 process_measurement+0x2948/0x3f30 security/integrity/ima/ima_main.c:372
 ima_file_check+0xb4/0x100 security/integrity/ima/ima_main.c:572
 security_file_post_open+0xc6/0x540 security/security.c:3129
 do_open fs/namei.c:3776 [inline]
 path_openat+0x58cc/0x6200 fs/namei.c:3933
 do_filp_open+0x20e/0x590 fs/namei.c:3960
 do_sys_openat2+0x1bf/0x2f0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_open fs/open.c:1438 [inline]
 __se_sys_open fs/open.c:1434 [inline]
 __x64_sys_open+0x275/0x2d0 fs/open.c:1434
 x64_sys_call+0x15a2/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:3
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Uninit was created at:
 __alloc_pages_noprof+0x9a7/0xe00 mm/page_alloc.c:4756
 alloc_pages_mpol_noprof+0x299/0x990 mm/mempolicy.c:2265
 alloc_pages_noprof mm/mempolicy.c:2345 [inline]
 folio_alloc_noprof+0x1db/0x310 mm/mempolicy.c:2352
 filemap_alloc_folio_noprof+0xa6/0x440 mm/filemap.c:1010
 __filemap_get_folio+0xac4/0x1550 mm/filemap.c:1952
 block_write_begin+0x6e/0x2b0 fs/buffer.c:2226
 exfat_write_begin+0xfb/0x400 fs/exfat/inode.c:434
 exfat_extend_valid_size fs/exfat/file.c:553 [inline]
 exfat_file_write_iter+0x474/0xfb0 fs/exfat/file.c:588
 do_iter_readv_writev+0x88a/0xa30
 vfs_writev+0x56a/0x14f0 fs/read_write.c:1064
 do_pwritev fs/read_write.c:1165 [inline]
 __do_sys_pwritev2 fs/read_write.c:1224 [inline]
 __se_sys_pwritev2+0x280/0x470 fs/read_write.c:1215
 __x64_sys_pwritev2+0x11f/0x1a0 fs/read_write.c:1215
 x64_sys_call+0x2edb/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:329
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

CPU: 0 UID: 0 PID: 5186 Comm: syz-executor173 Not tainted 6.12.0-rc2-syzkaller-00307-g36c254515dc6 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
=====================================================


---
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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] [integrity?] [lsm?] KMSAN: uninit-value in ima_add_template_entry (2)
  2024-10-13 19:06 ` syzbot
@ 2024-12-12  9:04   ` Yuezhang.Mo
  2024-12-12 11:21     ` [syzbot] [lsm?] [integrity?] " syzbot
  0 siblings, 1 reply; 5+ messages in thread
From: Yuezhang.Mo @ 2024-12-12  9:04 UTC (permalink / raw)
  To: syzbot, dmitry.kasatkin@gmail.com, eric.snowberg@oracle.com,
	jmorris@namei.org, linux-integrity@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org, paul@paul-moore.com,
	roberto.sassu@huawei.com, roberto.sassu@huaweicloud.com,
	serge@hallyn.com, syzkaller-bugs@googlegroups.com,
	willy@infradead.org, zohar@linux.ibm.com

[-- Attachment #1: Type: text/plain, Size: 9 bytes --]

#syz test

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: v1-0001-exfat-zero-new-buffer.patch --]
[-- Type: text/x-patch; name="v1-0001-exfat-zero-new-buffer.patch", Size: 1196 bytes --]

From 51b0e3cfc5c0c4ac0000ff97d236d2434618f7fc Mon Sep 17 00:00:00 2001
From: Yuezhang Mo <Yuezhang.Mo@sony.com>
Date: Thu, 12 Dec 2024 16:29:23 +0800
Subject: [PATCH v1] exfat: zero new buffer

Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
---
 fs/exfat/file.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index a25d7eb789f4..d91437831835 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -545,6 +545,7 @@ static int exfat_extend_valid_size(struct file *file, loff_t new_valid_size)
 	while (pos < new_valid_size) {
 		u32 len;
 		struct folio *folio;
+		unsigned long off;
 
 		len = PAGE_SIZE - (pos & (PAGE_SIZE - 1));
 		if (pos + len > new_valid_size)
@@ -554,6 +555,9 @@ static int exfat_extend_valid_size(struct file *file, loff_t new_valid_size)
 		if (err)
 			goto out;
 
+		off = offset_in_folio(folio, pos);
+		folio_zero_new_buffers(folio, off, off + len);
+
 		err = ops->write_end(file, mapping, pos, len, len, folio, NULL);
 		if (err < 0)
 			goto out;
@@ -563,6 +567,8 @@ static int exfat_extend_valid_size(struct file *file, loff_t new_valid_size)
 		cond_resched();
 	}
 
+	return 0;
+
 out:
 	return err;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [syzbot] [lsm?] [integrity?] KMSAN: uninit-value in ima_add_template_entry (2)
  2024-12-12  9:04   ` Yuezhang.Mo
@ 2024-12-12 11:21     ` syzbot
  0 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2024-12-12 11:21 UTC (permalink / raw)
  To: dmitry.kasatkin, eric.snowberg, jmorris, linux-integrity,
	linux-kernel, linux-security-module, paul, roberto.sassu,
	roberto.sassu, serge, syzkaller-bugs, willy, yuezhang.mo, zohar

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+91ae49e1c1a2634d20c0@syzkaller.appspotmail.com
Tested-by: syzbot+91ae49e1c1a2634d20c0@syzkaller.appspotmail.com

Tested on:

commit:         231825b2 Revert "unicode: Don't special case ignorable..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11b56cdf980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=b2d5bd2f63a4859d
dashboard link: https://syzkaller.appspot.com/bug?extid=91ae49e1c1a2634d20c0
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=133e6cdf980000

Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-12-12 11:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02  7:26 [syzbot] [integrity?] [lsm?] KMSAN: uninit-value in ima_add_template_entry (2) syzbot
2024-10-02  7:56 ` Roberto Sassu
2024-10-13 19:06 ` syzbot
2024-12-12  9:04   ` Yuezhang.Mo
2024-12-12 11:21     ` [syzbot] [lsm?] [integrity?] " syzbot

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).