Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jan 2024 15:21:27 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 503f72a828c7 - main - ncl_bioread(): check for vp->v_object before accessing it
Message-ID:  <202401151521.40FFLRtQ003407@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=503f72a828c7d0d938ec73ffbf62406038c69d47

commit 503f72a828c7d0d938ec73ffbf62406038c69d47
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-01-15 11:49:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-01-15 15:19:58 +0000

    ncl_bioread(): check for vp->v_object before accessing it
    
    Reported by:    cy
    Reviewed by:    rmacklem
    Fixes:  70dc6b2ce314a0f32755005ad02802fca7ed186e
    MFC after:      3 days
---
 sys/fs/nfsclient/nfs_clbio.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c
index c027d7d7c3fd..1cf45bb0c924 100644
--- a/sys/fs/nfsclient/nfs_clbio.c
+++ b/sys/fs/nfsclient/nfs_clbio.c
@@ -414,6 +414,18 @@ out:
 	return (error);
 }
 
+static bool
+ncl_bioread_dora(struct vnode *vp)
+{
+	vm_object_t obj;
+
+	obj = vp->v_object;
+	if (obj == NULL)
+		return (true);
+	return (!vm_object_mightbedirty(vp->v_object) &&
+	    vp->v_object->un_pager.vnp.writemappings == 0);
+}
+
 /*
  * Vnode op for read using bio
  */
@@ -486,9 +498,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
 		 * unlocked read by nfsiod could obliterate changes
 		 * done by userspace.
 		 */
-		if (nmp->nm_readahead > 0 &&
-		    !vm_object_mightbedirty(vp->v_object) &&
-		    vp->v_object->un_pager.vnp.writemappings == 0) {
+		if (nmp->nm_readahead > 0 && ncl_bioread_dora(vp)) {
 		    for (nra = 0; nra < nmp->nm_readahead && nra < seqcount &&
 			(off_t)(lbn + 1 + nra) * biosize < nsize; nra++) {
 			rabn = lbn + 1 + nra;
@@ -675,9 +685,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
 		 *  directory offset cookie of the next block.)
 		 */
 		NFSLOCKNODE(np);
-		if (nmp->nm_readahead > 0 &&
-		    !vm_object_mightbedirty(vp->v_object) &&
-		    vp->v_object->un_pager.vnp.writemappings == 0 &&
+		if (nmp->nm_readahead > 0 && ncl_bioread_dora(vp) &&
 		    (bp->b_flags & B_INVAL) == 0 &&
 		    (np->n_direofoffset == 0 ||
 		    (lbn + 1) * NFS_DIRBLKSIZ < np->n_direofoffset) &&



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401151521.40FFLRtQ003407>