Unverified Commit 813fd722 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!14981 nfsd: fix nfs4_openowner leak when concurrent nfsd4_open occur

parents f1b1f1a6 c618349a
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -1625,6 +1625,12 @@ static void release_open_stateid(struct nfs4_ol_stateid *stp)
	free_ol_stateid_reaplist(&reaplist);
}

static bool nfs4_openowner_unhashed(struct nfs4_openowner *oo)
{
	return list_empty(&oo->oo_owner.so_strhash) &&
		list_empty(&oo->oo_perclient);
}

static void unhash_openowner_locked(struct nfs4_openowner *oo)
{
	struct nfs4_client *clp = oo->oo_owner.so_client;
@@ -4632,6 +4638,12 @@ init_open_stateid(struct nfs4_file *fp, struct nfsd4_open *open)
	spin_lock(&oo->oo_owner.so_client->cl_lock);
	spin_lock(&fp->fi_lock);

	if (nfs4_openowner_unhashed(oo)) {
		mutex_unlock(&stp->st_mutex);
		stp = NULL;
		goto out_unlock;
	}

	retstp = nfsd4_find_existing_open(fp, open);
	if (retstp)
		goto out_unlock;
@@ -5751,6 +5763,11 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf

	if (!stp) {
		stp = init_open_stateid(fp, open);
		if (!stp) {
			status = nfserr_jukebox;
			goto out;
		}

		if (!open->op_stp)
			new_stp = true;
	}