From owner-svn-src-all@freebsd.org Sun Jan 20 14:31:17 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8D4591491BCA; Sun, 20 Jan 2019 14:31:17 +0000 (UTC) (envelope-from andriyvos@gmail.com) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 82F5369DA2; Sun, 20 Jan 2019 14:31:16 +0000 (UTC) (envelope-from andriyvos@gmail.com) Received: by mail-lj1-f170.google.com with SMTP id t18-v6so15377540ljd.4; Sun, 20 Jan 2019 06:31:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=V7NcKOyLf/SMcZ/6q4WBZC1D9+B+t4TnJ/fF4/heQmQ=; b=HujSzQ7zZXHivKXlXutuHOcUUZQnHYvEtu22SkQnLq5fnseLOSxh6RWIwNySAotmnO 9VUGMI8rdJ0b+kzFBmhqwpiz3+SurFFfZe9dQ/+iZYnfwCUeS4hjtBunAJgdRRGqNdhR ST4vCNdf0bKc+gYs53ilEr4mzOYi5wx/eLxpHwtx2G/sYzyckEz6pW9SA4aRXZV1o0u3 OTgotC0/2fKjWwm2kMjUAQ/mfnQ5byb96KRwXZnpb1B3lm2EcullLj5eVLZylpPwXkgO NQyaYi/AYTvpl+aLKawft9www5FwlZZUfS51+UBxUXwzIaOH6U8kqIklj+drYF96RmNT 2PPw== X-Gm-Message-State: AJcUukcfbdxXAH25x4/BcSjIZ5qr06rit5SBLaPuZNv7va7TTGn+V2l0 NnrT9g2fKCM+ydODBaEyNADBzdfP X-Google-Smtp-Source: ALg8bN6tw94tz9qCUmc1nmVC8lGdK2Dj1Zya4aMAnz2tNWu6SMnh7cjASZoTcQR+Oe21XfRb/+cflA== X-Received: by 2002:a2e:99d7:: with SMTP id l23-v6mr15359674ljj.165.1547994234377; Sun, 20 Jan 2019 06:23:54 -0800 (PST) Received: from localhost (46-133-20-39.dialup.umc.net.ua. [46.133.20.39]) by smtp.gmail.com with ESMTPSA id j25-v6sm1766388lji.77.2019.01.20.06.23.51 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 20 Jan 2019 06:23:53 -0800 (PST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Bjoern A. Zeeb" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r343213 - in head/sys: net80211 sys References: <201901201339.x0KDdICk003155@repo.freebsd.org> <64B0B511-D3A0-4034-B602-2C3956669D58@FreeBSD.org> Date: Sun, 20 Jan 2019 15:55:08 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable From: "Andriy Voskoboinyk" Message-ID: In-Reply-To: <64B0B511-D3A0-4034-B602-2C3956669D58@FreeBSD.org> User-Agent: Opera Mail/12.15 (FreeBSD) X-Rspamd-Queue-Id: 82F5369DA2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of andriyvos@gmail.com designates 209.85.208.170 as permitted sender) smtp.mailfrom=andriyvos@gmail.com X-Spamd-Result: default: False [-2.99 / 15.00]; ARC_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[freebsd.org]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(-1.13)[ipnet: 209.85.128.0/17(-3.75), asn: 15169(-1.84), country: US(-0.08)]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; NEURAL_HAM_SHORT(-0.34)[-0.344,0]; RCVD_IN_DNSWL_NONE(0.00)[170.208.85.209.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FORGED_SENDER(0.30)[avos@freebsd.org,andriyvos@gmail.com]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; MID_RHS_NOT_FQDN(0.50)[]; FROM_NEQ_ENVFROM(0.00)[avos@freebsd.org,andriyvos@gmail.com] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 20 Jan 2019 14:31:17 -0000 Sun, 20 Jan 2019 16:02:08 +0200 =D0=B1=D1=83=D0=BB=D0=BE =D0=BD=D0=B0=D0= =BF=D0=B8=D1=81=D0=B0=D0=BD=D0=BE Bjoern A. Zeeb = : > On 20 Jan 2019, at 13:39, Andriy Voskoboinyk wrote: > >> Author: avos >> Date: Sun Jan 20 13:39:18 2019 >> New Revision: 343213 >> URL: https://svnweb.freebsd.org/changeset/base/343213 >> >> Log: >> net80211: resolve ioctl <-> detach race for ieee80211com structure >> >> Since r287197 ieee80211com is a part of drivers softc; as a result,= >> after detach all pointers to it (iv_ic, ni_ic) are invalid. Most >> possible users (tasks, interrupt handlers) are blocked / removed >> when device is stopped; however, ioctl handlers were not tracked >> and may crash if ieee80211com structure is accessed. >> >> Since ieee80211com pointer access from ieee80211vap structure is no= t >> protected by lock (constant after interface creation) and used in >> many other places just use reference counting for ioctl handlers; >> on detach set 'detached' flag and wait until reference counter goes= = >> to 0. > > So how do any cloned interfaces do this (wifi or non-wifi)? Is this a= = > more general problem or are some wifi drivers just not exactly careful= = > with the order they take things down? > That's for wifi only; ifp (and vap as subpart) is alive until reference counter for ifp is not 0; however, 'com' gets invalid as soon as device detach procedure is finished - and net80211 uses it in various places inside ieee80211_ioctl(). > On another note, why would refcount(9) not be sufficient? I didn=E2=80= =99t = > really like the MC() macros and the hand crafted state machine for a = > refcount when scrolling through. > Just to keep 'detached' flag and reference counter inside one variable (they both need to be atomically accessible). > /bz