Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp777703rdh; Thu, 26 Oct 2023 16:00:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEStahvcofsN9dToobOiXVSEaxamNhnZ4PgW3w8V7PezUm7UBfx5dec8SgXsEZCfiEm5LLn X-Received: by 2002:a81:b722:0:b0:5a7:e726:13f7 with SMTP id v34-20020a81b722000000b005a7e72613f7mr1037696ywh.8.1698361218525; Thu, 26 Oct 2023 16:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698361218; cv=none; d=google.com; s=arc-20160816; b=CZ7DuAW/WzT4u60QTtbFveBaGtMVxWvi+lv8keOFkwS7U6EPDRTWnRm5ZGmT/mOSXB Tj/Cdpcs1yAkgJGfaxafL9mHrhPPsToyPLAh3jGiMWrxzqdWKhT+XUkeqxgRAhQNBxdE PNu/D5+SGj1Tppdzn1HQdUQypIfb4ovxy+JcEPNuzRNSO7VuxgPC/echtUZ/NZeIAiUl u1HDrAQO+q3HJtR9qRyQtJDCSjTjRLKVndG2Y4lwX4sNBpChRx4hJGEKytNkeYskg9i8 Vn44nhBYt/oVH5rWOibEdzYtErFBTWM/jQ585C/TzoT4Cj/OBvxgq5mbZ7GfaxK537aW PjjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wHThOiOK2ZHKZ5dxOKEfP3CHmptryy9ZbtmR7SRvI/0=; fh=vEdhs3U55JQ7F7POVpHwWvES3ESZsCWCYnoBZaHvWlo=; b=t7IZvL71Mdj09uf/yvpYjLFFJfqFI3ZHC284Kue5G6D+vLgO20Z/R4AgJ/wbeuNvCP dVO2gGavdBe2jSwBYlGHxrgKa3yHc9olwdNHbggxKju0X7zft9EBnqGrq1DxcdxT3cdv BKoyQvdR0vdaCr0L0l4NQykg3YD2dZf2fynZ1MGKOQtjhfVis96xYEL78EqpuD31LCaN i7QXrQ4JeBPVryvHEcYShNtYQ3RJuXkJrTGeJumlwn9mPHymd9XQJuTQVkj8iz6tbZxu TDf06TUdeKgdF2v96ACTcaf1zktxAGK+VMEPofoJlVgJ62T9BQqqlsG5kZQiAf5eZuHX MZ5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n878+hnC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x81-20020a817c54000000b0059f4ea770c5si495266ywc.268.2023.10.26.16.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 16:00:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n878+hnC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A1C6A807C742; Thu, 26 Oct 2023 16:00:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234816AbjJZXAF (ORCPT + 99 others); Thu, 26 Oct 2023 19:00:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231129AbjJZXAD (ORCPT ); Thu, 26 Oct 2023 19:00:03 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDC891BE; Thu, 26 Oct 2023 16:00:01 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 437DCC433C7; Thu, 26 Oct 2023 23:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698361201; bh=Tprv2HEJ1ZQn4DR9o0zCe+RP/h3cr0NDKFi8qh7NFT0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n878+hnCauWva1JmpNtSNeJSFptlrbAncruHiZeq6+iA/qqnOtPfpN8Zo68DICvjY iVYB1fg0c8D3R7LhJlNigqXI9SuklS3DJe9XTug7GpXAO8QdFT8dXdNIf0fP+pEW8d R0rmEkZC6Zom5Wwnj3VCz1TCOb1chfI1qr/TwgNlu0OGm7Kr9plL+ajixRG2BuVpWq 4iN/adr/NLCU5WGYo+n1jy5RZPknZDxi4aYGs/We/sheVLyNamBTE338mowP3CPI// XgnYi1jynEhBvLoULHVFq2XNCL4gEG8jiKvTCGA3/UiqU2qEXTe9W5B6T/C4nbCNWV qHQx5denoyBqg== Date: Thu, 26 Oct 2023 16:00:00 -0700 From: Saeed Mahameed To: Dust Li Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Cruz Zhao , Tianchen Ding Subject: Re: [PATCH net] net/mlx5e: fix double free of encap_header Message-ID: References: <20231025032712.79026-1-dust.li@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20231025032712.79026-1-dust.li@linux.alibaba.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 26 Oct 2023 16:00:14 -0700 (PDT) On 25 Oct 11:27, Dust Li wrote: >When mlx5_packet_reformat_alloc() fails, the encap_header allocated in >mlx5e_tc_tun_create_header_ipv4{6} will be released within it. However, >e->encap_header is already set to the previously freed encap_header >before mlx5_packet_reformat_alloc(). As a result, the later >mlx5e_encap_put() will free e->encap_header again, causing a double free >issue. > >mlx5e_encap_put() > --> mlx5e_encap_dealloc() > --> kfree(e->encap_header) > >This happens when cmd: MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT fail. > >This patch fix it by not setting e->encap_header until >mlx5_packet_reformat_alloc() success. > >Fixes: d589e785baf5e("net/mlx5e: Allow concurrent creation of encap entries") >Reported-by: Cruz Zhao >Reported-by: Tianchen Ding >Signed-off-by: Dust Li Applied to net-mlx5