[ovs-dev] netdev-offload-tc: Fix crash if offloading is not configured on outdev.
diff mbox series

Message ID 20200114203017.6472-1-i.maximets@ovn.org
State Accepted
Headers show
Series
  • [ovs-dev] netdev-offload-tc: Fix crash if offloading is not configured on outdev.
Related show

Commit Message

Ilya Maximets Jan. 14, 2020, 8:30 p.m. UTC
If output device is not yet added to netdev-offload, netdev_ports_get()
will not find it leading to NULL pointer dereference inside
netdev_get_inindex().

Fixes: 8f283af89298 ("netdev-tc-offloads: Implement netdev flow put using tc interface")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 lib/netdev-offload-tc.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Ben Pfaff Jan. 14, 2020, 8:48 p.m. UTC | #1
On Tue, Jan 14, 2020 at 09:30:17PM +0100, Ilya Maximets wrote:
> If output device is not yet added to netdev-offload, netdev_ports_get()
> will not find it leading to NULL pointer dereference inside
> netdev_get_inindex().
> 
> Fixes: 8f283af89298 ("netdev-tc-offloads: Implement netdev flow put using tc interface")
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>

Acked-by: Ben Pfaff <blp@ovn.org>
Ilya Maximets Jan. 15, 2020, 5:36 p.m. UTC | #2
On 14.01.2020 21:48, Ben Pfaff wrote:
> On Tue, Jan 14, 2020 at 09:30:17PM +0100, Ilya Maximets wrote:
>> If output device is not yet added to netdev-offload, netdev_ports_get()
>> will not find it leading to NULL pointer dereference inside
>> netdev_get_inindex().
>>
>> Fixes: 8f283af89298 ("netdev-tc-offloads: Implement netdev flow put using tc interface")
>> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
> 
> Acked-by: Ben Pfaff <blp@ovn.org>
> 

Thanks!  Applied to master and backported.

Best regards, Ilya Maximets.

Patch
diff mbox series

diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c
index 7453078d5..4988dadc3 100644
--- a/lib/netdev-offload-tc.c
+++ b/lib/netdev-offload-tc.c
@@ -1634,6 +1634,10 @@  netdev_tc_flow_put(struct netdev *netdev, struct match *match,
             odp_port_t port = nl_attr_get_odp_port(nla);
             struct netdev *outdev = netdev_ports_get(port, info->dpif_class);
 
+            if (!outdev) {
+                VLOG_DBG_RL(&rl, "Can't find netdev for output port %d", port);
+                return ENODEV;
+            }
             action->out.ifindex_out = netdev_get_ifindex(outdev);
             action->out.ingress = is_internal_port(netdev_get_type(outdev));
             action->type = TC_ACT_OUTPUT;