提交 14f3df1d 编写于 作者: S Sasha Neftin 提交者: Zheng Zengkai

igc: Check if num of q_vectors is smaller than max before array access

stable inclusion
from stable-5.10.67
commit 463b3edfba90f6771195626b4f252c8545002cb2
bugzilla: 182619 https://gitee.com/openeuler/kernel/issues/I4EWO7

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=463b3edfba90f6771195626b4f252c8545002cb2

--------------------------------

[ Upstream commit 373e2829 ]

Ensure that the adapter->q_vector[MAX_Q_VECTORS] array isn't accessed
beyond its size. It was fixed by using a local variable num_q_vectors
as a limit for loop index, and ensure that num_q_vectors is not bigger
than MAX_Q_VECTORS.
Suggested-by: NAleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: NSasha Neftin <sasha.neftin@intel.com>
Tested-by: NDvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com>
Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 22551cac
...@@ -4066,6 +4066,7 @@ static irqreturn_t igc_msix_ring(int irq, void *data) ...@@ -4066,6 +4066,7 @@ static irqreturn_t igc_msix_ring(int irq, void *data)
*/ */
static int igc_request_msix(struct igc_adapter *adapter) static int igc_request_msix(struct igc_adapter *adapter)
{ {
unsigned int num_q_vectors = adapter->num_q_vectors;
int i = 0, err = 0, vector = 0, free_vector = 0; int i = 0, err = 0, vector = 0, free_vector = 0;
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
...@@ -4074,7 +4075,13 @@ static int igc_request_msix(struct igc_adapter *adapter) ...@@ -4074,7 +4075,13 @@ static int igc_request_msix(struct igc_adapter *adapter)
if (err) if (err)
goto err_out; goto err_out;
for (i = 0; i < adapter->num_q_vectors; i++) { if (num_q_vectors > MAX_Q_VECTORS) {
num_q_vectors = MAX_Q_VECTORS;
dev_warn(&adapter->pdev->dev,
"The number of queue vectors (%d) is higher than max allowed (%d)\n",
adapter->num_q_vectors, MAX_Q_VECTORS);
}
for (i = 0; i < num_q_vectors; i++) {
struct igc_q_vector *q_vector = adapter->q_vector[i]; struct igc_q_vector *q_vector = adapter->q_vector[i];
vector++; vector++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册