Skip to content

Commit f96f8cc

Browse files
author
Trond Myklebust
committed
NFSv4: Sanity check the parameters in nfs41_update_target_slotid()
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]>
1 parent 1e2f67d commit f96f8cc

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

fs/nfs/nfs4session.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,16 @@ void nfs41_update_target_slotid(struct nfs4_slot_table *tbl,
511511
struct nfs4_slot *slot,
512512
struct nfs4_sequence_res *res)
513513
{
514+
u32 target_highest_slotid = min(res->sr_target_highest_slotid,
515+
NFS4_MAX_SLOTID);
516+
u32 highest_slotid = min(res->sr_highest_slotid, NFS4_MAX_SLOTID);
517+
514518
spin_lock(&tbl->slot_tbl_lock);
515-
if (!nfs41_is_outlier_target_slotid(tbl, res->sr_target_highest_slotid))
516-
nfs41_set_target_slotid_locked(tbl, res->sr_target_highest_slotid);
519+
if (!nfs41_is_outlier_target_slotid(tbl, target_highest_slotid))
520+
nfs41_set_target_slotid_locked(tbl, target_highest_slotid);
517521
if (tbl->generation == slot->generation)
518-
nfs41_set_server_slotid_locked(tbl, res->sr_highest_slotid);
519-
nfs41_set_max_slotid_locked(tbl, res->sr_target_highest_slotid);
522+
nfs41_set_server_slotid_locked(tbl, highest_slotid);
523+
nfs41_set_max_slotid_locked(tbl, target_highest_slotid);
520524
spin_unlock(&tbl->slot_tbl_lock);
521525
}
522526

fs/nfs/nfs4session.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define NFS4_DEF_SLOT_TABLE_SIZE (64U)
1313
#define NFS4_DEF_CB_SLOT_TABLE_SIZE (16U)
1414
#define NFS4_MAX_SLOT_TABLE (1024U)
15+
#define NFS4_MAX_SLOTID (NFS4_MAX_SLOT_TABLE - 1U)
1516
#define NFS4_NO_SLOT ((u32)-1)
1617

1718
#if IS_ENABLED(CONFIG_NFS_V4)

0 commit comments

Comments
 (0)