[syzbot] [erofs?] BUG: using smp_processor_id() in preemptible code in z_erofs_get_gbuf

Edward Adam Davis posted 1 patch 1 year, 10 months ago
[syzbot] [erofs?] BUG: using smp_processor_id() in preemptible code in z_erofs_get_gbuf
Posted by Edward Adam Davis 1 year, 10 months ago
please test wrong context using smp_processor_id

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 2b3d5988ae2c

diff --git a/fs/erofs/zutil.c b/fs/erofs/zutil.c
index 9687cad8be96..0a3d9eecbf16 100644
--- a/fs/erofs/zutil.c
+++ b/fs/erofs/zutil.c
@@ -35,8 +35,11 @@ void *z_erofs_get_gbuf(unsigned int requiredpages)
 	__acquires(gbuf->lock)
 {
 	struct z_erofs_gbuf *gbuf;
+	unsigned long flags;
 
+	local_irq_save(flags);
 	gbuf = &z_erofs_gbufpool[z_erofs_gbuf_id()];
+	local_irq_restore(flags);
 	spin_lock(&gbuf->lock);
 	/* check if the buffer is too small */
 	if (requiredpages > gbuf->nrpages) {
Re: [syzbot] [erofs?] BUG: using smp_processor_id() in preemptible code in z_erofs_get_gbuf
Posted by syzbot 1 year, 10 months ago
Hello,

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

Reported-and-tested-by: syzbot+27cc650ef45b379dfe5a@syzkaller.appspotmail.com

Tested on:

commit:         2b3d5988 Add linux-next specific files for 20240404
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
console output: https://syzkaller.appspot.com/x/log.txt?x=156898b9180000
kernel config:  https://syzkaller.appspot.com/x/.config?x=9c48fd2523cdee5e
dashboard link: https://syzkaller.appspot.com/bug?extid=27cc650ef45b379dfe5a
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=138af0b9180000

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