Skip to contentSkip to conversation

Coverity: page_zone(): Memory - corruptions

DISCUSSION coverity-bot 1 participant 1 message Nov 2, 2022 Linux-next tree

lore
Share & tools
lore
#0 lore raw

Hello!

This is an experimental semi-automated report about issues detected by Coverity from a scan of next-20221102 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified lines of code (noted below) that were touched by commits:

Tue Nov 1 17:26:18 2022 -0700
5cb2ae82a4c4 ("mm: simplify page_zone() and get_deferred_split_queue() with page_pgdat()")

Coverity reported the following:

*** CID 1527097: Memory - corruptions (OVERRUN)
/include/linux/mm.h: 1458 in page_zone()

1452     {
1453     	return NODE_DATA(page_to_nid(page));
1454     }

1455
1456 static inline struct zone *page_zone(const struct page *page)
1457 {
vvv CID 1527097: Memory - corruptions (OVERRUN)
vvv "&page_pgdat(page)->node_zones[page_zonenum(page)]" evaluates to an address that is at byte offset 114688 of an array of 81920 bytes.
1458 return &page_pgdat(page)->node_zones[page_zonenum(page)];
1459 }
1460

1461     static inline struct zone *folio_zone(const struct folio *folio)
1462     {
1463     	return page_zone(&folio->page);

If this is a false positive, please let us know so we can mark it as such, or teach the Coverity rules to be smarter. If not, please make sure fixes get into linux-next. :) For patches fixing this, please include these lines (but double-check the "Fixes" first):

Addresses-Coverity-ID: 1527097 ("Memory - corruptions")

Fixes 5cb2ae82a4c4 ("mm: simplify page_zone() and get_deferred_split_queue() with page_pgdat()")

The problem appears to be the difference between page_zonenum() returning up to ZONES_MASK-many, and node_zones[] being sized precisely...

Thanks for your attention!

Signature · 1 line
Coverity-bot