]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pagevec: Initialise folio_batch->percpu_pvec_drained
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 13 Jan 2022 21:44:19 +0000 (16:44 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 13 Jan 2022 21:50:50 +0000 (16:50 -0500)
When UBSAN is enabled, it reports an invalid value in __pagevec_release()
when accessing pvec->percpu_pvec_drained, which is simply whatever
garbage was on the stack.  Initialise it when initialising the rest of
the folio_batch.

Fixes: 10331795fb79 ("pagevec: Add folio_batch")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/pagevec.h

index dda8d5868c8163ba07f438b586dc6cb516acd7f6..67b1246f136b425f950e961cb65c336125509c19 100644 (file)
@@ -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)