Skip to content

mm/filemap: annotate lockless reads of mapping->nrpages - #1428

Open
ghost wants to merge 1 commit into
linus-master_basefrom
series/1183849=>linus-master
Open

ghost wants to merge 1 commit into
linus-master_basefrom
series/1183849=>linus-master

Conversation

@ghost

@ghost ghost commented Oct 12, 2026

Copy link
Copy Markdown

Pull request for series with
subject: mm/filemap: annotate lockless reads of mapping->nrpages
version: 2
url: https://patchwork.kernel.org/series/1183849/

@ghost

ghost commented Oct 12, 2026

Copy link
Copy Markdown
Author

Upstream branch: 24a19b9
series: https://patchwork.kernel.org/series/1183849/
version: 2

@ghost

ghost commented Oct 12, 2026

Copy link
Copy Markdown
Author

Upstream branch: 24a19b9
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost ghost added V3 and removed V2 labels Oct 12, 2026
@ghost
ghost force-pushed the series/1183849=>linus-master branch from 7c38520 to 1b6ceeb Compare October 12, 2026 14:52
@ghost

ghost commented Oct 12, 2026

Copy link
Copy Markdown
Author

Upstream branch: 24a19b9
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 1b6ceeb to a85cd17 Compare October 12, 2026 16:39
@ghost ghost added the V3-ci-pass label Oct 13, 2026
@ghost
ghost force-pushed the linus-master_base branch from 2e69118 to 3cdd51f Compare October 14, 2026 11:11
@ghost

ghost commented Oct 14, 2026

Copy link
Copy Markdown
Author

Upstream branch: 4056b3c
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from a85cd17 to 91243f6 Compare October 14, 2026 11:24
@ghost
ghost force-pushed the linus-master_base branch from 3cdd51f to e6ca2c1 Compare October 14, 2026 15:40
@ghost

ghost commented Oct 14, 2026

Copy link
Copy Markdown
Author

Upstream branch: 0fcb05b
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 91243f6 to 249f6fd Compare October 14, 2026 15:53
@ghost
ghost force-pushed the linus-master_base branch from e6ca2c1 to 3d027d5 Compare October 17, 2026 03:31
@ghost

ghost commented Oct 17, 2026

Copy link
Copy Markdown
Author

Upstream branch: 58161ea
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 249f6fd to b9017c7 Compare October 17, 2026 03:48
@ghost
ghost force-pushed the linus-master_base branch from 3d027d5 to 90ea7e4 Compare October 19, 2026 00:00
@ghost

ghost commented Oct 19, 2026

Copy link
Copy Markdown
Author

Upstream branch: c03c1a1
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from b9017c7 to a8a7802 Compare October 19, 2026 00:29
@ghost
ghost force-pushed the linus-master_base branch from 90ea7e4 to 435b194 Compare October 22, 2026 07:21
@ghost

ghost commented Oct 22, 2026

Copy link
Copy Markdown
Author

Upstream branch: 7be4bc5
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from a8a7802 to 5f06fc4 Compare October 22, 2026 07:56
@ghost
ghost force-pushed the linus-master_base branch from 435b194 to fd67522 Compare October 24, 2026 03:36
@ghost

ghost commented Oct 24, 2026

Copy link
Copy Markdown
Author

Upstream branch: 17bb0e2
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 5f06fc4 to 7732e8b Compare October 24, 2026 04:02
@ghost
ghost force-pushed the linus-master_base branch from fd67522 to 3b53a63 Compare October 26, 2026 01:52
@ghost

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Upstream branch: 6b4b543
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 5d387a7 to b808845 Compare October 26, 2026 07:29
@ghost
ghost force-pushed the linus-master_base branch from 5d84576 to 6582ed2 Compare October 26, 2026 18:11
@ghost

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Upstream branch: fb2c3f4
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from b808845 to 6f78e89 Compare October 26, 2026 18:56
@ghost
ghost force-pushed the linus-master_base branch from 6582ed2 to b3a1abc Compare October 26, 2026 23:55
@ghost

