Commit 429b6a72 authored by Harish Chegondi's avatar Harish Chegondi Committed by Doug Ledford

IB/hfi1: Make n_krcvqs be an unsigned long integer

The global variable n_krcvqs stores the sum of the number of kernel
receive queues of VLs 0-7 which the user can pass to the driver through
the module parameter array krcvqs which is of type unsigned integer. If
the user passes large value(s) into krcvqs parameter array, it can cause
an arithmetic overflow while calculating n_krcvqs which is also of type
unsigned int. The overflow results in an incorrect value of n_krcvqs
which can lead to kernel crash while loading the driver.

Fix by changing the data type of n_krcvqs to unsigned long. This patch
also changes the data type of other variables that get their values from
n_krcvqs.
Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarHarish Chegondi <harish.chegondi@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 673b975f
...@@ -12935,7 +12935,7 @@ static int set_up_interrupts(struct hfi1_devdata *dd) ...@@ -12935,7 +12935,7 @@ static int set_up_interrupts(struct hfi1_devdata *dd)
*/ */
static int set_up_context_variables(struct hfi1_devdata *dd) static int set_up_context_variables(struct hfi1_devdata *dd)
{ {
int num_kernel_contexts; unsigned long num_kernel_contexts;
int total_contexts; int total_contexts;
int ret; int ret;
unsigned ngroups; unsigned ngroups;
...@@ -12964,9 +12964,9 @@ static int set_up_context_variables(struct hfi1_devdata *dd) ...@@ -12964,9 +12964,9 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
*/ */
if (num_kernel_contexts > (dd->chip_send_contexts - num_vls - 1)) { if (num_kernel_contexts > (dd->chip_send_contexts - num_vls - 1)) {
dd_dev_err(dd, dd_dev_err(dd,
"Reducing # kernel rcv contexts to: %d, from %d\n", "Reducing # kernel rcv contexts to: %d, from %lu\n",
(int)(dd->chip_send_contexts - num_vls - 1), (int)(dd->chip_send_contexts - num_vls - 1),
(int)num_kernel_contexts); num_kernel_contexts);
num_kernel_contexts = dd->chip_send_contexts - num_vls - 1; num_kernel_contexts = dd->chip_send_contexts - num_vls - 1;
} }
/* /*
......
...@@ -1806,7 +1806,7 @@ extern unsigned int hfi1_max_mtu; ...@@ -1806,7 +1806,7 @@ extern unsigned int hfi1_max_mtu;
extern unsigned int hfi1_cu; extern unsigned int hfi1_cu;
extern unsigned int user_credit_return_threshold; extern unsigned int user_credit_return_threshold;
extern int num_user_contexts; extern int num_user_contexts;
extern unsigned n_krcvqs; extern unsigned long n_krcvqs;
extern uint krcvqs[]; extern uint krcvqs[];
extern int krcvqsset; extern int krcvqsset;
extern uint kdeth_qp; extern uint kdeth_qp;
......
...@@ -94,7 +94,7 @@ module_param_array(krcvqs, uint, &krcvqsset, S_IRUGO); ...@@ -94,7 +94,7 @@ module_param_array(krcvqs, uint, &krcvqsset, S_IRUGO);
MODULE_PARM_DESC(krcvqs, "Array of the number of non-control kernel receive queues by VL"); MODULE_PARM_DESC(krcvqs, "Array of the number of non-control kernel receive queues by VL");
/* computed based on above array */ /* computed based on above array */
unsigned n_krcvqs; unsigned long n_krcvqs;
static unsigned hfi1_rcvarr_split = 25; static unsigned hfi1_rcvarr_split = 25;
module_param_named(rcvarr_split, hfi1_rcvarr_split, uint, S_IRUGO); module_param_named(rcvarr_split, hfi1_rcvarr_split, uint, S_IRUGO);
......
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