From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387273; b=wOI4T5tUlHrzTFKB8u2e9puhBDWeG/P9XZkRztRaRyhN4hc+AN2i92JtNq8UUoQzCtzr B8icnBW3gbL1d1HStMkWfHcrFF0/QGWcnvDGzEl62zxyl8SJi2u1VQxtf4O1+pzX0iWev C+ToGb2+C+uzTYMmJovK91dmotFxxNhljOE32HEzZuRhAVjO9B1O3QA+Dvwf0l7zTpJ+w wrWUFxz/oFdvLK1xbGr1ck9wnmKfH3V0LF5UBdPMSteXMr4XTjRS9nNaMhEc77OwzjgYB 6te7/SyRecE0d+LZ4JLl9vOvo3SK/r60eFDTw7gPWD4EOnsdIjSjtFLUgKYqKXOuHjQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387273; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Ns+jbhwDC3ojZFUEj8SkX2ltQ/sHjEMrm9Qqw4Zy1z0=; b=hmUluHwT0WojGZvM8FALjIjn9f1OxmzEk8TMA2gOx/kELi0YbLzCj8ZqZF7fLaxdo5kS 9x3edrgWHKqBv6247lWP7p2lEgCFsq0j6aVd12cVOdwgUEdh7kl1z59TvuOTrNsZj5p5E pBwOrghDwNnTRo+pKtas95vTYQEW1kDuanxGIASUlWx8qUS+uL4tONJdqm1W1OIPFc4th rycRsI/jWUVqcXCsoYFPYMh3XdMfO3IQ0UugKNfHIfE6bOrxOndICE0SUkFXZG/zICIkf FrI7og8Inse/H8Q5MWS21kqmvLshk558qyiK3+oQ/8ftOsRCQVeAhwa7yErrgZTp1+w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=D2LK6v3U; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD656606A333; Fri, 4 Dec 2026 12:27:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=D2LK6v3U Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE8331F00897; Fri, 4 Dec 2026 12:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387273; bh=Ns+jbhwDC3ojZFUEj8SkX2ltQ/sHjEMrm9Qqw4Zy1z0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D2LK6v3UVPg/j+ZVIMkRLJw0jeELfLoutoSe9HfijLDXd6EQzkA4jAH/K9wJsAY1q Z3NxdDCubxXKXwqGaG4BTSnaeySjQl8YrA6EIslx1SUV/tjHgUNEl9qF2khWX8tT27 NQPzs7VfCb2S/k5UN7LgafG/hlKMNvZpezrww0vA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Li RongQing , Hangbin Liu , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 0175/1059] team: fix promisc/allmulti leak in team_port_add error path Date: Fri, 4 Dec 2026 18:55:06 +0900 Message-ID: <20261204100648.788601382@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Li RongQing [ Upstream commit ff618cb00a645f1e3f89068c5fbda3f3a7f4ae63 ] team_port_add() increments the port's promiscuity and allmulti counts before calling team_dev_type_check_change(). If the latter fails, the error path does not undo these increments, leaving the port in promiscuous and allmulti mode even though it was not successfully added to the team. Undo the promiscuity increment under err_set_slave_allmulti and the allmulti increment under err_set_dev_type, so each error label only reverts what was successfully applied, matching the cleanup performed by team_port_del(). With the promiscuity rollback now living under err_set_slave_allmulti, the inline dev_set_promiscuity(port_dev, -1) in the dev_set_allmulti() failure branch becomes redundant: that branch already jumps to err_set_slave_allmulti, which undoes the promiscuity increment. Drop the inline call to avoid doing it twice. Found by source code audit. Fixes: 0ae9cfc454ea ("team: Move team device type change at the end of team_port_add") Signed-off-by: Li RongQing Reviewed-by: Hangbin Liu Link: https://patch.msgid.link/20261104015217.2222-1-lirongqing@baidu.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/team/team.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 27067c38962c9..f96b1d581716a 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -1309,11 +1309,8 @@ static int team_port_add(struct team *team, struct net_device *port_dev, /* set allmulti level to new slave */ if (dev->flags & IFF_ALLMULTI) { err = dev_set_allmulti(port_dev, 1); - if (err) { - if (dev->flags & IFF_PROMISC) - dev_set_promiscuity(port_dev, -1); + if (err) goto err_set_slave_allmulti; - } } err = team_dev_type_check_change(dev, port_dev); @@ -1339,7 +1336,11 @@ static int team_port_add(struct team *team, struct net_device *port_dev, return 0; err_set_dev_type: + if (dev->flags & IFF_ALLMULTI) + dev_set_allmulti(port_dev, -1); err_set_slave_allmulti: + if (dev->flags & IFF_PROMISC) + dev_set_promiscuity(port_dev, -1); err_set_slave_promisc: __team_option_inst_del_port(team, port); -- 2.53.0