* [PATCH][next] netdevsim: fix sa_idx out of bounds check
@ 2018-06-30 20:39 Colin King
2018-07-01 19:21 ` Shannon Nelson
2018-07-02 11:36 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2018-06-30 20:39 UTC (permalink / raw)
To: Jakub Kicinski, David S . Miller, netdev; +Cc: kernel-janitors, linux-kernel
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;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] netdevsim: fix sa_idx out of bounds check
2018-06-30 20:39 [PATCH][next] netdevsim: fix sa_idx out of bounds check Colin King
@ 2018-07-01 19:21 ` Shannon Nelson
2018-07-02 11:36 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Shannon Nelson @ 2018-07-01 19:21 UTC (permalink / raw)
To: Colin King, Jakub Kicinski, David S . Miller, netdev
Cc: kernel-janitors, linux-kernel
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] netdevsim: fix sa_idx out of bounds check
2018-06-30 20:39 [PATCH][next] netdevsim: fix sa_idx out of bounds check Colin King
2018-07-01 19:21 ` Shannon Nelson
@ 2018-07-02 11:36 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-07-02 11:36 UTC (permalink / raw)
To: colin.king; +Cc: jakub.kicinski, netdev, kernel-janitors, linux-kernel
From: Colin King <colin.king@canonical.com>
Date: Sat, 30 Jun 2018 21:39:24 +0100
> 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>
Applied, thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-02 11:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-30 20:39 [PATCH][next] netdevsim: fix sa_idx out of bounds check Colin King
2018-07-01 19:21 ` Shannon Nelson
2018-07-02 11:36 ` David Miller
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).