qlcnic: underflow in qlcnic_validate_max_tx_rings()
PATCH 1/1 qlcnic: underflow in qlcnic_validate_max_tx_rings()
This function checks the upper bound but it doesn't check for negative numbers:
if (txq > QLCNIC_MAX_TX_RINGS) {I've solved this by making "txq" a u32 type. I chose that because ->tx_count in the ethtool_channels struct is a __u32.
This bug was added in aa4a1f7df7 ('qlcnic: Enable Tx queue changes using ethtool for 82xx Series adapter.').
drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +1 -1
@@ -1537,7 +1537,7 @@ int qlcnic_diag_alloc_res(struct net_device *netdev, int test);netdev_tx_t qlcnic_xmit_frame (struct sk_buff *skb,struct net_device *netdev);int qlcnic_set_max_rss (struct qlcnic_adapter *,u8 ,int );int qlcnic_validate_max_rss (struct qlcnic_adapter *,__u32 ); -int qlcnic_validate_max_tx_rings (struct qlcnic_adapter *,int ); +int qlcnic_validate_max_tx_rings (struct qlcnic_adapter *,u32 txq);void qlcnic_alloc_lb_filters_mem (struct qlcnic_adapter *adapter);void qlcnic_82xx_set_mac_filter_count (struct qlcnic_adapter *);int qlcnic_enable_msix (struct qlcnic_adapter *,u32 );
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +1 -1
@@ -3524,7 +3524,7 @@ qlcnicvf_start_firmware(struct qlcnic_adapter *adapter)return err; } -int qlcnic_validate_max_tx_rings (struct qlcnic_adapter *adapter,int txq) +int qlcnic_validate_max_tx_rings (struct qlcnic_adapter *adapter,u32 txq) {struct net_device *netdev = adapter->netdev;u8 max_hw =QLCNIC_MAX_TX_RINGS ;
________________________________________
From: Dan Carpenter [[email protected]]
Sent: Monday, August 26, 2013 6:16 PM
To: Himanshu Madhani
Cc: Rajesh Borundia; Shahed Shaikh; Jitendra Kalsaria; Sony Chacko; Sucheta Chakraborty; Dept-Eng Linux Driver; netdev; [email protected]
Subject: [patch -next] qlcnic: underflow in qlcnic_validate_max_tx_rings()
This function checks the upper bound but it doesn't check for negative numbers:
if (txq > QLCNIC_MAX_TX_RINGS) {I've solved this by making "txq" a u32 type. I chose that because ->tx_count in the ethtool_channels struct is a __u32.
This bug was added in aa4a1f7df7 ('qlcnic: Enable Tx queue changes using ethtool for 82xx Series adapter.').
drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +1 -1
@@ -1537,7 +1537,7 @@ int qlcnic_diag_alloc_res(struct net_device *netdev, int test);netdev_tx_t qlcnic_xmit_frame (struct sk_buff *skb,struct net_device *netdev);int qlcnic_set_max_rss (struct qlcnic_adapter *,u8 ,int );int qlcnic_validate_max_rss (struct qlcnic_adapter *,__u32 ); -int qlcnic_validate_max_tx_rings (struct qlcnic_adapter *,int ); +int qlcnic_validate_max_tx_rings (struct qlcnic_adapter *,u32 txq);void qlcnic_alloc_lb_filters_mem (struct qlcnic_adapter *adapter);void qlcnic_82xx_set_mac_filter_count (struct qlcnic_adapter *);int qlcnic_enable_msix (struct qlcnic_adapter *,u32 );
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +1 -1
@@ -3524,7 +3524,7 @@ qlcnicvf_start_firmware(struct qlcnic_adapter *adapter)return err; } -int qlcnic_validate_max_tx_rings (struct qlcnic_adapter *adapter,int txq) +int qlcnic_validate_max_tx_rings (struct qlcnic_adapter *adapter,u32 txq) {struct net_device *netdev = adapter->netdev;u8 max_hw =QLCNIC_MAX_TX_RINGS ;
Thanks
Quoted 42 lines
-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Monday, August 26, 2013 6:16 PM
To: Himanshu Madhani
Cc: Rajesh Borundia; Shahed Shaikh; Jitendra Kalsaria; Sony Chacko; Sucheta Chakraborty; Dept-Eng Linux Driver; netdev; [email protected]
Subject: [patch -next] qlcnic: underflow inqlcnic_validate_max_tx_rings()This function checks the upper bound but it doesn't check for negative numbers:
if (txq > QLCNIC_MAX_TX_RINGS) {I've solved this by making "txq" a u32 type. I chose that because ->tx_count in the
ethtool_channelsstruct is a__u32.This bug was added in
aa4a1f7df7('qlcnic: Enable Tx queue changes using ethtool for 82xx Series adapter.').Signed-off-by Dan Carpenter <[email protected]>drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +0
-0@@ -1537,7 +1537,7 @@ int qlcnic_diag_alloc_res(struct net_device *netdev, int test); netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev); int qlcnic_set_max_rss(struct qlcnic_adapter *,u8, int); int
qlcnic_validate_max_rss(struct qlcnic_adapter *, __u32); -intqlcnic_validate_max_tx_rings(struct qlcnic_adapter *, int);
+intqlcnic_validate_max_tx_rings(struct qlcnic_adapter *, u32 txq);
voidqlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter); voidqlcnic_82xx_set_mac_filter_count(struct qlcnic_adapter *); intqlcnic_enable_msix(struct qlcnic_adapter *, u32); diff --gita/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.cb/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 8321d1a..88e3c97 100644
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c qlcnicvf_start_firmware(struct qlcnic_adapter · line 3530
Quoted 10 lines
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +2
-1@@ -3524,7 +3524,7 @@ qlcnicvf_start_firmware(struct qlcnic_adapter *adapter)return err; } -int qlcnic_validate_max_tx_rings (struct qlcnic_adapter *adapter,int txq) +int qlcnic_validate_max_tx_rings (struct qlcnic_adapter *adapter,u32 +txq) {struct net_device *netdev = adapter->netdev;u8 max_hw =QLCNIC_MAX_TX_RINGS ;
Thanks
From: Dan Carpenter <[email protected]>
Date: Tue, 27 Aug 2013 04:16:22 +0300
Quoted 5 lines
This function checks the upper bound but it doesn't check for negative numbers:
if (txq > QLCNIC_MAX_TX_RINGS) {
Quoted 7 lines
I've solved this by making "txq" a u32 type. I chose that because ->tx_count in the
ethtool_channelsstruct is a__u32.This bug was added in
aa4a1f7df7('qlcnic: Enable Tx queue changes using ethtool for 82xx Series adapter.').Signed-off-by Dan Carpenter <[email protected]>
Applied, thanks.