diff options
author | Brian Foster <bfoster@redhat.com> | 2023-03-29 10:43:23 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:10:00 -0400 |
commit | 6b9857b208d7566d8bfd332a543b1dca92202c2b (patch) | |
tree | 41e40f8991e1a382ad67ccc83ff937ff4d4499e4 /virt | |
parent | 335f7d4f22fd27ea86398a3617ce41ab3d478ae6 (diff) | |
download | lwn-6b9857b208d7566d8bfd332a543b1dca92202c2b.tar.gz lwn-6b9857b208d7566d8bfd332a543b1dca92202c2b.zip |
bcachefs: use u64 for folio end pos to avoid overflows
Some of the folio_end_*() helpers are prone to overflow of signed
64-bit types because the mapping is only limited by the max value of
loff_t and the associated helpers return the start offset of the
next folio. Therefore, a folio_end_pos() of the max allowable folio in a
mapping returns a value that overflows loff_t.
This makes it hard to rely on such values when doing folio
processing across a range of a file, as bcachefs attempts to do with
the recent folio changes. For example, generic/564 causes problems
in the buffered write path when testing writes at max boundary
conditions.
The current understanding is that the pagecache historically limited
the mapping to one less page to avoid this problem and this was
dropped with some of the folio conversions, but may be reinstated to
properly address the problem. In the meantime, update the internal
folio_end_*() helpers in bcachefs to return a u64, and all of the
associated code to use or cast to u64 to avoid overflow problems.
This allows generic/564 to pass and can be reverted back to using
loff_t if at any point the pagecache subsystem can guarantee these
boundary conditions will not overflow.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'virt')
0 files changed, 0 insertions, 0 deletions