Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp4403061pxb; Wed, 20 Apr 2022 02:24:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe4LACfsUzLP4OhHPXTp1RTWBafs5Pjgr84Ed5cft05Opdk1jvgaki79ib+vccZcaiHj4U X-Received: by 2002:a05:6402:3283:b0:423:e141:f3df with SMTP id f3-20020a056402328300b00423e141f3dfmr16358614eda.154.1650446688897; Wed, 20 Apr 2022 02:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650446688; cv=none; d=google.com; s=arc-20160816; b=Yu+u2xyyjUWqbD1JC9xyFJidAnUYl+diurjsklykSAsj87c84emG6K6nJGnhjiHMZR ce+zAVMYKBNavhGVnnXtriSGIEztloeIsS6hQTlr+QxHCBP3gIHaAfXoq+agzPt1hp5M YUgqtF1tmqCxKAlMgExzgY2xKG+qScBTu6ebjGduQx94sjHPEqAW/KVhZWMDsbq7UrY1 bPTyLxy/JOs13CNeFC4VjvMcrprACjqajcNsgYaLjgIONq0j689krTTVZTBLGctQZX3N BD4Pf1K9Xbx8cME/5i86xCF1oZA3OHXQ9daYZV3UTIB66Apv2IwqvX0FrF1ZlMKsGm5l eCFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=b5rwAcODa+eRgsnTMmXsd0Fj6cNp7p0H/31BsiEvojA=; b=ba+1/Re/KI2x1hEgCrAxdTwY/or0Lhuop+3g+fyRUfxYlfWVqZIzSPngEtR3Rx45Gh 4O4wg7a6R6ANvyg02njklIcXdZJAypssHNW1fNquAud3EQdadxDcH1A9xfJxTWmersKI JIfwLWVa7W9l3jzPFMbrbu94W2Pe0NeCcIY1iUV7p4p1nbBmTS0HHEHDeYgFhGTxvU7e qbV4q0nAijCl2JmdNJOAtpIu3mDTWfCBusdOvZ87BwyOoMggOxvc/bPd6LPNVzDx96Ib xzZFhoP3QFsyu08KZIELT74IAIjb6puQEcpBJYSa5ENGMstL/b0W9z2pHa1P043D9KZa ojIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GBWCjftA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a17090649c600b006e8a0ae2285si1244966ejv.472.2022.04.20.02.24.23; Wed, 20 Apr 2022 02:24:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GBWCjftA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231566AbiDRMgo (ORCPT + 99 others); Mon, 18 Apr 2022 08:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238817AbiDRM0f (ORCPT ); Mon, 18 Apr 2022 08:26:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26A7B12759; Mon, 18 Apr 2022 05:20:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C6C56B80ED6; Mon, 18 Apr 2022 12:20:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36FA3C385A7; Mon, 18 Apr 2022 12:20:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284443; bh=vhKExvIQrbJBdlaP1JzvwlQFvp3uGz/rl9Ht0Bu1+qU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GBWCjftAgM/0uiyGo3dIC6cTPIYKFYnRAZNiX9oh2TqbFYetjUOi70jFc7P1HIsVn /OuAvD4bqiSBs6Ww7GmV0y43hfu1Y3YB13OmBTBRh6pQFj/dT8BT/m8GkEdzj29AVn ftYoobwW0iwvHqRl7CVJkS7owLqw7v/kFX1iMPG0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Willi , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 117/219] macvlan: Fix leaking skb in source mode with nodst option Date: Mon, 18 Apr 2022 14:11:26 +0200 Message-Id: <20220418121210.174324412@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Willi [ Upstream commit e16b859872b87650bb55b12cca5a5fcdc49c1442 ] The MACVLAN receive handler clones skbs to all matching source MACVLAN interfaces, before it passes the packet along to match on destination based MACVLANs. When using the MACVLAN nodst mode, passing the packet to destination based MACVLANs is omitted and the handler returns with RX_HANDLER_CONSUMED. However, the passed skb is not freed, leaking for any packet processed with the nodst option. Properly free the skb when consuming packets to fix that leak. Fixes: 427f0c8c194b ("macvlan: Add nodst option to macvlan type source") Signed-off-by: Martin Willi Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/macvlan.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 6ef5f77be4d0..c83664b28d89 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -460,8 +460,10 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb) return RX_HANDLER_CONSUMED; *pskb = skb; eth = eth_hdr(skb); - if (macvlan_forward_source(skb, port, eth->h_source)) + if (macvlan_forward_source(skb, port, eth->h_source)) { + kfree_skb(skb); return RX_HANDLER_CONSUMED; + } src = macvlan_hash_lookup(port, eth->h_source); if (src && src->mode != MACVLAN_MODE_VEPA && src->mode != MACVLAN_MODE_BRIDGE) { @@ -480,8 +482,10 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb) return RX_HANDLER_PASS; } - if (macvlan_forward_source(skb, port, eth->h_source)) + if (macvlan_forward_source(skb, port, eth->h_source)) { + kfree_skb(skb); return RX_HANDLER_CONSUMED; + } if (macvlan_passthru(port)) vlan = list_first_or_null_rcu(&port->vlans, struct macvlan_dev, list); -- 2.35.1