Article View: linux.kernel.netdev
Article #10902Re: [PATCH v2] team: fix promisc/allmulti leak in team_port_add error path
From: Hangbin Liu
Date: Wed, 04 Nov 2026 09:38
Date: Wed, 04 Nov 2026 09:38
67 lines
10790 bytes
10790 bytes
On Wed, Nov 04, 2026 at 09:52:17AM +0800, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> 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 <lirongqing@baidu.com>
> ---
> Diff with v1:
> 1. Remove the dev_set_promiscuity(port_dev, -1); in if (dev->flags & IFF_ALLMULTI) and move it under here.
> 2. change Fixes tag
>
> drivers/net/team/team_core.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
> index 957cc78..cfb833c 100644
> --- a/drivers/net/team/team_core.c
> +++ b/drivers/net/team/team_core.c
> @@ -1365,11 +1365,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);
> @@ -1397,7 +1394,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.9.4
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID:
<aur86WH_9VMrP9NN@fedora>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356341-linux-kernel-netdev=dewy.ruReferences:
<20261104015217.2222-1-lirongqing@baidu.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356341-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v2] team: fix promisc/allmulti leak in team_port_add error path Date: Wed, 4 Nov 2026 17:38:00 +0800 Organization: Usenet Network Message-ID: <aur86WH_9VMrP9NN@fedora> References: <20261104015217.2222-1-lirongqing@baidu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="3364809"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:vX8cQ1kBGj63JWA1PZfQPJDRtzs= sha256:lj8lShUwjYg1qKGa2rkt4oR/CmTuP6pU5w2P8n9/99U= sha1:hdyP+xK/+/XYFuUKWiQt5yRrcXI= sha256:Nc1J6H1bShiMYbNq1rgYlIyrgFzCGZMshcPOTfk9zns= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id B5CE0112B74; Wed, 4 Nov 2026 12:50:54 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2vrp8zjZ7XRp; Wed, 4 Nov 2026 12:50:51 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-356341-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 3852F112B65; Wed, 4 Nov 2026 12:50:40 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 30B7B272EC; Wed, 4 Nov 2026 09:38:25 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793785104; b=HHp8cgtnBMBLWadjDpjvYLVi8GEc0+K27WTBGVnJATni9VUSffNvcx2lpM6Q7ckMfjW5 uNNh/s7j+uTd9To5KfkbJbfSeeMPT7Pvd1P95b+K0FSiDEY2TtIPznhLcFu17KyxMkSCp sfK++qDVjo8mHnpN7SFV9h/JmkwvxPvEOOtUmm8Ij3AHBGVPSIUth5qYZhGPVMg7U2Zdv 3H9xIlDbXYnbys0ppX2pmm+Gd/trSl579TmeeuZXlajvO/D4q1pPJ5y3Vpta0hxM8T7Xw vMd7Oq7jFsc+KMjGN7l2LdckE6oZmYx5gWEkeCj0hv7KQ1wT8DRWtrpRrLLPzAl3b7g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793785104; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=5oRk43/W3Y6gddSCWn6cma4la8Lxnv8/S1acmO9S1Qo=; b=5hPgPcZKHPTSt2NcrWsVpoXnrisIv0MBsAwmBgIb83Xy189148oIpDG6MOaxkdPfoiIq hQpCY1MLk0eFwR6roGYYxnUSDsFa/UPL32+lGiGIKYqbOoyKcZfnZb4mBRQdRkrnf3Hgd Pg/wlQ7WtMhVnYEeMWJ0eAX5sRIwKDrOE6r49eZYiJfhQDKzqtK6IJLAeeuCJBhslxfDC T5gpwaAFFE+Af5Vkunxbozog3oIg8AlNw03FEvtGjn+NubWI8niMe/JD5Go06T0/U7+jf cXHttp/ZegkMXJHs/6OLXPJuU5+3cfwjSDGmdemP7hLIMEoTU8MwEPfDg9uOq2ucuIg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=e4iWoGak; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4210F606A32C; Wed, 4 Nov 2026 09:38:24 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=e4iWoGak X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.218 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793785098; b=myG2/6S5BHRyuhU7CeGL0rHh/IvVrY/Hq6S2QpkLfjYYygT3tS+xNJhm5Flpy+W4PPrw Q+PZxMFnJXLmnRjRz3Lvs02KdYk2NZIoyB6yN0JbmUKVUh8y6UD0wJHjCQyaqQMXeXi1f z/o7OqCIKfIwT6P1ekIAtLyuoAFHOJB1geZbky3FFMTaqpNaUhAWVPyKJqCigsowqtFIV p97BUPAOyQno4shd06piqtxNWasbTccevYnFXx+m6qOXPmhnxaNzsQtSkdkJiHHI92XPJ f8lhjdCw0BnJtqhetJScI+7re8VGCQG+c91PLknCmF7l3vLMH0iE+eTEkFEKjz1Po1Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793785098; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=5oRk43/W3Y6gddSCWn6cma4la8Lxnv8/S1acmO9S1Qo=; b=MyW9vyqNl/aXTiKIFu32uk/0RczivXcf4Ae7zvmySF6uvGGOOvrcG1BhlpWXcl2v6tjr dhwPZlhJsCGdaCV/DYEvX/UYd3nzOKAYcXfyjSAk6dKL51o1W+9QzD7C7FI+4uWUg/Jba ra9hodYxUH0WJf0eCv8qMrKbvy93AkwnmF3Mb+7e4auDqOHt7kEh4UCjcrW2cwGL7IVLx tPzR8jUEjjDPqg8EkSjM/kx6xr/1GeQQonrrGBcaekNhN7IVp/Tdh8+yzfcN3cBDx/Z21 F6W66y9ehdYK05gAL42BaDrAgqpBNutTKFbBZEU8QRzt71w+v4ZlIb+WMwimmlKlsew== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=e4iWoGak; arc=none smtp.remote-ip=91.218.175.218 X-Received: from mta0.migadu.com (out-218.mta0.migadu.com [91.218.175.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03001606A326 for <netdev@vger.kernel.org>; Wed, 4 Nov 2026 09:38:16 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 03001606A326 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=HPJz/VqRgF2OV0uwCCoFF4MG9ZEWJG9czJUot0f7Ois=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793785094; v=1; x=1794389894; b=e4iWoGakmQ8XChzuurSIdGb5es9rdgR6NbMqiq6Leu8wMokL8T+QBBO3Od6rXbQsqvn6Mr4Z NpOO/OejmZRmffjeb+qVruWqCRLoOa6HrBte/FAA6rAMW731+W9W7+CZF7OZIq+9Zsk0vmFtFVv v29KtGWdpN+W6YbssireMH2c= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta11.migadu.com with ESMTPS id 44bfdfe872025a89; Wed, 04 Nov 2026 09:38:12 +0000 X-Mizu-Trace-ID: 44bfdfe872025a89 X-Migadu-Flow: FLOW_OUT X-Cc: Jiri Pirko <jiri@resnulli.us>, Andrew Lunn <andrew+netdev@lunn.ch>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, "Nikola Z . Ivanov" <zlatistiv@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261104015217.2222-1-lirongqing@baidu.com>