From: Greg KH <gregkh@linuxfoundation.org>
To: Bharath SM <bharathsm.hsk@gmail.com>
Cc: linux-cifs@vger.kernel.org, smfrench@gmail.com,
dhowells@redhat.com, sprasad@microsoft.com, pc@manguebit.com,
ematsumiya@suse.de, henrique.carvalho@suse.com,
bharathsm@microsoft.com, stable@vger.kernel.org
Subject: Re: [PATCH 6.6.y] smb: client: fix page cache corruption from in-place encryption in SMB2_write
Date: Wed, 4 Mar 2026 15:21:52 +0100 [thread overview]
Message-ID: <2026030442-cleft-appealing-93ec@gregkh> (raw)
In-Reply-To: <20260304140452.1606662-1-bharathsm@microsoft.com>
On Wed, Mar 04, 2026 at 07:34:52PM +0530, Bharath SM wrote:
> SMB2_write() passes data kvecs inline in rq_iov by setting
> rqst.rq_nvec = n_vec + 1. When SMB3 encryption is negotiated,
> smb3_init_transform_rq() -> crypt_message() encrypts data in the
> kvec buffers in-place.
>
> For synchronous writes through cifs_write(), the kvec buffers point
> directly into the page cache via kmap(). In-place encryption overwrites
> the page cache with ciphertext. If the send fails with a replayable
> error such as -EAGAIN (e.g., from a connection reset), SMB2_write()
> retries the write using the same iov[1] buffer. Since iov[1] now
> contains ciphertext from the first attempt, the retry encrypts and
> sends ciphertext-as-data to the server, resulting in data corruption.
>
> The corruption is most likely to be observed when connections are
> unstable, as reconnects trigger write retries that re-send the
> already-encrypted page cache data.
>
> The sync path can be reached during partial-page O_WRONLY writes when
> the page is not in cache (common for append workloads with repeated
> open/write/close patterns).
>
> The async write path (smb2_async_writev) is not affected because it
> passes data via rqst.rq_iter, which the encryption layer handles
> without modifying the source buffers.
>
> Fix by setting rq_nvec = 1 (header only) and moving data kvecs into
> rq_iter via iov_iter_kvec().
>
> Signed-off-by: Bharath SM <bharathsm@microsoft.com>
> Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
> Cc: stable@vger.kernel.org
> ---
> fs/smb/client/smb2pdu.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> index a8890ae21714..a88a19dec494 100644
> --- a/fs/smb/client/smb2pdu.c
> +++ b/fs/smb/client/smb2pdu.c
> @@ -5072,7 +5072,11 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
>
> memset(&rqst, 0, sizeof(struct smb_rqst));
> rqst.rq_iov = iov;
> - rqst.rq_nvec = n_vec + 1;
> + rqst.rq_nvec = 1;
> + iov_iter_kvec(&rqst.rq_iter, ITER_SOURCE, &iov[1], n_vec,
> + io_parms->length);
> + rqst.rq_iter_size = io_parms->length;
> +
>
> if (retries)
> smb2_set_replay(server, &rqst);
> --
> 2.45.4
>
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
next prev parent reply other threads:[~2026-03-04 14:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 14:04 [PATCH 6.6.y] smb: client: fix page cache corruption from in-place encryption in SMB2_write Bharath SM
2026-03-04 14:21 ` Greg KH [this message]
2026-03-16 18:26 ` Bharath SM
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=2026030442-cleft-appealing-93ec@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=bharathsm.hsk@gmail.com \
--cc=bharathsm@microsoft.com \
--cc=dhowells@redhat.com \
--cc=ematsumiya@suse.de \
--cc=henrique.carvalho@suse.com \
--cc=linux-cifs@vger.kernel.org \
--cc=pc@manguebit.com \
--cc=smfrench@gmail.com \
--cc=sprasad@microsoft.com \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox