linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shannon Nelson <shannon.nelson@oracle.com>
To: Colin King <colin.king@canonical.com>,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	"David S . Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] netdevsim: fix sa_idx out of bounds check
Date: Sun, 1 Jul 2018 12:21:17 -0700	[thread overview]
Message-ID: <8bfbcc6a-eed8-c5fd-17a9-35fcf5f94b57@oracle.com> (raw)
In-Reply-To: <20180630203924.5121-1-colin.king@canonical.com>

On 6/30/2018 1:39 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently if sa_idx is equal to NSIM_IPSEC_MAX_SA_COUNT then
> an out-of-bounds read on ipsec->sa will occur. Fix the
> incorrect bounds check by using >= rather than >.
> 
> Detected by CoverityScan, CID#1470226 ("Out-of-bounds-read")
> 
> Fixes: 7699353da875 ("netdevsim: add ipsec offload testing")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/net/netdevsim/ipsec.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/netdevsim/ipsec.c b/drivers/net/netdevsim/ipsec.c
> index ceff544510b9..2dcf6cc269d0 100644
> --- a/drivers/net/netdevsim/ipsec.c
> +++ b/drivers/net/netdevsim/ipsec.c
> @@ -249,7 +249,7 @@ bool nsim_ipsec_tx(struct netdevsim *ns, struct sk_buff *skb)
>   	}
>   
>   	sa_idx = xs->xso.offload_handle & ~NSIM_IPSEC_VALID;
> -	if (unlikely(sa_idx > NSIM_IPSEC_MAX_SA_COUNT)) {
> +	if (unlikely(sa_idx >= NSIM_IPSEC_MAX_SA_COUNT)) {
>   		netdev_err(ns->netdev, "bad sa_idx=%d max=%d\n",
>   			   sa_idx, NSIM_IPSEC_MAX_SA_COUNT);
>   		return false;
> 

Good catch - thanks!

Acked-by: Shannon Nelson <shannon.nelson@oracle.com>

  reply	other threads:[~2018-07-01 19:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-30 20:39 [PATCH][next] netdevsim: fix sa_idx out of bounds check Colin King
2018-07-01 19:21 ` Shannon Nelson [this message]
2018-07-02 11:36 ` David Miller

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=8bfbcc6a-eed8-c5fd-17a9-35fcf5f94b57@oracle.com \
    --to=shannon.nelson@oracle.com \
    --cc=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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 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).