git: bac79d8e1646 - stable/13 - cache: only assert on flags when dealing with EMPTYPATH

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Sat, 05 Mar 2022 19:56:51 UTC
The branch stable/13 has been updated by mjg:

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

commit bac79d8e16466009afed9378dfe4e42adf46f4bb
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2021-10-17 08:40:16 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-03-05 19:52:33 +0000

    cache: only assert on flags when dealing with EMPTYPATH
    
    Reported by:    syzbot+bd48ee0843206a09e6b8@syzkaller.appspotmail.com
    Fixes:          7dd419cabc6bb9e0 ("cache: add empty path support")
    
    (cherry picked from commit 1045352f150346ba422b3a3ce6344fc694bc3aa4)
---
 sys/kern/vfs_cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 313879cf6d1f..14e148b2f839 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -4784,13 +4784,14 @@ cache_fplookup_emptypath(struct cache_fpl *fpl)
 	tvp_seqc = fpl->tvp_seqc;
 
 	MPASS(*cnp->cn_pnbuf == '\0');
-	MPASS((cnp->cn_flags & (LOCKPARENT | WANTPARENT)) == 0);
 
 	if (__predict_false((cnp->cn_flags & EMPTYPATH) == 0)) {
 		cache_fpl_smr_exit(fpl);
 		return (cache_fpl_handled_error(fpl, ENOENT));
 	}
 
+	MPASS((cnp->cn_flags & (LOCKPARENT | WANTPARENT)) == 0);
+
 	tvs = vget_prep_smr(tvp);
 	cache_fpl_smr_exit(fpl);
 	if (__predict_false(tvs == VGET_NONE)) {