diff mbox series

[ovs-dev,v2] odp-execute: Fix length checking while executing check_pkt_len action.

Message ID 20200626105110.4074225-1-i.maximets@ovn.org
State New
Headers show
Series [ovs-dev,v2] odp-execute: Fix length checking while executing check_pkt_len action. | expand

Commit Message

Ilya Maximets June 26, 2020, 10:51 a.m. UTC
If dp-packet contains l2 padding or cutlen was applied to it, size will
be larger than the actual size of a payload and action will work
incorrectly.

Ex. Padding could be added during miniflow_extract() if detected.

CC: Numan Siddique <nusiddiq@redhat.com>
Fixes: 5b34f8fc3b38 ("Add a new OVS action check_pkt_larger")
Reported-by: Miroslav Kubiczek <miroslav.kubiczek@adaptivemobile.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2020-May/050157.html
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---

Version 2:
  - Using dp_packet_get_send_len() to account cutlen.

 lib/odp-execute.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Dumitru Ceara June 26, 2020, 4:01 p.m. UTC | #1
On 6/26/20 12:51 PM, Ilya Maximets wrote:
> If dp-packet contains l2 padding or cutlen was applied to it, size will
> be larger than the actual size of a payload and action will work
> incorrectly.
> 
> Ex. Padding could be added during miniflow_extract() if detected.
> 
> CC: Numan Siddique <nusiddiq@redhat.com>
> Fixes: 5b34f8fc3b38 ("Add a new OVS action check_pkt_larger")
> Reported-by: Miroslav Kubiczek <miroslav.kubiczek@adaptivemobile.com>
> Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2020-May/050157.html
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>

Looks good to me, thanks!

Acked-by: Dumitru Ceara <dceara@redhat.com>

> ---
> 
> Version 2:
>   - Using dp_packet_get_send_len() to account cutlen.
> 
>  lib/odp-execute.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/odp-execute.c b/lib/odp-execute.c
> index 6018e378a..6eeda2a61 100644
> --- a/lib/odp-execute.c
> +++ b/lib/odp-execute.c
> @@ -761,10 +761,11 @@ odp_execute_check_pkt_len(void *dp, struct dp_packet *packet, bool steal,
>  
>      const struct nlattr *a;
>      struct dp_packet_batch pb;
> +    uint32_t size = dp_packet_get_send_len(packet)
> +                    - dp_packet_l2_pad_size(packet);
>  
>      a = attrs[OVS_CHECK_PKT_LEN_ATTR_PKT_LEN];
> -    bool is_greater = dp_packet_size(packet) > nl_attr_get_u16(a);
> -    if (is_greater) {
> +    if (size > nl_attr_get_u16(a)) {
>          a = attrs[OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER];
>      } else {
>          a = attrs[OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL];
>
Flavio Leitner July 2, 2020, 8:26 p.m. UTC | #2
On Fri, Jun 26, 2020 at 12:51:10PM +0200, Ilya Maximets wrote:
> If dp-packet contains l2 padding or cutlen was applied to it, size will
> be larger than the actual size of a payload and action will work
> incorrectly.
> 
> Ex. Padding could be added during miniflow_extract() if detected.
> 
> CC: Numan Siddique <nusiddiq@redhat.com>
> Fixes: 5b34f8fc3b38 ("Add a new OVS action check_pkt_larger")
> Reported-by: Miroslav Kubiczek <miroslav.kubiczek@adaptivemobile.com>
> Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2020-May/050157.html
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
> ---

Acked-by: Flavio Leitner <fbl@sysclose.org>
diff mbox series

Patch

diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 6018e378a..6eeda2a61 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -761,10 +761,11 @@  odp_execute_check_pkt_len(void *dp, struct dp_packet *packet, bool steal,
 
     const struct nlattr *a;
     struct dp_packet_batch pb;
+    uint32_t size = dp_packet_get_send_len(packet)
+                    - dp_packet_l2_pad_size(packet);
 
     a = attrs[OVS_CHECK_PKT_LEN_ATTR_PKT_LEN];
-    bool is_greater = dp_packet_size(packet) > nl_attr_get_u16(a);
-    if (is_greater) {
+    if (size > nl_attr_get_u16(a)) {
         a = attrs[OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER];
     } else {
         a = attrs[OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL];