diff mbox series

[ovs-dev,v3] flow: fix incorrect padding length checking in ipv6_sanity_check

Message ID 1567413407-29664-1-git-send-email-Yanqin.Wei@arm.com
State Accepted
Commit 892545b953d23e29da8f556937f7ea66d0e85e28
Headers show
Series [ovs-dev,v3] flow: fix incorrect padding length checking in ipv6_sanity_check | expand

Commit Message

Yanqin Wei Sept. 2, 2019, 8:36 a.m. UTC
The padding length is (packet size - ipv6 header length - ipv6 plen).  This
patch fixes incorrect padding size checking in ipv6_sanity_check.

Reviewed-by: Gavin Hu <Gavin.Hu@arm.com>
Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
---
 lib/flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

William Tu Sept. 3, 2019, 3:57 p.m. UTC | #1
On Mon, Sep 02, 2019 at 04:36:47PM +0800, Yanqin Wei wrote:
> The padding length is (packet size - ipv6 header length - ipv6 plen).  This
> patch fixes incorrect padding size checking in ipv6_sanity_check.
> 
> Reviewed-by: Gavin Hu <Gavin.Hu@arm.com>
> Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>

Looks good to me.

Acked-by: William Tu <u9012063@gmail.com>

> ---
>  lib/flow.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/flow.c b/lib/flow.c
> index ac6a4e1..0413c67 100644
> --- a/lib/flow.c
> +++ b/lib/flow.c
> @@ -699,7 +699,7 @@ ipv6_sanity_check(const struct ovs_16aligned_ip6_hdr *nh, size_t size)
>          return false;
>      }
>      /* Jumbo Payload option not supported yet. */
> -    if (OVS_UNLIKELY(size - plen > UINT8_MAX)) {
> +    if (OVS_UNLIKELY(size - (plen + IPV6_HEADER_LEN) > UINT8_MAX)) {
>          return false;
>      }
>  
> -- 
> 2.7.4
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Ben Pfaff Sept. 26, 2019, 12:27 a.m. UTC | #2
On Tue, Sep 03, 2019 at 08:57:02AM -0700, William Tu wrote:
> On Mon, Sep 02, 2019 at 04:36:47PM +0800, Yanqin Wei wrote:
> > The padding length is (packet size - ipv6 header length - ipv6 plen).  This
> > patch fixes incorrect padding size checking in ipv6_sanity_check.
> > 
> > Reviewed-by: Gavin Hu <Gavin.Hu@arm.com>
> > Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
> 
> Looks good to me.
> 
> Acked-by: William Tu <u9012063@gmail.com>

Thanks Yanqin (and William).  I applied this to master and backported as
far as branch-2.10.
diff mbox series

Patch

diff --git a/lib/flow.c b/lib/flow.c
index ac6a4e1..0413c67 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -699,7 +699,7 @@  ipv6_sanity_check(const struct ovs_16aligned_ip6_hdr *nh, size_t size)
         return false;
     }
     /* Jumbo Payload option not supported yet. */
-    if (OVS_UNLIKELY(size - plen > UINT8_MAX)) {
+    if (OVS_UNLIKELY(size - (plen + IPV6_HEADER_LEN) > UINT8_MAX)) {
         return false;
     }