Skip to content

Commit

Permalink
IB/srp: Enforce protocol limit on srp_sg_tablesize
Browse files Browse the repository at this point in the history
The current SRP initiator will allow unlimited s/g entries in the
indirect descriptors lists, but the entry count field in the SRP_CMD
request is 8 bits, so setting srp_sg_tablesize too large will open the
possibility of wrapping the count and generating invalid requests.

Clamp srp_sg_tablesize to the protocol limits to prevent surprises.

Reported by Martin W. Schlining III <mschlining@datadirectnet.com>.

Signed-off-by: David Dillow <dillowda@ornl.gov>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
  • Loading branch information
David Dillow authored and Roland Dreier committed Apr 17, 2008
1 parent 826d801 commit 1e89a19
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/infiniband/ulp/srp/ib_srp.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static int srp_max_iu_len;

module_param(srp_sg_tablesize, int, 0444);
MODULE_PARM_DESC(srp_sg_tablesize,
"Max number of gather/scatter entries per I/O (default is 12)");
"Max number of gather/scatter entries per I/O (default is 12, max 255)");

static int topspin_workarounds = 1;

Expand Down Expand Up @@ -2138,6 +2138,11 @@ static int __init srp_init_module(void)
{
int ret;

if (srp_sg_tablesize > 255) {
printk(KERN_WARNING PFX "Clamping srp_sg_tablesize to 255\n");
srp_sg_tablesize = 255;
}

ib_srp_transport_template =
srp_attach_transport(&ib_srp_transport_functions);
if (!ib_srp_transport_template)
Expand Down

0 comments on commit 1e89a19

Please sign in to comment.