All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>, davem@davemloft.net
Cc: Shannon Nelson <shannon.nelson@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com
Subject: Re: [net-next 05/13] i40e: add range check to i40e_aq_rc_to_posix
Date: Tue, 09 Dec 2014 17:23:56 +0300	[thread overview]
Message-ID: <548705FC.6020805@cogentembedded.com> (raw)
In-Reply-To: <1418124170-7495-6-git-send-email-jeffrey.t.kirsher@intel.com>

Hello.

On 12/9/2014 2:22 PM, Jeff Kirsher wrote:

> From: Shannon Nelson <shannon.nelson@intel.com>

> Just to be sure, add a range check to avoid any possible
> array index-out-of-bound issues.

> Change-ID: I9323bee6732c2a47599816e1d6c6b3a1f8dcbf54
> Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
> Acked-by: Michal Kosiarz <michal.kosiarz@intel.com>
> Tested-by: Jim Young <jamesx.m.young@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
>   drivers/net/ethernet/intel/i40e/i40e_adminq.h   | 2 ++
>   drivers/net/ethernet/intel/i40evf/i40e_adminq.h | 2 ++
>   2 files changed, 4 insertions(+)

> diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.h b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
> index 618fe96..4064b1e 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_adminq.h
> +++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
> @@ -136,6 +136,8 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
>   		-EFBIG,      /* I40E_AQ_RC_EFBIG */
>   	};
>
> +	if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))

    There's ARRAY_SIZE() macro exactly for such computations. And parens 
around the last 'aq_to_posix' are not needed.

> +		return -ERANGE;
>   	return aq_to_posix[aq_rc];
>   }
>
> diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
> index d5d3c93..4d63514 100644
> --- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
> +++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
> @@ -136,6 +136,8 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
>   		-EFBIG,      /* I40E_AQ_RC_EFBIG */
>   	};
>
> +	if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))

    Likewise.

[...]

WBR, Sergei

  reply	other threads:[~2014-12-09 14:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-09 11:22 [net-next 00/13][pull request] Intel Wired LAN Driver Updates 2014-12-09 Jeff Kirsher
2014-12-09 11:22 ` [net-next 01/13] i40e: clear NVM update state on ethtool test Jeff Kirsher
2014-12-09 11:22 ` [net-next 02/13] i40e: better error messages for NVM update issues Jeff Kirsher
2014-12-09 11:22 ` [net-next 03/13] i40e: let firmware catch the NVM busy error Jeff Kirsher
2014-12-09 11:22 ` [net-next 04/13] i40e: rework debug messages for NVM update Jeff Kirsher
2014-12-09 11:22 ` [net-next 05/13] i40e: add range check to i40e_aq_rc_to_posix Jeff Kirsher
2014-12-09 14:23   ` Sergei Shtylyov [this message]
2014-12-09 17:35     ` Nelson, Shannon
2014-12-09 11:22 ` [net-next 06/13] i40e: init NVM update state on adminq init Jeff Kirsher
2014-12-09 11:22 ` [net-next 07/13] i40e: remove unused nvm_semaphore_wait Jeff Kirsher
2014-12-09 11:22 ` [net-next 08/13] i40e: set max limit for access polling Jeff Kirsher
2014-12-09 11:22 ` [net-next 09/13] i40e: fix up NVM update sm error handling Jeff Kirsher
2014-12-09 11:22 ` [net-next 10/13] i40e: poll on NVM semaphore only if not other error Jeff Kirsher
2014-12-09 11:22 ` [net-next 11/13] i40e: check for AQ timeout in aq_rc decode Jeff Kirsher
2014-12-09 11:22 ` [net-next 12/13] i40e: add to NVM update debug message Jeff Kirsher
2014-12-09 11:22 ` [net-next 13/13] i40e/i40evf: Convert macro to static inline Jeff Kirsher
2014-12-09 19:06   ` Sergei Shtylyov
2014-12-09 17:13 ` [net-next 00/13][pull request] Intel Wired LAN Driver Updates 2014-12-09 David Miller
2014-12-09 20:15   ` Jeff Kirsher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=548705FC.6020805@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=davem@davemloft.net \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jogreene@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    --cc=shannon.nelson@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.