Skip to content

Commit

Permalink
pagevec: Initialise folio_batch->percpu_pvec_drained
Browse files Browse the repository at this point in the history
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: 1033179 ("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>
  • Loading branch information
Matthew Wilcox (Oracle) committed Jan 13, 2022
1 parent 455e73a commit 6840f90
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/pagevec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6840f90

Please sign in to comment.