[syzbot] [erofs?] BUG: using smp_processor_id() in preemptible code in z_erofs_get_gbuf
From: Edward Adam Davis
Date: Mon Apr 08 2024 - 21:16:39 EST
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) {