* [PATCH net] ice: Fix a couple off by one bugs
@ 2020-01-31 4:56 Dan Carpenter
2020-01-31 10:15 ` Maciej Fijalkowski
2020-02-07 22:38 ` [Intel-wired-lan] " Bowers, AndrewX
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-01-31 4:56 UTC (permalink / raw)
To: Jeff Kirsher, Tony Nguyen
Cc: David S. Miller, Henry Tieman, intel-wired-lan, netdev, kernel-janitors
The hw->blk[blk]->es.ref_count[] array has hw->blk[blk].es.count
elements. It gets allocated in ice_init_hw_tbls(). So the > should be
>= to prevent accessing one element beyond the end of the array.
Fixes: 2c61054c5fda ("ice: Optimize table usage")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
index 99208946224c..38a7041fe774 100644
--- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
+++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
@@ -1950,7 +1950,7 @@ ice_free_prof_id(struct ice_hw *hw, enum ice_block blk, u8 prof_id)
static enum ice_status
ice_prof_inc_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id)
{
- if (prof_id > hw->blk[blk].es.count)
+ if (prof_id >= hw->blk[blk].es.count)
return ICE_ERR_PARAM;
hw->blk[blk].es.ref_count[prof_id]++;
@@ -1991,7 +1991,7 @@ ice_write_es(struct ice_hw *hw, enum ice_block blk, u8 prof_id,
static enum ice_status
ice_prof_dec_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id)
{
- if (prof_id > hw->blk[blk].es.count)
+ if (prof_id >= hw->blk[blk].es.count)
return ICE_ERR_PARAM;
if (hw->blk[blk].es.ref_count[prof_id] > 0) {
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] ice: Fix a couple off by one bugs
2020-01-31 4:56 [PATCH net] ice: Fix a couple off by one bugs Dan Carpenter
@ 2020-01-31 10:15 ` Maciej Fijalkowski
2020-02-07 22:38 ` [Intel-wired-lan] " Bowers, AndrewX
1 sibling, 0 replies; 3+ messages in thread
From: Maciej Fijalkowski @ 2020-01-31 10:15 UTC (permalink / raw)
To: Dan Carpenter
Cc: Jeff Kirsher, Tony Nguyen, David S. Miller, Henry Tieman,
intel-wired-lan, netdev, kernel-janitors
On Fri, Jan 31, 2020 at 07:56:59AM +0300, Dan Carpenter wrote:
> The hw->blk[blk]->es.ref_count[] array has hw->blk[blk].es.count
> elements. It gets allocated in ice_init_hw_tbls(). So the > should be
> >= to prevent accessing one element beyond the end of the array.
>
> Fixes: 2c61054c5fda ("ice: Optimize table usage")
You should also provide:
Fixes: 31ad4e4ee1e4 ("ice: Allocate flow profile")
prof_id can be 0 so thanks for catching this. You can take my:
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
> index 99208946224c..38a7041fe774 100644
> --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
> +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
> @@ -1950,7 +1950,7 @@ ice_free_prof_id(struct ice_hw *hw, enum ice_block blk, u8 prof_id)
> static enum ice_status
> ice_prof_inc_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id)
> {
> - if (prof_id > hw->blk[blk].es.count)
> + if (prof_id >= hw->blk[blk].es.count)
> return ICE_ERR_PARAM;
>
> hw->blk[blk].es.ref_count[prof_id]++;
> @@ -1991,7 +1991,7 @@ ice_write_es(struct ice_hw *hw, enum ice_block blk, u8 prof_id,
> static enum ice_status
> ice_prof_dec_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id)
> {
> - if (prof_id > hw->blk[blk].es.count)
> + if (prof_id >= hw->blk[blk].es.count)
> return ICE_ERR_PARAM;
>
> if (hw->blk[blk].es.ref_count[prof_id] > 0) {
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [Intel-wired-lan] [PATCH net] ice: Fix a couple off by one bugs
2020-01-31 4:56 [PATCH net] ice: Fix a couple off by one bugs Dan Carpenter
2020-01-31 10:15 ` Maciej Fijalkowski
@ 2020-02-07 22:38 ` Bowers, AndrewX
1 sibling, 0 replies; 3+ messages in thread
From: Bowers, AndrewX @ 2020-02-07 22:38 UTC (permalink / raw)
To: netdev, intel-wired-lan
> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On
> Behalf Of Dan Carpenter
> Sent: Thursday, January 30, 2020 8:57 PM
> To: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>; Nguyen, Anthony L
> <anthony.l.nguyen@intel.com>
> Cc: netdev@vger.kernel.org; kernel-janitors@vger.kernel.org; intel-wired-
> lan@lists.osuosl.org; David S. Miller <davem@davemloft.net>
> Subject: [Intel-wired-lan] [PATCH net] ice: Fix a couple off by one bugs
>
> The hw->blk[blk]->es.ref_count[] array has hw->blk[blk].es.count elements.
> It gets allocated in ice_init_hw_tbls(). So the > should be
> >= to prevent accessing one element beyond the end of the array.
>
> Fixes: 2c61054c5fda ("ice: Optimize table usage")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-07 22:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-31 4:56 [PATCH net] ice: Fix a couple off by one bugs Dan Carpenter
2020-01-31 10:15 ` Maciej Fijalkowski
2020-02-07 22:38 ` [Intel-wired-lan] " Bowers, AndrewX
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).