ghost commented Oct 27, 2026

Copy link
Copy Markdown
Author

Upstream branch: d135ab4
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 6f78e89 to 4ac035d Compare October 27, 2026 00:19
@ghost
ghost force-pushed the linus-master_base branch from b3a1abc to 712496f Compare October 28, 2026 23:34
@ghost

ghost commented Oct 28, 2026

Copy link
Copy Markdown
Author

Upstream branch: c339f40
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 4ac035d to bf280de Compare October 28, 2026 23:59
@ghost
ghost force-pushed the linus-master_base branch from 712496f to a186880 Compare October 30, 2026 13:52
@ghost

ghost commented Oct 30, 2026

Copy link
Copy Markdown
Author

Upstream branch: d89e1d1
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from bf280de to 07bafd8 Compare October 30, 2026 14:51
@ghost
ghost force-pushed the linus-master_base branch from a186880 to 46206a3 Compare November 2, 2026 17:14
@ghost

ghost commented Nov 2, 2026

Copy link
Copy Markdown
Author

Upstream branch: 6628e7d
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 07bafd8 to 7db9cb3 Compare November 2, 2026 18:01
@ghost
ghost force-pushed the linus-master_base branch from 46206a3 to 220bd96 Compare November 3, 2026 23:41
@ghost

ghost commented Nov 4, 2026

Copy link
Copy Markdown
Author

Upstream branch: 05441d6
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 7db9cb3 to 7256856 Compare November 4, 2026 00:12
@ghost
ghost force-pushed the linus-master_base branch from 220bd96 to 6c4625e Compare November 6, 2026 08:02
@ghost

ghost commented Nov 6, 2026

Copy link
Copy Markdown
Author

Upstream branch: f66469d
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 7256856 to e0d2d05 Compare November 6, 2026 08:52
@ghost
ghost force-pushed the linus-master_base branch from 6c4625e to c7f678d Compare November 7, 2026 03:08
@ghost

ghost commented Nov 7, 2026

Copy link
Copy Markdown
Author

Upstream branch: d487237
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from e0d2d05 to 8850dcd Compare November 7, 2026 03:49
@ghost
ghost force-pushed the linus-master_base branch from c7f678d to 6aa6cd1 Compare November 10, 2026 07:53
mapping->nrpages is updated under the i_pages lock but is read locklessly
as a cheap "anything cached?" hint, e.g. in invalidate_bdev() and
filemap_write_and_wait_range(). KCSAN reports the race:

  BUG: KCSAN: data-race in __filemap_add_folio / invalidate_bdev

  read-write to 0xffff8881004c4178 of 8 bytes by task 3600 on cpu 0:
   __filemap_add_folio+0x6b7/0x910 mm/filemap.c:919
   filemap_add_folio+0x1cd/0x380
   page_cache_ra_unbounded+0x1a4/0x3a0
   ...
   blkdev_read_iter+0x21e/0x2d0
  read to 0xffff8881004c4178 of 8 bytes by task 3601 on cpu 1:
   invalidate_bdev+0x25/0x70 block/bdev.c:98
   ext4_fill_super+0x2ccb/0x37b0

The same counter also races with filemap_write_and_wait_range() through
mapping_needs_writeback().

The race is benign: a stale value only makes the caller do or skip a
harmless invalidate/flush pass. Mark the lockless reads with data_race()
in invalidate_bdev() and in the two callers of mapping_needs_writeback(),
rather than inside the helper, so a future user needing a reliable answer
is not silently covered.

Reported-by: syzbot+e0624b5bf72b99131402@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e0624b5bf72b99131402
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
@ghost

ghost commented Nov 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: b3dfbde
series: https://patchwork.kernel.org/series/1183975/
version: 3

@ghost
ghost force-pushed the series/1183849=>linus-master branch from 8850dcd to 0646255 Compare November 10, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant