Skip to content

Commit 1db7a8b

Browse files
committed
Merge: nfsd: fix nfs4_openowner leak when concurrent nfsd4_open occur
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6296 nfsd: fix nfs4_openowner leak when concurrent nfsd4_open occur JIRA: https://issues.redhat.com/browse/RHEL-76402 CVE: CVE-2024-56779 Signed-off-by: Olga Kornievskaia <okorniev@redhat.com> Approved-by: Benjamin Coddington <bcodding@redhat.com> Approved-by: Scott Mayhew <smayhew@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Patrick Talbert <ptalbert@redhat.com>
2 parents ea5f743 + 48fd2c6 commit 1db7a8b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

fs/nfsd/nfs4state.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,14 @@ static void release_open_stateid(struct nfs4_ol_stateid *stp)
16581658
free_ol_stateid_reaplist(&reaplist);
16591659
}
16601660

1661+
static bool nfs4_openowner_unhashed(struct nfs4_openowner *oo)
1662+
{
1663+
lockdep_assert_held(&oo->oo_owner.so_client->cl_lock);
1664+
1665+
return list_empty(&oo->oo_owner.so_strhash) &&
1666+
list_empty(&oo->oo_perclient);
1667+
}
1668+
16611669
static void unhash_openowner_locked(struct nfs4_openowner *oo)
16621670
{
16631671
struct nfs4_client *clp = oo->oo_owner.so_client;
@@ -4979,6 +4987,12 @@ init_open_stateid(struct nfs4_file *fp, struct nfsd4_open *open)
49794987
spin_lock(&oo->oo_owner.so_client->cl_lock);
49804988
spin_lock(&fp->fi_lock);
49814989

4990+
if (nfs4_openowner_unhashed(oo)) {
4991+
mutex_unlock(&stp->st_mutex);
4992+
stp = NULL;
4993+
goto out_unlock;
4994+
}
4995+
49824996
retstp = nfsd4_find_existing_open(fp, open);
49834997
if (retstp)
49844998
goto out_unlock;
@@ -6132,6 +6146,11 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
61326146

61336147
if (!stp) {
61346148
stp = init_open_stateid(fp, open);
6149+
if (!stp) {
6150+
status = nfserr_jukebox;
6151+
goto out;
6152+
}
6153+
61356154
if (!open->op_stp)
61366155
new_stp = true;
61376156
}

0 commit comments

Comments
 (0)