Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 848f5bda authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFSv4.1: Ensure we use the correct credentials for session create/destroy

parent ad24ecfb
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -241,8 +241,8 @@ extern int nfs41_setup_sequence(struct nfs4_session *session,
		struct rpc_task *task);
		struct rpc_task *task);
extern void nfs4_destroy_session(struct nfs4_session *session);
extern void nfs4_destroy_session(struct nfs4_session *session);
extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp);
extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp);
extern int nfs4_proc_create_session(struct nfs_client *);
extern int nfs4_proc_create_session(struct nfs_client *, struct rpc_cred *);
extern int nfs4_proc_destroy_session(struct nfs4_session *);
extern int nfs4_proc_destroy_session(struct nfs4_session *, struct rpc_cred *);
extern int nfs4_init_session(struct nfs_server *server);
extern int nfs4_init_session(struct nfs_server *server);
extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
		struct nfs_fsinfo *fsinfo);
		struct nfs_fsinfo *fsinfo);
+17 −10
Original line number Original line Diff line number Diff line
@@ -5480,8 +5480,12 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
void nfs4_destroy_session(struct nfs4_session *session)
void nfs4_destroy_session(struct nfs4_session *session)
{
{
	struct rpc_xprt *xprt;
	struct rpc_xprt *xprt;
	struct rpc_cred *cred;


	nfs4_proc_destroy_session(session);
	cred = nfs4_get_exchange_id_cred(session->clp);
	nfs4_proc_destroy_session(session, cred);
	if (cred)
		put_rpccred(cred);


	rcu_read_lock();
	rcu_read_lock();
	xprt = rcu_dereference(session->clp->cl_rpcclient->cl_xprt);
	xprt = rcu_dereference(session->clp->cl_rpcclient->cl_xprt);
@@ -5591,7 +5595,8 @@ static int nfs4_verify_channel_attrs(struct nfs41_create_session_args *args,
	return nfs4_verify_back_channel_attrs(args, session);
	return nfs4_verify_back_channel_attrs(args, session);
}
}


static int _nfs4_proc_create_session(struct nfs_client *clp)
static int _nfs4_proc_create_session(struct nfs_client *clp,
		struct rpc_cred *cred)
{
{
	struct nfs4_session *session = clp->cl_session;
	struct nfs4_session *session = clp->cl_session;
	struct nfs41_create_session_args args = {
	struct nfs41_create_session_args args = {
@@ -5605,6 +5610,7 @@ static int _nfs4_proc_create_session(struct nfs_client *clp)
		.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE_SESSION],
		.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE_SESSION],
		.rpc_argp = &args,
		.rpc_argp = &args,
		.rpc_resp = &res,
		.rpc_resp = &res,
		.rpc_cred = cred,
	};
	};
	int status;
	int status;


@@ -5629,7 +5635,7 @@ static int _nfs4_proc_create_session(struct nfs_client *clp)
 * It is the responsibility of the caller to verify the session is
 * It is the responsibility of the caller to verify the session is
 * expired before calling this routine.
 * expired before calling this routine.
 */
 */
int nfs4_proc_create_session(struct nfs_client *clp)
int nfs4_proc_create_session(struct nfs_client *clp, struct rpc_cred *cred)
{
{
	int status;
	int status;
	unsigned *ptr;
	unsigned *ptr;
@@ -5637,7 +5643,7 @@ int nfs4_proc_create_session(struct nfs_client *clp)


	dprintk("--> %s clp=%p session=%p\n", __func__, clp, session);
	dprintk("--> %s clp=%p session=%p\n", __func__, clp, session);


	status = _nfs4_proc_create_session(clp);
	status = _nfs4_proc_create_session(clp, cred);
	if (status)
	if (status)
		goto out;
		goto out;


@@ -5659,10 +5665,15 @@ int nfs4_proc_create_session(struct nfs_client *clp)
 * Issue the over-the-wire RPC DESTROY_SESSION.
 * Issue the over-the-wire RPC DESTROY_SESSION.
 * The caller must serialize access to this routine.
 * The caller must serialize access to this routine.
 */
 */
int nfs4_proc_destroy_session(struct nfs4_session *session)
int nfs4_proc_destroy_session(struct nfs4_session *session,
		struct rpc_cred *cred)
{
{
	struct rpc_message msg = {
		.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_SESSION],
		.rpc_argp = session,
		.rpc_cred = cred,
	};
	int status = 0;
	int status = 0;
	struct rpc_message msg;


	dprintk("--> nfs4_proc_destroy_session\n");
	dprintk("--> nfs4_proc_destroy_session\n");


@@ -5670,10 +5681,6 @@ int nfs4_proc_destroy_session(struct nfs4_session *session)
	if (session->clp->cl_cons_state != NFS_CS_READY)
	if (session->clp->cl_cons_state != NFS_CS_READY)
		return status;
		return status;


	msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_SESSION];
	msg.rpc_argp = session;
	msg.rpc_resp = NULL;
	msg.rpc_cred = NULL;
	status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
	status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);


	if (status)
	if (status)
+7 −3
Original line number Original line Diff line number Diff line
@@ -256,7 +256,7 @@ int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
		goto out;
		goto out;
	set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
	set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
do_confirm:
do_confirm:
	status = nfs4_proc_create_session(clp);
	status = nfs4_proc_create_session(clp, cred);
	if (status != 0)
	if (status != 0)
		goto out;
		goto out;
	clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
	clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
@@ -1717,10 +1717,12 @@ void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)


static int nfs4_reset_session(struct nfs_client *clp)
static int nfs4_reset_session(struct nfs_client *clp)
{
{
	struct rpc_cred *cred;
	int status;
	int status;


	nfs4_begin_drain_session(clp);
	nfs4_begin_drain_session(clp);
	status = nfs4_proc_destroy_session(clp->cl_session);
	cred = nfs4_get_exchange_id_cred(clp);
	status = nfs4_proc_destroy_session(clp->cl_session, cred);
	if (status && status != -NFS4ERR_BADSESSION &&
	if (status && status != -NFS4ERR_BADSESSION &&
	    status != -NFS4ERR_DEADSESSION) {
	    status != -NFS4ERR_DEADSESSION) {
		status = nfs4_recovery_handle_error(clp, status);
		status = nfs4_recovery_handle_error(clp, status);
@@ -1728,7 +1730,7 @@ static int nfs4_reset_session(struct nfs_client *clp)
	}
	}


	memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN);
	memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN);
	status = nfs4_proc_create_session(clp);
	status = nfs4_proc_create_session(clp, cred);
	if (status) {
	if (status) {
		status = nfs4_recovery_handle_error(clp, status);
		status = nfs4_recovery_handle_error(clp, status);
		goto out;
		goto out;
@@ -1742,6 +1744,8 @@ static int nfs4_reset_session(struct nfs_client *clp)
	if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
	if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
		nfs41_setup_state_renewal(clp);
		nfs41_setup_state_renewal(clp);
out:
out:
	if (cred)
		put_rpccred(cred);
	return status;
	return status;
}
}