Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp61285rdh; Wed, 22 Nov 2023 18:23:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVZVVliLd/oB1dxcnvG0ugvuPuuGf/6aeeAj9YlAUKzTekTrSJMQni2KzaLRojKiMf1C4d X-Received: by 2002:a17:90b:4c87:b0:285:34da:f564 with SMTP id my7-20020a17090b4c8700b0028534daf564mr4469231pjb.44.1700706215739; Wed, 22 Nov 2023 18:23:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700706215; cv=none; d=google.com; s=arc-20160816; b=kWoVnXNz8qmd51mk5SO4MP0VpY3P5EQSr7yiIx4JNmDoyQSAV2CtzS+xMFBRFfR14q S5C4oY9CWsNDWAwWsmoOJjLYCshumhZ77zpI1M0Nzd8LVUTaioZ3kItVNCGcQTt0Oiri KKvr464spEbNSxfQ0MhGeHku24hIoaE6HrzBnf/uI7p4cm5JzqFtA2KSxDEIaLiBM2CE d0wI/XYytSNaO0nTQXn+UhYGal6kx2rDf+9vJ94bjfBbDYFgmFWnyeCU77Xw8tPE7Zg4 7oL8uHorc/0/5Dms8KaxyMHW1QuYsbVhBieAUaWBIEoT8NOejAx/0DJy9Zviuz9AXYVP 7iMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=UlxvLHjBs0+KVhlcvFETRh+wWbRujxcqONaLwY9ZXkY=; fh=J7SvRbSRR+YwHW5zYcnTqqszr4tZQEZwfKYahr+F5+8=; b=a0uKBM4JPt0MLH/eWuKt9Ac2d1GKQc4UE7c9vRpaxJC/z5O1rbQo8yMm/FF/rKrtUb ZUV5FkRr3rcqopBMwN0AFw6lh59umDV9brqAMkeQ67VhAciV6ovevVvGkXHyWiPqceZ0 sxcGs+W67oP5zDLs4f3+MsiEPJviY2SPV02x5okhsNITy1T0ofaq3gz+otX4t1uYpjzU JC9ydrcTEsstPfo7QuPw+6d7/xTO3NL692tpf8hNbOSWQKY6/mVSzJvQ58j2x3q8qwDu L4PC+iPCDpOMw4QKM+mD2ee/HORMPvovd7P2tlpJY7G4/zLntXF/Yw1X4pr9osqAA0lX NEhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=pOZl2CHy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id n14-20020a17090a4e0e00b0027cde38c731si846525pjh.17.2023.11.22.18.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 18:23:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=pOZl2CHy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 212B683784AD; Wed, 22 Nov 2023 18:23:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343878AbjKWCXQ (ORCPT + 99 others); Wed, 22 Nov 2023 21:23:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbjKWCXP (ORCPT ); Wed, 22 Nov 2023 21:23:15 -0500 Received: from m126.mail.126.com (m126.mail.126.com [220.181.12.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2D52B112; Wed, 22 Nov 2023 18:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:From: Content-Type; bh=UlxvLHjBs0+KVhlcvFETRh+wWbRujxcqONaLwY9ZXkY=; b=pOZl2CHy15CILlb/xweooyqCmAppWfRvdwQNMDPqEadI6gqKwPiZphD9h5UR6u eI88+VXUshcG0fwFS2LtIEMRk3QuVvjpCex3rfvHpKl9lMcuQZJplkkVnrvjs9UA TIlSnT0E6/HxLUbqeGfm2TzAUUtnK9wuMP72snhyFeb9M= Received: from [172.23.69.7] (unknown [121.32.254.149]) by zwqz-smtp-mta-g3-0 (Coremail) with SMTP id _____wD3XznVtl5lJaXiCw--.59075S2; Thu, 23 Nov 2023 10:20:07 +0800 (CST) Message-ID: <3cfe509b-ca24-47a7-931c-fe620c2dab7c@126.com> Date: Thu, 23 Nov 2023 10:20:03 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] net/mlx5e: Fix a race in command alloc flow To: Leon Romanovsky Cc: saeedm@nvidia.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jackm@dev.mellanox.co.il, ogerlitz@mellanox.com, roland@purestorage.com, eli@mellanox.com, dinghui@sangfor.com.cn, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231121115251.588436-1-lishifeng1992@126.com> <20231122120245.GC4760@unreal> From: Shifeng Li In-Reply-To: <20231122120245.GC4760@unreal> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: _____wD3XznVtl5lJaXiCw--.59075S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxGryfAF4xGr45WFy8CFW3KFg_yoW5Cw45pr yxGw47AFn5Krsxtrn7Xw4jq3W8J397Kw15GF1v9r1xWwsaya4kAa4Ikr4jg34UX3yjqa47 JayDKFy8Xr4fX3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jeD73UUUUU= X-Originating-IP: [121.32.254.149] X-CM-SenderInfo: xolvxx5ihqwiqzzsqiyswou0bp/1tbi1xgxr153c3k9gwABsN X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Wed, 22 Nov 2023 18:23:32 -0800 (PST) On 2023/11/22 20:02, Leon Romanovsky wrote: > On Tue, Nov 21, 2023 at 03:52:51AM -0800, Shifeng Li wrote: >> Fix a cmd->ent use after free due to a race on command entry. >> Such race occurs when one of the commands releases its last refcount and >> frees its index and entry while another process running command flush >> flow takes refcount to this command entry. The process which handles >> commands flush may see this command as needed to be flushed if the other >> process allocated a ent->idx but didn't set ent to cmd->ent_arr in >> cmd_work_handler(). Fix it by moving the assignment of cmd->ent_arr into >> the spin lock. >> >> [70013.081955] BUG: KASAN: use-after-free in mlx5_cmd_trigger_completions+0x1e2/0x4c0 [mlx5_core] >> [70013.081967] Write of size 4 at addr ffff88880b1510b4 by task kworker/26:1/1433361 >> [70013.081968] >> [70013.081989] CPU: 26 PID: 1433361 Comm: kworker/26:1 Kdump: loaded Tainted: G OE 4.19.90-25.17.v2101.osc.sfc.6.10.0.0030.ky10.x86_64+debug #1 >> [70013.082001] Hardware name: SANGFOR 65N32-US/ASERVER-G-2605, BIOS SSSS5203 08/19/2020 >> [70013.082028] Workqueue: events aer_isr >> [70013.082053] Call Trace: >> [70013.082067] dump_stack+0x8b/0xbb >> [70013.082086] print_address_description+0x6a/0x270 >> [70013.082102] kasan_report+0x179/0x2c0 >> [70013.082133] ? mlx5_cmd_trigger_completions+0x1e2/0x4c0 [mlx5_core] >> [70013.082173] mlx5_cmd_trigger_completions+0x1e2/0x4c0 [mlx5_core] >> [70013.082213] ? mlx5_cmd_use_polling+0x20/0x20 [mlx5_core] >> [70013.082223] ? kmem_cache_free+0x1ad/0x1e0 >> [70013.082267] mlx5_cmd_flush+0x80/0x180 [mlx5_core] >> [70013.082304] mlx5_enter_error_state+0x106/0x1d0 [mlx5_core] >> [70013.082338] mlx5_try_fast_unload+0x2ea/0x4d0 [mlx5_core] >> [70013.082377] remove_one+0x200/0x2b0 [mlx5_core] >> [70013.082390] ? __pm_runtime_resume+0x58/0x70 >> [70013.082409] pci_device_remove+0xf3/0x280 >> [70013.082426] ? pcibios_free_irq+0x10/0x10 >> [70013.082439] device_release_driver_internal+0x1c3/0x470 >> [70013.082453] pci_stop_bus_device+0x109/0x160 >> [70013.082468] pci_stop_and_remove_bus_device+0xe/0x20 >> [70013.082485] pcie_do_fatal_recovery+0x167/0x550 >> [70013.082493] aer_isr+0x7d2/0x960 >> [70013.082510] ? aer_get_device_error_info+0x420/0x420 >> [70013.082526] ? __schedule+0x821/0x2040 >> [70013.082536] ? strscpy+0x85/0x180 >> [70013.082543] process_one_work+0x65f/0x12d0 >> [70013.082556] worker_thread+0x87/0xb50 >> [70013.082563] ? __kthread_parkme+0x82/0xf0 >> [70013.082569] ? process_one_work+0x12d0/0x12d0 >> [70013.082571] kthread+0x2e9/0x3a0 >> [70013.082579] ? kthread_create_worker_on_cpu+0xc0/0xc0 >> [70013.082592] ret_from_fork+0x1f/0x40 > > I'm curious how did you get this error? I would expect to see some sort > of lock in upper level which prevents it. > Just inject AER unrecoverable error to pci BDF device corresponding to the network card constantly and I get this error. Thanks > Thanks