Commit 1e89a194 authored by David Dillow's avatar David Dillow Committed by Roland Dreier

IB/srp: Enforce protocol limit on srp_sg_tablesize

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: default avatarDavid Dillow <dillowda@ornl.gov>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 826d8010
...@@ -68,7 +68,7 @@ static int srp_max_iu_len; ...@@ -68,7 +68,7 @@ static int srp_max_iu_len;
module_param(srp_sg_tablesize, int, 0444); module_param(srp_sg_tablesize, int, 0444);
MODULE_PARM_DESC(srp_sg_tablesize, 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; static int topspin_workarounds = 1;
...@@ -2138,6 +2138,11 @@ static int __init srp_init_module(void) ...@@ -2138,6 +2138,11 @@ static int __init srp_init_module(void)
{ {
int ret; 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 = ib_srp_transport_template =
srp_attach_transport(&ib_srp_transport_functions); srp_attach_transport(&ib_srp_transport_functions);
if (!ib_srp_transport_template) if (!ib_srp_transport_template)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment