[PATCH v4 00/22] netfs: Miscellaneous fixes

David Howells
2026-04-27T15:46:49Z

Hi Christian,

Here are the outstanding miscellaneous fixes for netfslib gathered together
and with some fixes-to-fixes folded down and one rearrangement. Various
Sashiko review comments[1][2][3] are addressed:

(1) Fix subrequest cancellation cleanup in DIO read and single-read.

(2) Fix read and write result collection to use barriering correctly to
access a request's subrequest lists without taking a lock.

This adds list_add_tail_release() and list_first_entry_acquire() to
appropriate incorporate barriering into some list functions.

(3) Fix missing locking around retry adding new subrequests.

(4) Fix netfs_read_to_pagecache() to pause on subrequest I/O failure.

(5) Fix the potential for 64-bit tearing on a 32-bit machine when reading
netfs_inode->remote_i_size and ->zero_point by using much the same
mechanism as is used for ->i_size.

(6) Fix the calculation of zero_point in netfs_release_folio() to limit it
to ->remote_i_size, not ->i_size.

(7) Fix triggering of a VM_BUG_ON_FOLIO() in netfs_write_begin().

(8) Fix error handling in netfs_extract_user_iter().

(9) Fix netfs_invalidate_folio() to clear the folio dirty bit if all dirty
data removed.

(10) Defer the emission of trace_netfs_folio() in netfs_perform_write().
This allows the next patch to emit the correct traces.

(11) Fix the handling of a partially failed copy (ie. EFAULT) into a
streaming write folio. Also remove the netfs_folio if a streaming
write folio is entirely overwritten.

(12) Fix netfs_read_gaps() to remove the netfs_folio from a filled folio.

(13) Fix netfs_perform_write() to not disable streaming writes when writing
to an fd that's open O_RDWR.

(14) Fix an early put of the sink page used in netfs_read_gaps(), before
the request has completed.

(15) Fix request leak in netfs_write_begin() error handling.

(16) Fix a potential UAF in netfs_unlock_abandoned_read_pages() due to
trying to check index of each folio we're abandoning to see if that
folio is actually owned by the caller (in which case, we're not
actually allowed to dereference it).

(17) Fix a potentially uninitialised error value in
netfs_extract_user_iter().

(18) Fix incorrect adjustment of dirty region when partially invalidating a
streaming write folio.

(19) Fix the handling of folio->private in netfs_perform_write() and the
attached netfs_folio and/or group when a streaming write folio is
modified.

(20) Fix netfs_read_folio() to wait on writeback first (it holds the folio
lock) otherwise we aren't allowed to look at the netfs_folio struct as
that could be modified at any time by the writeback collector.

(21) Fix write skipping in dir/symlink writepages.

(22) Fix the locking used by afs_get_link().

The patches can also be found here:

https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=netfs-fixes

Thanks,
David

[1] https://sashiko.dev/#/patchset/20260414082004.3756080-1-dhowells%40redhat.com
[2] https://sashiko.dev/#/patchset/20260326104544.509518-1-dhowells%40redhat.com
[3] https://sashiko.dev/#/patchset/20260425125426.3855807-1-dhowells%40redhat.com

Changes
=======
ver #4)
- Rebase on v7.0-rc1
- Fix latest set of Sashiko issues[3].
- Move the ->subrequests barriering patch up front as it modifies
linux/list.h.
- Split that barriering patch and make the first patch to harmonise the
order of adding a read subreq to the queue, for buffered, dio and
single reads and to fix cancellation on prep failure. The second patch
then fixes the barriering.
- Lock ->subrequests in retry when adding in extra subreqs.
- Use a spinlock as well when modifying ->zero_point with a seq lock.
- Atomically check and change ->zero_point when bumping it up.
- Merged the two patches sorting out the locking in afs symlink handling,
then fixed a number of issues in them.
- Added a patch to make afs dir and symlink writepages skip if the
validate_lock is held and WB_SYNC_NONE is set.

ver #3)
- Rebase on linus/master.
- Consolidate the various sets of fixes for reposting.
- Fold down fixes-to-fixes.
- Move the tracing change in netfs_perform_write() down to below the patch
it primarily affects.

base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731

David Howells (20):
netfs: Fix cancellation of a DIO and single read subrequests
netfs: Fix missing barriers when accessing stream->subrequests
locklessly
netfs: Fix missing locking around retry adding new subreqs
netfs: Fix netfs_read_to_pagecache() to pause on subreq failure
netfs: Fix potential for tearing in ->remote_i_size and ->zero_point
netfs: Fix zeropoint update where i_size > remote_i_size
netfs: Fix netfs_invalidate_folio() to clear dirty bit if all changes
gone
netfs: Defer the emission of trace_netfs_folio()
netfs: Fix streaming write being overwritten
netfs: Fix read-gaps to remove netfs_folio from filled folio
netfs: Fix write streaming disablement if fd open O_RDWR
netfs: Fix early put of sink folio in netfs_read_gaps()
netfs: Fix leak of request in netfs_write_begin() error handling
netfs: Fix potential UAF in netfs_unlock_abandoned_read_pages()
netfs: Fix potential uninitialised var in netfs_extract_user_iter()
netfs: Fix partial invalidation of streaming-write folio
netfs: Fix folio->private handling in netfs_perform_write()
netfs: Fix netfs_read_folio() to wait on writeback
netfs, afs: Fix write skipping in dir/link writepages
afs: Fix the locking used by afs_get_link()

Paulo Alcantara (1):
netfs: fix error handling in netfs_extract_user_iter()

Viacheslav Dubeyko (1):
netfs: fix VM_BUG_ON_FOLIO() issue in netfs_write_begin() call

fs/9p/vfs_inode.c | 2 +-
fs/9p/vfs_inode_dotl.c | 4 +-
fs/afs/Makefile | 1 +
fs/afs/dir.c | 76 ++++----
fs/afs/fsclient.c | 4 +-
fs/afs/inode.c | 104 +----------
fs/afs/internal.h | 34 +++-
fs/afs/symlink.c | 267 +++++++++++++++++++++++++++++
fs/afs/validation.c | 8 +-
fs/afs/write.c | 2 +-
fs/afs/yfsclient.c | 4 +-
fs/netfs/buffered_read.c | 64 ++++---
fs/netfs/buffered_write.c | 147 ++++++++++------
fs/netfs/direct_read.c | 19 +-
fs/netfs/direct_write.c | 4 +-
fs/netfs/internal.h | 2 +
fs/netfs/iterator.c | 15 +-
fs/netfs/misc.c | 21 ++-
fs/netfs/read_collect.c | 6 +-
fs/netfs/read_retry.c | 13 +-
fs/netfs/read_single.c | 20 +--
fs/netfs/write_collect.c | 7 +-
fs/netfs/write_issue.c | 8 +-
fs/netfs/write_retry.c | 2 +
fs/smb/client/cifsfs.c | 28 +--
fs/smb/client/cifssmb.c | 2 +-
fs/smb/client/file.c | 9 +-
fs/smb/client/inode.c | 9 +-
fs/smb/client/readdir.c | 3 +-
fs/smb/client/smb2ops.c | 16 +-
fs/smb/client/smb2pdu.c | 2 +-
include/linux/list.h | 37 ++++
include/linux/netfs.h | 324 +++++++++++++++++++++++++++++++++--
include/trace/events/netfs.h | 8 +
34 files changed, 949 insertions(+), 323 deletions(-)
create mode 100644 fs/afs/symlink.c