diff mbox series

[ovs-dev] ofproto-dpif-upcall: Fix null pointer dereference on exit.

Message ID 20171027154023.14307-1-blp@ovn.org
State Accepted
Headers show
Series [ovs-dev] ofproto-dpif-upcall: Fix null pointer dereference on exit. | expand

Commit Message

Ben Pfaff Oct. 27, 2017, 3:40 p.m. UTC
When revalidation occurs at the same time that a bridge is being removed
or ovs-vswitchd is exiting, xlate_lookup_ofproto() races with deletion of
the ofproto.  This caused a null pointer dereference if revalidation lost
the race.  This commit fixes the problem.

Reported-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 ofproto/ofproto-dpif-upcall.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jakub Sitnicki Nov. 2, 2017, 5:53 p.m. UTC | #1
On Fri, 27 Oct 2017 08:40:23 -0700
Ben Pfaff <blp@ovn.org> wrote:

> When revalidation occurs at the same time that a bridge is being removed
> or ovs-vswitchd is exiting, xlate_lookup_ofproto() races with deletion of
> the ofproto.  This caused a null pointer dereference if revalidation lost
> the race.  This commit fixes the problem.
> 
> Reported-by: Jakub Sitnicki <jkbs@redhat.com>
> Signed-off-by: Ben Pfaff <blp@ovn.org>
> ---

Tested-by: Jakub Sitnicki <jkbs@redhat.com>

Thank you for the patch. I'm seeing less than before tests
failing or hanging with it applied of on top of master.

-Jakub
Jakub Sitnicki Nov. 2, 2017, 5:58 p.m. UTC | #2
On Thu, 2 Nov 2017 18:53:02 +0100
Jakub Sitnicki <jkbs@redhat.com> wrote:

> On Fri, 27 Oct 2017 08:40:23 -0700
> Ben Pfaff <blp@ovn.org> wrote:
> 
> > When revalidation occurs at the same time that a bridge is being removed
> > or ovs-vswitchd is exiting, xlate_lookup_ofproto() races with deletion of
> > the ofproto.  This caused a null pointer dereference if revalidation lost
> > the race.  This commit fixes the problem.
> > 
> > Reported-by: Jakub Sitnicki <jkbs@redhat.com>
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> > ---
> 
> Tested-by: Jakub Sitnicki <jkbs@redhat.com>
> 
> Thank you for the patch. I'm seeing less than before tests
> failing or hanging with it applied of on top of master.

Forgot to ask - any chance it could be also applied back to branch-2.7?

Thanks,
Jakub
Ben Pfaff Nov. 2, 2017, 6:13 p.m. UTC | #3
On Thu, Nov 02, 2017 at 06:53:02PM +0100, Jakub Sitnicki wrote:
> On Fri, 27 Oct 2017 08:40:23 -0700
> Ben Pfaff <blp@ovn.org> wrote:
> 
> > When revalidation occurs at the same time that a bridge is being removed
> > or ovs-vswitchd is exiting, xlate_lookup_ofproto() races with deletion of
> > the ofproto.  This caused a null pointer dereference if revalidation lost
> > the race.  This commit fixes the problem.
> > 
> > Reported-by: Jakub Sitnicki <jkbs@redhat.com>
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> > ---
> 
> Tested-by: Jakub Sitnicki <jkbs@redhat.com>
> 
> Thank you for the patch. I'm seeing less than before tests
> failing or hanging with it applied of on top of master.

Thanks.  I applied this to master.
Ben Pfaff Nov. 2, 2017, 6:15 p.m. UTC | #4
On Thu, Nov 02, 2017 at 06:58:39PM +0100, Jakub Sitnicki wrote:
> On Thu, 2 Nov 2017 18:53:02 +0100
> Jakub Sitnicki <jkbs@redhat.com> wrote:
> 
> > On Fri, 27 Oct 2017 08:40:23 -0700
> > Ben Pfaff <blp@ovn.org> wrote:
> > 
> > > When revalidation occurs at the same time that a bridge is being removed
> > > or ovs-vswitchd is exiting, xlate_lookup_ofproto() races with deletion of
> > > the ofproto.  This caused a null pointer dereference if revalidation lost
> > > the race.  This commit fixes the problem.
> > > 
> > > Reported-by: Jakub Sitnicki <jkbs@redhat.com>
> > > Signed-off-by: Ben Pfaff <blp@ovn.org>
> > > ---
> > 
> > Tested-by: Jakub Sitnicki <jkbs@redhat.com>
> > 
> > Thank you for the patch. I'm seeing less than before tests
> > failing or hanging with it applied of on top of master.
> 
> Forgot to ask - any chance it could be also applied back to branch-2.7?

I backported to branch-2.8, but branch-2.7 doesn't have the code that
causes this problem.
Jakub Sitnicki Nov. 3, 2017, 5:06 p.m. UTC | #5
On Thu, 2 Nov 2017 11:15:23 -0700
Ben Pfaff <blp@ovn.org> wrote:

> > Forgot to ask - any chance it could be also applied back to branch-2.7?  
> 
> I backported to branch-2.8, but branch-2.7 doesn't have the code that
> causes this problem.

Thank you. I should have checked before asking. Will remember next time.
diff mbox series

Patch

diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index 4a71bbe258df..e52871da2b81 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -2047,8 +2047,8 @@  revalidate_ukey__(struct udpif *udpif, const struct udpif_key *ukey,
     if (xoutp->slow) {
         struct ofproto_dpif *ofproto;
         ofproto = xlate_lookup_ofproto(udpif->backer, &ctx.flow, NULL);
-        uint32_t smid = ofproto->up.slowpath_meter_id;
-        uint32_t cmid = ofproto->up.controller_meter_id;
+        uint32_t smid = ofproto ? ofproto->up.slowpath_meter_id : UINT32_MAX;
+        uint32_t cmid = ofproto ? ofproto->up.controller_meter_id : UINT32_MAX;
 
         ofpbuf_clear(odp_actions);
         compose_slow_path(udpif, xoutp, &ctx.flow, ctx.flow.in_port.odp_port,