Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3717430rdh; Tue, 28 Nov 2023 01:41:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcela4FzWk56fDbSj6Q8WzopG7yIcpLPAP9ETPBcx65axm1LdKBOSOaSqKgwnbwU0QJkuU X-Received: by 2002:a17:902:e546:b0:1cf:ff41:51e2 with SMTP id n6-20020a170902e54600b001cfff4151e2mr871713plf.55.1701164513254; Tue, 28 Nov 2023 01:41:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701164513; cv=none; d=google.com; s=arc-20160816; b=iCYb08xB38bVSwEhN4daCs23xEWOSDYtodLzvK5+vc08EG/gXrsj+TB6yv0LX7aPNH A4moeA5PNDf1P/nSpIo+6eWVeV6SKhAgfwj8k7FIxNzcFZ3OLBWefCjDrjdwIB9zfkKf E9RY9eGUD6Bgmm86cahbdq1JMDGL8SHqQLillAmQF6Zcb0igO/R0TpY5W08KORhpEPEp ZvLRr4XpaaOqTwHs4lrFw0ZHQEKNgORHzCL1iNQWAKk01OzbZK35aY5b3D0ydEY3c1U+ rodL+KDygohaphEL3JlHUfSZy4xmBKDoRqKY1YEKCBIk+bxPOe0U7Fy2HeTeToUob0OL Oqnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=lpB0U9qvDi5L/BD+qtz5cfRM0yMIaAZbQwGJPZCR7Ko=; fh=DXeYPwKgGOMyTFwb1Sb5iQks4qs0gXG0mQjmDamqfwI=; b=XixH8VV9vIYBf6paYprdIH8oQ2IxT7B33ZOeyD2HkhZemYw8frACCWe78ZsXXbWJD0 Jo5xkV640gfeKWc3aDFjMwSM+Xxtf+UCb5q/kdtEkBykr0mMl3/TqZO9L1sgc3VLBUQa ittuFWXXcc6hAGnkbnfGoedPXMQca0jRv7L664dThVtH/TCzl594YGcEnbOP/m+mD5Ed cYle1RI7ATu+f81yDRoZ8cuZBo/RZdyiQ/HZSCn+QdpVZietCbjZvDOvvBWqB72VdDYt JhQ7OqE6xY6jvhSCYC/mwmlOVsQmUm77txxqmDJZL6o3JDOA1+rfnO0vpEnZ7H2akybU /2OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m6-20020a170902db8600b001c20db25108si5877250pld.41.2023.11.28.01.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 01:41:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 8F6F780A990F; Tue, 28 Nov 2023 01:41:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231495AbjK1Jll (ORCPT + 99 others); Tue, 28 Nov 2023 04:41:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbjK1Jlk (ORCPT ); Tue, 28 Nov 2023 04:41:40 -0500 Received: from zju.edu.cn (mail.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4E1E0BE; Tue, 28 Nov 2023 01:41:45 -0800 (PST) Received: from localhost.localdomain (unknown [10.190.69.212]) by mail-app2 (Coremail) with SMTP id by_KCgBHGCiytWVldVgiAA--.57544S4; Tue, 28 Nov 2023 17:41:14 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Zhengchao Shao , Simon Horman , Rahul Rameshbabu , Aya Levin , Tariq Toukan , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] net/mlx5e: fix a potential double-free in fs_udp_create_groups Date: Tue, 28 Nov 2023 17:40:53 +0800 Message-Id: <20231128094055.5561-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: by_KCgBHGCiytWVldVgiAA--.57544S4 X-Coremail-Antispam: 1UD129KBjvJXoWrZFyUAFWrZF45tw13ur1fXrb_yoW8Jr43pF 4kCr9FgryfAw18WwsrZFW8Zr1rCa18t3yF93WSv3ySvwn8tF4xJrn5uFW7ZFW2kFW3JF1Y v34xAw1fAF4DA37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9G1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJr0_GcWl84ACjcxK6I8E 87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c 8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JrI_ JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwI xGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAa w2AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l42xK82IY6x8ErcxFaVAv8VW8uw4UJr1UMx C20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAF wI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20x vE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v2 0xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxV W8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VU13ku3UUUUU== X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgsIBmVfIgMaAQAksj X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 28 Nov 2023 01:41:51 -0800 (PST) When kcalloc() for ft->g succeeds but kvzalloc() for in fails, fs_udp_create_groups() will free ft->g. However, its caller fs_udp_create_table() will free ft->g again through calling mlx5e_destroy_flow_table(), which will lead to a double-free. Fix this by setting ft->g to NULL in fs_udp_create_groups(). Fixes: 1c80bd684388 ("net/mlx5e: Introduce Flow Steering UDP API") Signed-off-by: Dinghao Liu --- Changelog: v2: Setting ft->g to NULL instead of removing the kfree(). --- drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c b/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c index be83ad9db82a..e1283531e0b8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c @@ -154,6 +154,7 @@ static int fs_udp_create_groups(struct mlx5e_flow_table *ft, enum fs_udp_type ty in = kvzalloc(inlen, GFP_KERNEL); if (!in || !ft->g) { kfree(ft->g); + ft->g = NULL; kvfree(in); return -ENOMEM; } -- 2.17.1