Skip to content

Commit

Permalink
NFSv4: Sanity check the parameters in nfs41_update_target_slotid()
Browse files Browse the repository at this point in the history
Ensure that the values supplied by the server do not exceed the size of
the largest allowed slot table.

Reported-by: <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
Trond Myklebust committed Nov 7, 2021
1 parent 1e2f67d commit f96f8cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fs/nfs/nfs4session.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,16 @@ void nfs41_update_target_slotid(struct nfs4_slot_table *tbl,
struct nfs4_slot *slot,
struct nfs4_sequence_res *res)
{
u32 target_highest_slotid = min(res->sr_target_highest_slotid,
NFS4_MAX_SLOTID);
u32 highest_slotid = min(res->sr_highest_slotid, NFS4_MAX_SLOTID);

spin_lock(&tbl->slot_tbl_lock);
if (!nfs41_is_outlier_target_slotid(tbl, res->sr_target_highest_slotid))
nfs41_set_target_slotid_locked(tbl, res->sr_target_highest_slotid);
if (!nfs41_is_outlier_target_slotid(tbl, target_highest_slotid))
nfs41_set_target_slotid_locked(tbl, target_highest_slotid);
if (tbl->generation == slot->generation)
nfs41_set_server_slotid_locked(tbl, res->sr_highest_slotid);
nfs41_set_max_slotid_locked(tbl, res->sr_target_highest_slotid);
nfs41_set_server_slotid_locked(tbl, highest_slotid);
nfs41_set_max_slotid_locked(tbl, target_highest_slotid);
spin_unlock(&tbl->slot_tbl_lock);
}

Expand Down
1 change: 1 addition & 0 deletions fs/nfs/nfs4session.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define NFS4_DEF_SLOT_TABLE_SIZE (64U)
#define NFS4_DEF_CB_SLOT_TABLE_SIZE (16U)
#define NFS4_MAX_SLOT_TABLE (1024U)
#define NFS4_MAX_SLOTID (NFS4_MAX_SLOT_TABLE - 1U)
#define NFS4_NO_SLOT ((u32)-1)

#if IS_ENABLED(CONFIG_NFS_V4)
Expand Down

0 comments on commit f96f8cc

Please sign in to comment.