git: 148a227bf80e - main - nfsd: add KASSERTs to nfsm_trimtrailing() for M_EXTPG mbufs

Rick Macklem rmacklem at FreeBSD.org
Sun Jan 10 21:53:33 UTC 2021


The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=148a227bf80e9716ee26a8a6747961b5a639918b

commit 148a227bf80e9716ee26a8a6747961b5a639918b
Author:     Rick Macklem <rmacklem at FreeBSD.org>
AuthorDate: 2021-01-10 21:50:15 +0000
Commit:     Rick Macklem <rmacklem at FreeBSD.org>
CommitDate: 2021-01-10 21:50:15 +0000

    nfsd: add KASSERTs to nfsm_trimtrailing() for M_EXTPG mbufs
    
    Add KASSERTS to nfsm_trimtrailing() to confirm the sanity of
    the arguments for the M_EXTPG case.
    
    Suggested by:   kib
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D28053
---
 sys/fs/nfsserver/nfs_nfsdport.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c
index 727a83005fa0..8336a0b8fab2 100644
--- a/sys/fs/nfsserver/nfs_nfsdport.c
+++ b/sys/fs/nfsserver/nfs_nfsdport.c
@@ -6581,6 +6581,12 @@ nfsm_trimtrailing(struct nfsrv_descript *nd, struct mbuf *mb, char *bpos,
 		mb->m_next = NULL;
 	}
 	if ((mb->m_flags & M_EXTPG) != 0) {
+		KASSERT(bextpg >= 0 && bextpg < mb->m_epg_npgs,
+		    ("nfsm_trimtrailing: bextpg out of range"));
+		KASSERT(bpos == (char *)(void *)
+		    PHYS_TO_DMAP(mb->m_epg_pa[bextpg]) + PAGE_SIZE - bextpgsiz,
+		    ("nfsm_trimtrailing: bextpgsiz bad!"));
+
 		/* First, get rid of any pages after this position. */
 		for (i = mb->m_epg_npgs - 1; i > bextpg; i--) {
 			pg = PHYS_TO_VM_PAGE(mb->m_epg_pa[i]);


More information about the dev-commits-src-all mailing list