nfsd: set SC_STATUS_FREED in nfsd4_drop_revoked_stid for delegations
Subsystems (2)
PATCH 1/1 nfsd: set SC_STATUS_FREED in nfsd4_drop_revoked_stid for delegations
nfsd4_drop_revoked_stid() handles FREE_STATEID for admin-revoked delegations but does not set SC_STATUS_FREED before releasing cl_lock. revoke_delegation() uses this flag to detect whether FREE_STATEID has already processed the delegation — without it, the freed delegation is added to cl_revoked via list_add(), producing a use-after-free when cl_revoked is later traversed in __release_client().
The SC_STATUS_REVOKED path in nfsd4_free_stateid() (line 7590) already sets SC_STATUS_FREED correctly. Apply the same pattern to the SC_STATUS_ADMIN_REVOKED path in nfsd4_drop_revoked_stid().
--- fs/nfsd/nfs4state.c | 1 + 1 file changed, 1 insertion(+)
fs/nfsd/nfs4state.c +1 -0
@@ -5071,6 +5071,7 @@ static void nfsd4_drop_revoked_stid(struct nfs4_stid *s)case SC_TYPE_DELEG : dp =delegstateid (s);list_del_init (&dp->dl_recall_lru); + s->sc_status |=SC_STATUS_FREED ;spin_unlock (&cl->cl_lock);nfs4_put_stid (s);break ;
Signature · 1 line
2.50.1 (Apple Git-155)
Quoted 22 lines · Zhenghang Xiao
nfsd4_drop_revoked_stid()handlesFREE_STATEIDfor admin-revoked delegations but does not setSC_STATUS_FREEDbefore releasingcl_lock.revoke_delegation()uses this flag to detect whetherFREE_STATEIDhas already processed the delegation — without it, the freed delegation is added tocl_revokedvialist_add(), producing a use-after-free whencl_revokedis later traversed in__release_client().The
SC_STATUS_REVOKEDpath innfsd4_free_stateid()(line 7590) already setsSC_STATUS_FREEDcorrectly. Apply the same pattern to theSC_STATUS_ADMIN_REVOKEDpath innfsd4_drop_revoked_stid().Fixes 8be12e0cf211 ("nfsd: convert global state_lock to per-net deleg_lock")Signed-off-by Zhenghang Xiao <[email protected]>--- fs/nfsd/nfs4state.c | 1 + 1 file changed, 1 insertion(+)fs/nfsd/nfs4state.c +0
-0
fs/nfsd/nfs4state.c static void nfsd4_drop_revoked_stid(struct nfs4_stid *s) · line 5077
Quoted 7 lines
fs/nfsd/nfs4state.c +1
-0@@ -5071,6 +5071,7 @@ static void nfsd4_drop_revoked_stid(struct nfs4_stid *s)case SC_TYPE_DELEG : dp =delegstateid (s);list_del_init (&dp->dl_recall_lru); + s->sc_status |=SC_STATUS_FREED ;spin_unlock (&cl->cl_lock);nfs4_put_stid (s);break ;
The Fixes tag doesn't look right. I think it should be:
The patch looks OK though.
Chuck Lever
maintainerFrom: Chuck Lever <[email protected]>
Quoted 8 lines · Zhenghang Xiao
nfsd4_drop_revoked_stid()handlesFREE_STATEIDfor admin-revoked delegations but does not setSC_STATUS_FREEDbefore releasingcl_lock.revoke_delegation()uses this flag to detect whetherFREE_STATEIDhas already processed the delegation — without it, the freed delegation is added tocl_revokedvialist_add(), producing a use-after-free whencl_revokedis later traversed in__release_client().[...]
Applied to nfsd-testing, thanks!
[1/1] nfsd: set SC_STATUS_FREED in nfsd4_drop_revoked_stid for delegations
commit: a1da502807b6b63963f2b1064df76e0a58fb3479
--
Chuck Lever <[email protected]>