All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "David Howells" <dhowells@redhat.com>
Cc: v9fs@lists.linux.dev, "Chuck Lever" <cel@kernel.org>,
	"Jeff Layton" <jlayton@kernel.org>,
	"Anna Schumaker" <anna@kernel.org>
Subject: Re: [PATCH v19 08/17] netfs: Explicitly pass tail padding to netfs_writeback_single()
Date: Thu, 19 Nov 2026 09:15:01 +0000	[thread overview]
Message-ID: <sashiko-outbox-222801@kernel.org> (raw)
In-Reply-To: <20261119083851.3306418-9-dhowells@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] afs: uninitialized cache write or WARN in
  afs_symlink_writepages()
--

commit 95ee548dcf53267f4aa069e5911e552ec816490b
Author: David Howells <dhowells@redhat.com>

netfs: Explicitly pass tail padding to netfs_writeback_single()

This commit updates netfs_writeback_single() to take an explicit content
length alongside the buffer iterator and updates AFS directory and symlink
writeback to clear tail padding in the buffer.

> diff --git a/fs/afs/symlink.c b/fs/afs/symlink.c
> index a1dbd552ddff0..c18e4f8064234 100644
> --- a/fs/afs/symlink.c
> +++ b/fs/afs/symlink.c
> @@ -228,6 +228,10 @@ int afs_readlink(struct dentry *dentry, char __user *buffer, int buflen)
>  /*
>   * Write the symlink contents to the cache as a single blob.  We then throw
>   * away the page we used to receive it.
> + *
> + * Note that the buffer tail is cleared under a shared lock on ->validate_lock
> + * - though hopefully there won't be racing writers since the only
> + * 'modification' is to be either read from the server or locally created.
>   */
>  int afs_symlink_writepages(struct address_space *mapping,
>  			   struct writeback_control *wbc)
> @@ -247,9 +251,17 @@ int afs_symlink_writepages(struct address_space *mapping,
>  
>  	if (vnode->directory &&
>  	    atomic64_read(&vnode->cb_expires_at) != AFS_NO_CB_PROMISE) {
> +		size_t i_size = i_size_read(&vnode->netfs.inode);
> +
> +		if (i_size < vnode->directory_size) {
> +			iov_iter_folio_queue(&iter, ITER_DEST, vnode->directory, 0, 0,
> +					     vnode->directory_size);
> +			iov_iter_advance(&iter, i_size);
> +			iov_iter_zero(vnode->directory_size - i_size, &iter);
> +		}
>  		iov_iter_folio_queue(&iter, ITER_SOURCE, vnode->directory, 0, 0,
> -				     i_size_read(&vnode->netfs.inode));
> -		ret = netfs_writeback_single(mapping, wbc, &iter);
> +				     vnode->directory_size);
> +		ret = netfs_writeback_single(mapping, wbc, &iter, i_size);
>  	}
>  
>  	if (ret == 0) {

[Severity: Medium]
Can afs_symlink_writepages() write uninitialized kernel memory to fscache
or trigger WARN_ON_ONCE(iov_iter_count(iter) < len) in
netfs_writeback_single() if the symlink's server status size grows before
writeback runs?

Unlike afs_do_read_single() and afs_dir_get_block(), afs_init_new_symlink()
and afs_do_read_symlink() allocate the PAGE_SIZE vnode->directory buffer
without __GFP_ZERO, populate only the initial symlink length, and mark the
inode dirty.  If a status fetch (such as afs_getattr() or
FS.InlineBulkStatus) observes a larger size on the server before writeback,
afs_apply_status() updates inode->i_size and afs_apply_callback() sets a
valid cb_expires_at without freeing vnode->directory (or during
afs_do_read_symlink(), FS.FetchData updates i_size > PAGE_SIZE and marks
the inode dirty before returning -EFBIG).

When afs_symlink_writepages() then reads the updated i_size, a new size
between the populated length and PAGE_SIZE advances past the unzeroed gap
and writes those uninitialized bytes to fscache.  A new size above
vnode->directory_size (PAGE_SIZE) skips zeroing and passes len >
iov_iter_count(&iter) to netfs_writeback_single(), hitting WARN_ON_ONCE()
and returning -EIO without freeing vnode->directory.  Passing __GFP_ZERO
when allocating the symlink buffer and invalidating or clamping against
vnode->directory_size when status changes would avoid both issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119083851.3306418-1-dhowells@redhat.com?part=8

  reply	other threads:[~2026-11-19  9:15 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  8:38 [PATCH v19 00/17] netfs, iov_iter: Use a chain of bio_vec arrays instead of folio_queue David Howells
2026-11-19  8:38 ` [PATCH v19 01/17] iov_iter: Fix kunit test to remove __init and __refdata marks David Howells
2026-11-19  8:47   ` sashiko-bot
2026-11-19  9:21   ` Wang Yibo
2026-11-19  8:38 ` [PATCH v19 02/17] block: Add a function to kmap one page of a multipage bio_vec David Howells
2026-11-19  8:44   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 03/17] iov_iter: Add a segmented queue of bio_vec[] David Howells
2026-11-19  8:52   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 04/17] netfs: Add some tools for managing bvecq chains David Howells
2026-11-19  9:07   ` sashiko-bot
2026-11-19 11:49   ` David Howells
2026-11-19  8:38 ` [PATCH v19 05/17] iov_iter: Add an API document for the bvecq structure David Howells
2026-11-19  8:53   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 06/17] iov_iter: Add a bvecq kunit test David Howells
2026-11-19  8:50   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 07/17] afs: Fix an inconsistency in the symlink code David Howells
2026-11-19  8:57   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 08/17] netfs: Explicitly pass tail padding to netfs_writeback_single() David Howells
2026-11-19  9:15   ` sashiko-bot [this message]
2026-11-19  8:38 ` [PATCH v19 09/17] netfs: Change netfs_writeback_single() to not look inside the iterator David Howells
2026-11-19  9:09   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 10/17] netfs: Pass the write length to request creation where appropriate David Howells
2026-11-19  8:56   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 11/17] afs: Use a bvecq to hold dir content rather than folioq David Howells
2026-11-19  9:29   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 12/17] cifs: Use a bvecq for buffering instead of a folioq David Howells
2026-11-19  9:10   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 13/17] smbdirect: Support ITER_BVECQ in smbdirect_map_sges_from_iter() David Howells
2026-11-19  9:15   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 14/17] netfs: Switch folioq to bvecq David Howells
2026-11-19  9:38   ` sashiko-bot
2026-11-19 11:49   ` David Howells
2026-11-19  8:38 ` [PATCH v19 15/17] smbdirect: Remove support for ITER_FOLIOQ from smbdirect_map_sges_from_iter() David Howells
2026-11-19  9:13   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 16/17] iov_iter: Remove ITER_FOLIOQ David Howells
2026-11-19  9:20   ` sashiko-bot
2026-11-19  8:38 ` [PATCH v19 17/17] netfs: Remove folio_queue David Howells
2026-11-19  9:18   ` sashiko-bot
2026-11-20  9:38 ` [PATCH v19 00/17] netfs, iov_iter: Use a chain of bio_vec arrays instead of folio_queue Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-222801@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=anna@kernel.org \
    --cc=cel@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=jlayton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=v9fs@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.