mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
NFSv4/flexfiles: fix NULL dereference for NFSv4.0 data servers
flexfiles accepts NFSv4.0 data servers, but two NFSv4 code paths assume
the data server client has a session. Unlike NFSv4.1+, an NFSv4.0 client
has no session (clp->cl_session is NULL; it uses clp->cl_slot_tbl), so
I/O to a v4.0 flexfiles DS oopses:
- nfs4_init_ds_session() dereferences clp->cl_session->session_state
while seeding the DS lease. It also only seeds cl_lease_time when
NFS4_SESSION_INITING is set; without a session that never happens, so
cl_lease_time stays 0 and nfs4_renew_state() busy-loops, requeuing
every 5 seconds. Seed the lease whenever there is no session and
return before touching session state.
- ff_layout_async_handle_error_v4() dereferences
clp->cl_session->fc_slot_table on every DS I/O error. Fall back to the
v4.0 transport slot table (clp->cl_slot_tbl) when there is no session.
Fixes: a7878ca140 ("nfs: flexfilelayout: remove v3-only data server limitation")
Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
parent
8cb1ce7aa0
commit
2b03ebbf8d
|
|
@ -1322,7 +1322,8 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task,
|
|||
struct pnfs_layout_hdr *lo = lseg->pls_layout;
|
||||
struct inode *inode = lo->plh_inode;
|
||||
struct nfs4_deviceid_node *devid = FF_LAYOUT_DEVID_NODE(lseg, idx, dss_id);
|
||||
struct nfs4_slot_table *tbl = &clp->cl_session->fc_slot_table;
|
||||
struct nfs4_slot_table *tbl = nfs4_has_session(clp) ?
|
||||
&clp->cl_session->fc_slot_table : clp->cl_slot_tbl;
|
||||
|
||||
switch (op_status) {
|
||||
case NFS4_OK:
|
||||
|
|
|
|||
|
|
@ -632,16 +632,22 @@ int nfs4_init_ds_session(struct nfs_client *clp, unsigned long lease_time)
|
|||
int ret;
|
||||
|
||||
spin_lock(&clp->cl_lock);
|
||||
if (test_and_clear_bit(NFS4_SESSION_INITING, &session->session_state)) {
|
||||
/*
|
||||
* Do not set NFS_CS_CHECK_LEASE_TIME instead set the
|
||||
* DS lease to be equal to the MDS lease.
|
||||
*/
|
||||
/*
|
||||
* Do not set NFS_CS_CHECK_LEASE_TIME instead set the
|
||||
* DS lease to be equal to the MDS lease.
|
||||
*
|
||||
* A v4.0 DS has no session, so seed the lease every time.
|
||||
*/
|
||||
if (!session ||
|
||||
test_and_clear_bit(NFS4_SESSION_INITING, &session->session_state)) {
|
||||
clp->cl_lease_time = lease_time;
|
||||
clp->cl_last_renewal = jiffies;
|
||||
}
|
||||
spin_unlock(&clp->cl_lock);
|
||||
|
||||
if (!session)
|
||||
return 0;
|
||||
|
||||
ret = nfs41_check_session_ready(clp);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user