From owner-svn-src-all@freebsd.org Tue Mar 14 22:09:19 2017 Return-Path: Delivered-To: svn-src-all@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 2C920D0D2EF; Tue, 14 Mar 2017 22:09:19 +0000 (UTC) (envelope-from ermal.luci@gmail.com) Received: from mail-it0-x22b.google.com (mail-it0-x22b.google.com [IPv6:2607:f8b0:4001:c0b::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E8B9C1873; Tue, 14 Mar 2017 22:09:18 +0000 (UTC) (envelope-from ermal.luci@gmail.com) Received: by mail-it0-x22b.google.com with SMTP id m27so55969166iti.0; Tue, 14 Mar 2017 15:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=6Lbn79Gu5klDLCppl2HDpVWECdh3uhHeVoAAEeQyy5Q=; b=L/j31fUtz6ntguvU2mLeawzFrACHv70E0HqwEK9ySvV8XFEfbEe6NRplYFFHRjEvy1 E+yDJ6aTecFfeCz/bInKuct5hXDChmDjISq+PBkjGAswL1mdKq09j4qgbH+2xzQNEtEP aI+FSFGM+l4TvOurDvFwQNQseFJHP14gKUMlnZKP/itV5edY3ATCCWt6a5XrivQHpvOq QNjYXbrCx3sDfHitPts4v72mzogizLfPTpIKvLql0N0uvDNUEdXYMOEa+6XelcmoLQCs tg6+f5ynTO0PaBaxVw7vexLEkuZ3oE7Keu5Z2IR0ZnFqWKEpzn9es1XGMg1EWGUDjrqI /8Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=6Lbn79Gu5klDLCppl2HDpVWECdh3uhHeVoAAEeQyy5Q=; b=aA2MP66sU3ybin7f4kUGMGIYT75M8MbbwQefKd88V29X3kw8xaVbtyPIzguMs3lN3P +rSrgxJYxDHhP+zgbulCdphaTastOTCH0Y9AWUaflnq6x3PZAJkB/Ku6gQyJgDSULjJY I6td2pxhcX6nhU2+zQ1ux5XyuGwRKWmLm4JPfivsnTC/svh7owkDPXfrOVCCGrk9pzHE 60RCz3uJxeALnerRReynJjQ6k1Y2BJ+znjlfmfK3CKts+rBr2xFARrveeo6wJrYKveV1 8Ai3vfehzd4mi8Z2cJr8SKYOpsCRVWZMDWa704ln9v/21I1rFji9z0XaEx553miuG9jq xfOw== X-Gm-Message-State: AFeK/H3MzUpq9RLZhhaDLHxzoGjn2xTTgEobHR0q6UYpxOdo/CXjKVb7ZNsJF7FWk9MAPuRk/oAawfqfvrUMVQ== X-Received: by 10.36.153.197 with SMTP id a188mr18757487ite.5.1489529358143; Tue, 14 Mar 2017 15:09:18 -0700 (PDT) MIME-Version: 1.0 Sender: ermal.luci@gmail.com Received: by 10.107.149.135 with HTTP; Tue, 14 Mar 2017 15:09:17 -0700 (PDT) In-Reply-To: <20170314215706.GB1072@FreeBSD.org> References: <201703120542.v2C5gvM4075391@repo.freebsd.org> <20170314215706.GB1072@FreeBSD.org> From: =?UTF-8?Q?Ermal_Lu=C3=A7i?= Date: Tue, 14 Mar 2017 15:09:17 -0700 X-Google-Sender-Auth: lGZM-2-wlZymMIpbxHPnNA4lSO4 Message-ID: Subject: Re: svn commit: r315136 - head/sys/netpfil/pf To: Gleb Smirnoff Cc: Kristof Provost , src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Mar 2017 22:09:19 -0000 On Tue, Mar 14, 2017 at 2:57 PM, Gleb Smirnoff wrote: > Kristof, > > On Sun, Mar 12, 2017 at 05:42:57AM +0000, Kristof Provost wrote: > K> Log: > K> pf: Fix incorrect rw_sleep() in pf_unload() > K> > K> When we unload we don't hold the pf_rules_lock, so we cannot call > rw_sleep() > K> with it, because it would release a lock we do not hold. There's no > need for the > K> lock either, so we can just tsleep(). > K> > K> While here also make the same change in pf_purge_thread(), because it > explicitly > K> takes the lock before rw_sleep() and then immediately releases it > afterwards. > > The correct change would to be grab lock in pf_unload(), exactly as > pf_purge_thread() > does. With your change you introduces a possible infinite sleep due to > race, since > there is no timeout and no lock. > > No... Actually both cases should PF_RULES_WLOCK(), and read/write the > pf_end_threads > variable under this lock. And use rw_sleep. > I already provided the same concerns privately and solutions to it. > > K> Modified: > K> head/sys/netpfil/pf/pf.c > K> head/sys/netpfil/pf/pf_ioctl.c > K> > K> Modified: head/sys/netpfil/pf/pf.c > K> ============================================================ > ================== > K> --- head/sys/netpfil/pf/pf.c Sun Mar 12 05:36:31 2017 (r315135) > K> +++ head/sys/netpfil/pf/pf.c Sun Mar 12 05:42:57 2017 (r315136) > K> @@ -1429,9 +1429,7 @@ pf_purge_thread(void *unused __unused) > K> u_int idx = 0; > K> > K> for (;;) { > K> - PF_RULES_RLOCK(); > K> - rw_sleep(pf_purge_thread, &pf_rules_lock, 0, "pftm", hz / > 10); > K> - PF_RULES_RUNLOCK(); > K> + tsleep(pf_purge_thread, 0, "pftm", hz / 10); > K> > K> VNET_LIST_RLOCK(); > K> VNET_FOREACH(vnet_iter) { > K> > K> Modified: head/sys/netpfil/pf/pf_ioctl.c > K> ============================================================ > ================== > K> --- head/sys/netpfil/pf/pf_ioctl.c Sun Mar 12 05:36:31 2017 > (r315135) > K> +++ head/sys/netpfil/pf/pf_ioctl.c Sun Mar 12 05:42:57 2017 > (r315136) > K> @@ -3791,7 +3791,7 @@ pf_unload(void) > K> pf_end_threads = 1; > K> while (pf_end_threads < 2) { > K> wakeup_one(pf_purge_thread); > K> - rw_sleep(pf_purge_thread, &pf_rules_lock, 0, "pftmo", 0); > K> + tsleep(pf_purge_thread, 0, "pftmo", 0); > K> } > K> > K> if (pf_dev != NULL) > K> _______________________________________________ > K> svn-src-all@freebsd.org mailing list > K> https://lists.freebsd.org/mailman/listinfo/svn-src-all > K> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" > > -- > Totus tuus, Glebius. > > -- > Ermal >