diff mbox series

mm: fix missed initialization for folio_batch::percpu_pvec_drained

Message ID 20220116070227.6854-1-changbin.du@gmail.com (mailing list archive)
State New
Headers show
Series mm: fix missed initialization for folio_batch::percpu_pvec_drained | expand

Commit Message

Changbin Du Jan. 16, 2022, 7:02 a.m. UTC
The folio_batch_init() forgets to initinize folio_batch::percpu_pvec_drained.
This can be detected by UBSAN tool.
[    6.990914][    T1] ========================================================================
[    6.991968][    T1] UBSAN: invalid-load in mm/swap.c:996:11
[    6.993429][    T1] load of value 124 is not a valid value for type '_Bool'
[    6.994774][    T1] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.16.0-09673-ga33f5c380c4b #27
[    6.995909][    T1] Hardware name: riscv-virtio,qemu (DT)
[    6.996898][    T1] Call Trace:
[    6.997608][    T1] [<ffffffff80005ee6>] dump_backtrace+0x30/0x38
[    6.998307][    T1] [<ffffffff80912a9a>] dump_stack_lvl+0x58/0x7a
[    6.998822][    T1] [<ffffffff80912ad4>] dump_stack+0x18/0x20
[    6.999334][    T1] [<ffffffff8091276e>] ubsan_epilogue+0x10/0x58
[    6.999938][    T1] [<ffffffff8052f84a>] __ubsan_handle_load_invalid_value+0x84/0x86
[    7.000626][    T1] [<ffffffff801927ea>] __pagevec_release+0x6c/0x72
[    7.001212][    T1] [<ffffffff80193776>] truncate_inode_pages_range+0x152/0x4a6
[    7.001839][    T1] [<ffffffff80193aec>] truncate_inode_pages+0x22/0x2a
[    7.002397][    T1] [<ffffffff8045fb60>] blkdev_flush_mapping+0x78/0x13e
[    7.002960][    T1] [<ffffffff80460046>] blkdev_put+0x1a6/0x1f8
[    7.003482][    T1] [<ffffffff804811c2>] disk_scan_partitions+0x5c/0x78
[    7.004069][    T1] [<ffffffff8048147e>] device_add_disk+0x2a0/0x2c0
[    7.004627][    T1] [<ffffffff8060f2a6>] virtblk_probe+0x68c/0xb20
[    7.005176][    T1] [<ffffffff805989dc>] virtio_dev_probe+0x12e/0x210
[    7.005718][    T1] [<ffffffff805eba02>] really_probe.part.0+0x6c/0x24e
[    7.006266][    T1] [<ffffffff805ebcc0>] __driver_probe_device+0xdc/0x13e
[    7.006847][    T1] [<ffffffff805ebd62>] driver_probe_device+0x40/0x10c
[    7.007451][    T1] [<ffffffff805ec5a2>] __driver_attach+0x8c/0x172
[    7.008036][    T1] [<ffffffff805e946a>] bus_for_each_dev+0x6a/0xa8
[    7.008617][    T1] [<ffffffff805eb140>] driver_attach+0x2e/0x36
[    7.009159][    T1] [<ffffffff805eab80>] bus_add_driver+0x170/0x1ee
[    7.009717][    T1] [<ffffffff805ece74>] driver_register+0x66/0xfe
[    7.010295][    T1] [<ffffffff805987fa>] register_virtio_driver+0x30/0x4e
[    7.010899][    T1] [<ffffffff80a2a116>] init+0x78/0xac
[    7.011381][    T1] [<ffffffff800025e8>] do_one_initcall+0x7e/0x262
[    7.011955][    T1] [<ffffffff80a0197e>] kernel_init_freeable+0x30e/0x372
[    7.012559][    T1] [<ffffffff8091846a>] kernel_init+0x32/0x178
[    7.013105][    T1] [<ffffffff80003cda>] ret_from_exception+0x0/0x14
[    7.015034][    T1] ========================================================================

Signed-off-by: Changbin Du <changbin.du@gmail.com>
---
 include/linux/pagevec.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Matthew Wilcox Jan. 16, 2022, 11:40 a.m. UTC | #1
On Sun, Jan 16, 2022 at 03:02:27PM +0800, Changbin Du wrote:
> The folio_batch_init() forgets to initinize folio_batch::percpu_pvec_drained.

Already reported by Randy three days ago; sitting in linux-next since
then.  commit 6840f9094f2b.
Changbin Du Jan. 17, 2022, 3:40 p.m. UTC | #2
On Sun, Jan 16, 2022 at 11:40:39AM +0000, Matthew Wilcox wrote:
> On Sun, Jan 16, 2022 at 03:02:27PM +0800, Changbin Du wrote:
> > The folio_batch_init() forgets to initinize folio_batch::percpu_pvec_drained.
> 
> Already reported by Randy three days ago; sitting in linux-next since
> then.  commit 6840f9094f2b.

Glade to know. Thank you.
diff mbox series

Patch

diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
index dda8d5868c81..67b1246f136b 100644
--- a/include/linux/pagevec.h
+++ b/include/linux/pagevec.h
@@ -111,6 +111,7 @@  static_assert(offsetof(struct pagevec, pages) ==
 static inline void folio_batch_init(struct folio_batch *fbatch)
 {
 	fbatch->nr = 0;
+	fbatch->percpu_pvec_drained = false;
 }
 
 static inline unsigned int folio_batch_count(struct folio_batch *fbatch)