Skip to content

Commit 576acc2

Browse files
scottmayhewTrond Myklebust
authored andcommitted
nfs4: take a reference on the nfs_client when running FREE_STATEID
During umount, the session slot tables are freed. If there are outstanding FREE_STATEID tasks, a use-after-free and slab corruption can occur when rpc_exit_task calls rpc_call_done -> nfs41_sequence_done -> nfs4_sequence_process/nfs41_sequence_free_slot. Prevent that from happening by taking a reference on the nfs_client in nfs41_free_stateid and putting it in nfs41_free_stateid_release. Signed-off-by: Scott Mayhew <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent edfa0b1 commit 576acc2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/nfs/nfs4proc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10115,6 +10115,10 @@ static void nfs41_free_stateid_done(struct rpc_task *task, void *calldata)
1011510115

1011610116
static void nfs41_free_stateid_release(void *calldata)
1011710117
{
10118+
struct nfs_free_stateid_data *data = calldata;
10119+
struct nfs_client *clp = data->server->nfs_client;
10120+
10121+
nfs_put_client(clp);
1011810122
kfree(calldata);
1011910123
}
1012010124

@@ -10151,6 +10155,10 @@ static int nfs41_free_stateid(struct nfs_server *server,
1015110155
};
1015210156
struct nfs_free_stateid_data *data;
1015310157
struct rpc_task *task;
10158+
struct nfs_client *clp = server->nfs_client;
10159+
10160+
if (!refcount_inc_not_zero(&clp->cl_count))
10161+
return -EIO;
1015410162

1015510163
nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_STATEID,
1015610164
&task_setup.rpc_client, &msg);

0 commit comments

Comments
 (0)