Skip to content

Commit 6351323

Browse files
olgakorn1amschuma-ntap
authored andcommitted
NFS prevent double free in async nfs4_exchange_id
Since rpc_task is async, the release function should be called which will free the impl_id, scope, and owner. Trond pointed at 2 more problems: -- use of client pointer after free in the nfs4_exchangeid_release() function -- cl_count mismatch if rpc_run_task() isn't run Fixes: 8d89bd7 ("NFS setup async exchange_id") Signed-off-by: Olga Kornievskaia <kolga@netapp.com> Cc: stable@vger.kernel.org # 4.9 Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 05fae7b commit 6351323

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

fs/nfs/nfs4proc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7425,11 +7425,11 @@ static void nfs4_exchange_id_release(void *data)
74257425
struct nfs41_exchange_id_data *cdata =
74267426
(struct nfs41_exchange_id_data *)data;
74277427

7428-
nfs_put_client(cdata->args.client);
74297428
if (cdata->xprt) {
74307429
xprt_put(cdata->xprt);
74317430
rpc_clnt_xprt_switch_put(cdata->args.client->cl_rpcclient);
74327431
}
7432+
nfs_put_client(cdata->args.client);
74337433
kfree(cdata->res.impl_id);
74347434
kfree(cdata->res.server_scope);
74357435
kfree(cdata->res.server_owner);
@@ -7536,10 +7536,8 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
75367536
task_setup_data.callback_data = calldata;
75377537

75387538
task = rpc_run_task(&task_setup_data);
7539-
if (IS_ERR(task)) {
7540-
status = PTR_ERR(task);
7541-
goto out_impl_id;
7542-
}
7539+
if (IS_ERR(task))
7540+
return PTR_ERR(task);
75437541

75447542
if (!xprt) {
75457543
status = rpc_wait_for_completion_task(task);
@@ -7567,6 +7565,7 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
75677565
kfree(calldata->res.server_owner);
75687566
out_calldata:
75697567
kfree(calldata);
7568+
nfs_put_client(clp);
75707569
goto out;
75717570
}
75727571

0 commit comments

Comments
 (0)