From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 325D4C56201 for ; Wed, 28 Oct 2020 23:21:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAD6220791 for ; Wed, 28 Oct 2020 23:21:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="nWFx2UzN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390155AbgJ1XVJ (ORCPT ); Wed, 28 Oct 2020 19:21:09 -0400 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:1454 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390127AbgJ1XVE (ORCPT ); Wed, 28 Oct 2020 19:21:04 -0400 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Wed, 28 Oct 2020 09:57:54 -0700 Received: from [172.27.0.18] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 28 Oct 2020 16:58:11 +0000 Subject: Re: [PATCH v3] nvme-rdma: handle nvme completion data length To: zhenwei pi , , , , CC: , , References: <20201025115124.1430678-1-pizhenwei@bytedance.com> From: Max Gurtovoy Message-ID: <86fa6106-b969-4bb9-95ee-c1101a61ff03@nvidia.com> Date: Wed, 28 Oct 2020 18:58:08 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20201025115124.1430678-1-pizhenwei@bytedance.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1603904274; bh=cR2ZEkkVb/BlRCyOFgIUSEJCwL4kH+CyituXrsasLIE=; h=Subject:To:CC:References:From:Message-ID:Date:User-Agent: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding: Content-Language:X-Originating-IP:X-ClientProxiedBy; b=nWFx2UzNPDiROjdiBCoKaqsoXBmlMDFGaKIaTCPEvZLLmwBjn6a5pVAnzknVcWEBL Zp9/RSvDbckthXtzooyEMojhijAhKPEOtke6799ARYxLPNoBTJuyal0yJyMd3gb5rh dirt/6rnxeYZb1/wxBYsxH8MD/O/5f1ANoLm3NqDLrtaoOy8AlqSUa3/p0i8SSqd5S D+BsZTStZC7a1WXAMtLgF0VAILvWTxNSpNguPgDY0qrnjaKUPbxOnyRNYxKtjO8mqq PXrV0ShzH5EMS4x8hrVwa4ValWS2DFZhNql8gaq4CVNXEnbyfPPUkK1gu7aOPCA4Zh mynLNW5LnWEMw== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/25/2020 1:51 PM, zhenwei pi wrote: > Hit a kernel warning: > refcount_t: underflow; use-after-free. > WARNING: CPU: 0 PID: 0 at lib/refcount.c:28 > > RIP: 0010:refcount_warn_saturate+0xd9/0xe0 > Call Trace: > > nvme_rdma_recv_done+0xf3/0x280 [nvme_rdma] > __ib_process_cq+0x76/0x150 [ib_core] > ... > > The reason is that a zero bytes message received from target, and the > host side continues to process without length checking, then the > previous CQE is processed twice. > > Do sanity check on received data length, try to recovery for corrupted > CQE case. > > Because zero bytes message in not defined in spec, using zero bytes > message to detect dead connections on transport layer is not > standard, currently still treat it as illegal. > > Thanks to Chao Leng & Sagi for suggestions. > > Signed-off-by: zhenwei pi > --- > drivers/nvme/host/rdma.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > Seems strange that the targets sends zero byte packets. Can you specify which target is this and the scenario ?