From f1b2f01b146870c734f27799e365d166370cdafe Mon Sep 17 00:00:00 2001 From: ozaki-r Date: Fri, 10 Feb 2017 13:44:47 +0000 Subject: [PATCH] Fix locking against myself in ifa_ifwithroute_psref It happened on the path: rtrequest1 => rt_getifa => ifa_ifwithroute_psref. Reported by ryo@ --- sys/net/route.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index 1cf17b8b5cfd..dacca947e380 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.188 2017/01/19 06:58:55 ozaki-r Exp $ */ +/* $NetBSD: route.c,v 1.189 2017/02/10 13:44:47 ozaki-r Exp $ */ /*- * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.188 2017/01/19 06:58:55 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.189 2017/02/10 13:44:47 ozaki-r Exp $"); #include #ifdef RTFLUSH_DEBUG @@ -1012,7 +1012,11 @@ ifa_ifwithroute_psref(int flags, const struct sockaddr *dst, int s; struct rtentry *rt; - rt = rtalloc1(dst, 0); + /* XXX we cannot call rtalloc1 if holding the rt lock */ + if (RT_LOCKED()) + rt = rtalloc1_locked(dst, 0, true); + else + rt = rtalloc1(dst, 0); if (rt == NULL) return NULL; /*