Patch "nfs/localio: must clear res.replen in nfs_local_read_done" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    nfs/localio: must clear res.replen in nfs_local_read_done

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nfs-localio-must-clear-res.replen-in-nfs_local_read_.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 07bec7021cee2b1d2f38ee20f1c6d842299918ec
Author: NeilBrown <neilb@xxxxxxx>
Date:   Fri Nov 8 18:39:44 2024 -0500

    nfs/localio: must clear res.replen in nfs_local_read_done
    
    [ Upstream commit 650703bc4ed3edf841e851c99ab8e7ba9e5262a3 ]
    
    Otherwise memory corruption can occur due to NFSv3 LOCALIO reads
    leaving garbage in res.replen:
    - nfs3_read_done() copies that into server->read_hdrsize; from there
      nfs3_proc_read_setup() copies it to args.replen in new requests.
    - nfs3_xdr_enc_read3args() passes that to rpc_prepare_reply_pages()
      which includes it in hdrsize for xdr_init_pages, so that rq_rcv_buf
      contains a ridiculous len.
    - This is copied to rq_private_buf and xs_read_stream_request()
      eventually passes the kvec to sock_recvmsg() which receives incoming
      data into entirely the wrong place.
    
    This is easily reproduced with NFSv3 LOCALIO that is servicing reads
    when it is made to pivot back to using normal RPC.  This switch back
    to using normal NFSv3 with RPC can occur for a few reasons but this
    issue was exposed with a test that stops and then restarts the NFSv3
    server while LOCALIO is performing heavy read IO.
    
    Fixes: 70ba381e1a43 ("nfs: add LOCALIO support")
    Reported-by: Mike Snitzer <snitzer@xxxxxxxxxx>
    Signed-off-by: NeilBrown <neilb@xxxxxxx>
    Co-developed-by: Mike Snitzer <snitzer@xxxxxxxxxx>
    Signed-off-by: Mike Snitzer <snitzer@xxxxxxxxxx>
    Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c
index 8f0ce82a677e1..637528e6368ef 100644
--- a/fs/nfs/localio.c
+++ b/fs/nfs/localio.c
@@ -354,6 +354,12 @@ nfs_local_read_done(struct nfs_local_kiocb *iocb, long status)
 
 	nfs_local_pgio_done(hdr, status);
 
+	/*
+	 * Must clear replen otherwise NFSv3 data corruption will occur
+	 * if/when switching from LOCALIO back to using normal RPC.
+	 */
+	hdr->res.replen = 0;
+
 	if (hdr->res.count != hdr->args.count ||
 	    hdr->args.offset + hdr->res.count >= i_size_read(file_inode(filp)))
 		hdr->res.eof = true;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux