Date: Mon, 01 Jan 2024 22:27:13 +0000 From: bugzilla-noreply@freebsd.org To: fs@FreeBSD.org Subject: [Bug 276002] nfscl: data corruption using both copy_file_range and mmap'd I/O Message-ID: <bug-276002-3630-Uoa5w7VByw@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-276002-3630@https.bugs.freebsd.org/bugzilla/> References: <bug-276002-3630@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276002 --- Comment #38 from Konstantin Belousov <kib@FreeBSD.org> --- (In reply to Rick Macklem from comment #34) This sounds as an interesting theory, but please note that read-ahead initiators in nfs_clbio.c checks that the B_CACHE buffer flag is not set. This should prevent a situation where we have constructed buffer with valid (might be dirty) pa= ges but not valid content recorded at buf cache layer. But lets recheck the theory anyway, the patch below should prevent RA when there are writeable mappings: commit 2234d9d4f7595a78bf10c08b1e6b12d2115799cd Author: Konstantin Belousov <kib@FreeBSD.org> Date: Tue Jan 2 00:22:44 2024 +0200 nfsclient: do not do (unlocked) read-ahead by nfsiod if there are write= able mappings diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index e6486af55daf..1f92fe0a4cf3 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -481,9 +481,13 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int iof= lag, struct ucred *cred) on =3D uio->uio_offset - (lbn * biosize); /* - * Start the read ahead(s), as required. + * Start the read ahead(s), as required. Do not do + * read-ahead if there are writeable mappings, since + * unlocked read by nfsiod could obliterate changes + * done by userspace. */ - if (nmp->nm_readahead > 0) { + if (nmp->nm_readahead > 0 && + vp->v_object->un_pager.vnp.writemappings =3D=3D 0) { for (nra =3D 0; nra < nmp->nm_readahead && nra < seqcou= nt && (off_t)(lbn + 1 + nra) * biosize < nsize; nra++) { rabn =3D lbn + 1 + nra; @@ -671,6 +675,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int iofl= ag, struct ucred *cred) */ NFSLOCKNODE(np); if (nmp->nm_readahead > 0 && + vp->v_object->un_pager.vnp.writemappings =3D=3D 0 && (bp->b_flags & B_INVAL) =3D=3D 0 && (np->n_direofoffset =3D=3D 0 || (lbn + 1) * NFS_DIRBLKSIZ < np->n_direofoffset) && --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-276002-3630-Uoa5w7VByw>