From owner-freebsd-net@freebsd.org Fri Dec 4 19:32:25 2015 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 18C3AA411A9; Fri, 4 Dec 2015 19:32:25 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9895C10FC; Fri, 4 Dec 2015 19:32:23 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id B33661FE023; Fri, 4 Dec 2015 20:32:19 +0100 (CET) Subject: Re: panic in arptimer in r289937 To: "Alexander V. Chernikov" , Adrian Chadd References: <2739461446298483@web2h.yandex.ru> <1733241446303675@web19h.yandex.ru> Cc: FreeBSD Net , freebsd-current , Randall Stewart From: Hans Petter Selasky Message-ID: <5661EAAF.1010906@selasky.org> Date: Fri, 4 Dec 2015 20:34:07 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1733241446303675@web19h.yandex.ru> Content-Type: multipart/mixed; boundary="------------010400080206050505080202" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Dec 2015 19:32:25 -0000 This is a multi-part message in MIME format. --------------010400080206050505080202 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi Adrian, On 10/31/15 16:01, Alexander V. Chernikov wrote: > > > 31.10.2015, 16:46, "Adrian Chadd" : >> On 31 October 2015 at 09:34, Alexander V. Chernikov >> wrote: >>> 31.10.2015, 05:32, "Adrian Chadd" : >>>> Hiya, >>>> >>>> Here's a panic from arptimer: >>> Hi Adrian, >>> >>> As far as I see, line 205 in if_ether.c is IF_AFDATA_LOCK(ifp) which happens after LLE_WUNLOCK(). >>> So, it looks like (pre-cached) ifp had been freed before locking ifdata. >>> Do you have any more details on that? (e.g. was some interface detached at that moment, is it reproducible, etc..) >>> >>> From a quick glance, potential use-after-free has been possible for quite a long time, but I wonder why it hasn't been observed before. >>> Probably lltable_free() changes might have triggered that. >>> >>> I'll take a deeper look on that and reply. >> Observed on an idle box with projects/hps_head too: > panic: bogus refcnt 0 on lle 0xfffff8016508ca00 > cpuid = 7 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe03e4e8c7e0 > vpanic() at vpanic+0x182/frame 0xfffffe03e4e8c860 > kassert_panic() at kassert_panic+0x126/frame 0xfffffe03e4e8c8d0 > llentry_free() at llentry_free+0x136/frame 0xfffffe03e4e8c900 > arptimer() at arptimer+0x20e/frame 0xfffffe03e4e8c950 > softclock_call_cc() at softclock_call_cc+0x170/frame 0xfffffe03e4e8c9c0 > softclock() at softclock+0x47/frame 0xfffffe03e4e8c9e0 > intr_event_execute_handlers() at intr_event_execute_handlers+0x96/frame 0xfffffe03e4e8ca20 > ithread_loop() at ithread_loop+0xa6/frame 0xfffffe03e4e8ca70 > fork_exit() at fork_exit+0x84/frame 0xfffffe03e4e8cab0 > fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe03e4e8cab0 > --- trap 0, rip = 0, rsp = 0, rbp = 0 --- Looks like callout_reset() must be examined too, and was missed by: https://svnweb.freebsd.org/changeset/base/290805 Can you try the attached patch? Randall: Can you fix this ASAP? --HPS --------------010400080206050505080202 Content-Type: text/x-patch; name="callout_reset_arptimer.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="callout_reset_arptimer.diff" diff --git a/sys/dev/oce/oce_if.c b/sys/dev/oce/oce_if.c index 826cd3c..1cca876 100644 --- a/sys/dev/oce/oce_if.c +++ b/sys/dev/oce/oce_if.c @@ -343,7 +343,7 @@ oce_attach(device_t dev) callout_init(&sc->timer, 1); rc = callout_reset(&sc->timer, 2 * hz, oce_local_timer, sc); - if (rc) + if (rc > 0) goto stats_free; return 0; diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index dfba0b2..0aec1c4 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -420,7 +420,7 @@ arpresolve_full(struct ifnet *ifp, int is_gw, int create, struct mbuf *m, la->la_expire = time_uptime; canceled = callout_reset(&la->lle_timer, hz * V_arpt_down, arptimer, la); - if (canceled) + if (canceled > 0) LLE_REMREF(la); la->la_asked++; LLE_WUNLOCK(la); @@ -1084,7 +1084,7 @@ arp_mark_lle_reachable(struct llentry *la) la->la_expire = time_uptime + V_arpt_keep; canceled = callout_reset(&la->lle_timer, hz * V_arpt_keep, arptimer, la); - if (canceled) + if (canceled > 0) LLE_REMREF(la); } la->la_asked = 0; --------------010400080206050505080202--