git: 3ac3f94992ed - stable/13 - nfscl: Fix IO_APPEND writes from kernel space

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Mon, 06 Jun 2022 22:12:36 UTC
The branch stable/13 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=3ac3f94992ed936a380bedc6ca2e0759c9abe909

commit 3ac3f94992ed936a380bedc6ca2e0759c9abe909
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2022-03-28 22:11:52 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2022-06-06 22:11:37 +0000

    nfscl: Fix IO_APPEND writes from kernel space
    
    Commit 867c27c23a5c modified the NFS client so that
    it did IO_APPEND writes directly to the NFS server
    bypassing the buffer cache, via a call to
    nfs_directio_write().  Unfortunately, this (very old)
    function assumed that the uio iov was for user space
    addresses.  As such, a IO_APPEND VOP_WRITE() that
    was for system space, such as ktrace(1) does, would
    write bogus data.
    
    This patch fixes nfs_directio_write() so that it
    handles kernel space uio iovs.
    
    (cherry picked from commit c1970a7ebab582d19694c9a525ed6eb4512fdb73)
---
 sys/fs/nfsclient/nfs_clbio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c
index 29bc66669dfb..7f661e36f4b7 100644
--- a/sys/fs/nfsclient/nfs_clbio.c
+++ b/sys/fs/nfsclient/nfs_clbio.c
@@ -780,7 +780,7 @@ do_sync:
 			uio.uio_iovcnt = 1;
 			uio.uio_offset = uiop->uio_offset;
 			uio.uio_resid = size;
-			uio.uio_segflg = UIO_USERSPACE;
+			uio.uio_segflg = uiop->uio_segflg;
 			uio.uio_rw = UIO_WRITE;
 			uio.uio_td = td;
 			iomode = NFSWRITE_FILESYNC;