Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2469367ybx; Sat, 2 Nov 2019 20:58:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNItK29CL4B5wADM+wovj5LJ/hlOo0C9v1USyK6waUgvsnpe0FCMO8ANDrjegV3Xn0YPix X-Received: by 2002:a17:906:7a47:: with SMTP id i7mr1695348ejo.22.1572753529887; Sat, 02 Nov 2019 20:58:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572753529; cv=none; d=google.com; s=arc-20160816; b=bB0E5hg0KWYZT87xTetg4f/D/lmkNof8koc7DMDy2pvEMKhHbFqjjOMydSUjUjY1/D OhJCrbHnNXDyYd+PuHbSfCF+bLxTQyOk57TRP/gWxFrGuEkGa/CBhjWvXM5KQWDhlc8x YS/mtEoNhi1f1m+5X85/zhUr7MArdq3cfU7paJIUisVgn6hbxaKYWA9TAslz55aTa/qm eYgDRqXUe69MbXUU5QyLEoa+OZBkfUdA/lkZHLQFa3Sfl2P3DButyU6CfKj+TPtVaUFC 2I7xX/NrERehViPt4iCFLt4IO8ejGniYySdPW7AnSgkxMzGIwitnYu9EGw+S5NqgHS3D xzyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-disposition:mime-version:references:in-reply-to:subject:cc :to:from:message-id:date:dkim-signature; bh=wOg1PtFWo6IuY/J6e5WFjVi85apyAhEHv0iLtW+bwFo=; b=KN6DQ14y3slOEghSl8evz1L3aY5lATHpihUj98Fx8Hdh1Ffehu9irbig+Y4fxFsQT1 Z3xPzHhsPyclh5G1e0aJmJNVc3RoceGelKC/39Kfdz2lgItz5Myw/MYIuzA1yGeOgcYg Mj9alZofQG4TRBAKtcBbB9BrJDQvSDTR+X0rSkxChS4SAsHDCRfjvGeVMqTiwoxfdPb1 7axYez+ECQqp8h60gzM9CmO5KXQdPNkghLgP5EK1S0eDwHVCB2fW+SW8eZS4+jPHZ4w6 t61SzrDz81+6IZTdZPSv6gGvqIxagx51cmj1qi3MKYKJ9WeMs3II0zeHGuWsBO4Pboqg I4zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CFqU6jq+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b49si3701005eda.312.2019.11.02.20.57.59; Sat, 02 Nov 2019 20:58:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CFqU6jq+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727499AbfKCDxy (ORCPT + 99 others); Sat, 2 Nov 2019 23:53:54 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:35035 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727389AbfKCDxy (ORCPT ); Sat, 2 Nov 2019 23:53:54 -0400 Received: by mail-qt1-f196.google.com with SMTP id r22so8639118qtt.2; Sat, 02 Nov 2019 20:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:from:to:cc:subject:in-reply-to:references :mime-version:content-disposition:content-transfer-encoding; bh=wOg1PtFWo6IuY/J6e5WFjVi85apyAhEHv0iLtW+bwFo=; b=CFqU6jq+P0UI+cv5IHF/a/9cZZ3yMEv3k1uupJ9pV9YxxCPEcXfx17VZrG9M3Ug+HT QWTj+U2Q0FWEs9wNROaslzazsmJE5AylnnO4gsCEi6bXcUygsgU+PLygddN+QLvDWUsm GeW/9Kslm8141admwFcmpXjbAZABkQScgKqjeBxSsxE8166TAmFvBC6bBZtp4H01TSyl RlPAh1hcRReAsuXsW1MsicZWe+OQut5KuJVxnNujmuZn6qSb3VSiG9kAoccy/5ExVReo uZRXmlTLZlRV0xBuvG/TeudJg/8wUIGOzmbC5PJ+018cYrIBE32fvi1LBy65jLEnz6/T Pclg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:from:to:cc:subject:in-reply-to :references:mime-version:content-disposition :content-transfer-encoding; bh=wOg1PtFWo6IuY/J6e5WFjVi85apyAhEHv0iLtW+bwFo=; b=sr+t8WADk2fU65wYolaDyETkjLw1ckG5bTqfbwHBY8HNIvQo9WIRskEEakS2hxlB+Q 304HnZqtFbFY192I8OOMb541tsEi9DAQ+SzXM25m0gK7nBjjBDXpOT7pIAORkWO7TbkY ZZsa2Vrp3ILoxeNWBureezHXWeQ/djxZ3CYKYrlH/ccc02VcJGvEaF728iGOcrEgUVtk w56wBBMf9NtyvSg7jVm2NZe09xlVVm+84/r+UoR/xnVoa/IpgLaNxB0P0L70RmLanKui l/p58WBl4f6SBUNqkxkHqGuEChoK3VJITG9LD8oIWOe7S9yLcp465O5WoLIyeNtQhsQ8 9/SA== X-Gm-Message-State: APjAAAWEQl5MJ6A7D+igSlI/5LxMN+yK4lMVhAS5Y9PWJNRdCTozeAdL mDnrc8c6CcClImp5YlWOqve+Rj+K X-Received: by 2002:ac8:28e3:: with SMTP id j32mr6623627qtj.212.1572753233114; Sat, 02 Nov 2019 20:53:53 -0700 (PDT) Received: from localhost (modemcable249.105-163-184.mc.videotron.ca. [184.163.105.249]) by smtp.gmail.com with ESMTPSA id e18sm1811995qto.32.2019.11.02.20.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Nov 2019 20:53:52 -0700 (PDT) Date: Sat, 2 Nov 2019 23:53:50 -0400 Message-ID: <20191102235350.GB417753@t480s.localdomain> From: Vivien Didelot To: Florian Fainelli Cc: netdev@vger.kernel.org, rmk+kernel@armlinux.org.uk, hkallweit1@gmail.com, Florian Fainelli , Andrew Lunn , "David S. Miller" , open list Subject: Re: [PATCH net-next] net: dsa: Fix use after free in dsa_switch_remove() In-Reply-To: <20191103031326.26873-1-f.fainelli@gmail.com> References: <20191103031326.26873-1-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2 Nov 2019 20:13:26 -0700, Florian Fainelli wrote: > The order in which the ports are deleted from the list and freed and the > call to dsa_tree_remove_switch() is done is reversed, which leads to an s/dsa_tree_remove_switch/dsa_switch_remove/ > use after free condition. Reverse the two: first tear down the ports and > switch from the fabric, then free the ports associated with that switch > fabric. > > Fixes: 05f294a85235 ("net: dsa: allocate ports on touch") > Signed-off-by: Florian Fainelli Thanks for reporting and fixing this! Reviewed-by: Vivien Didelot