Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1871504pxk; Tue, 1 Sep 2020 09:41:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzenDMJ6taZ1eDr0tfLHK4sAwJ2jw6Up/4C+Rlkp/3Flav9HfD+VCCzSyTUob9OfdzDg7Gc X-Received: by 2002:a17:906:b20c:: with SMTP id p12mr2239709ejz.300.1598978476467; Tue, 01 Sep 2020 09:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598978476; cv=none; d=google.com; s=arc-20160816; b=0eRiv62UE4i2LrTRGLiv0om6S8S3SkZNkRZ3IAEPyFEXy+QISAzdtfN2DbZjyPlyor qXKKqsBdjSjuYLzBSY2XfSoPduUZjN6m0d1VTLDm/uJunmiLzO3WnkT3rdqQRijYQtAw Q+eBVdVLoUSs9xh8i3qIp5qzMPcivsTxptNpIr4864oMvCTYarTM60L/OnlY6j39Lnj8 RMgCvR76auTaufnTpzl7kPNw8RP6eo9Tsywic7YOq5CMnpOF+Ue3sBtqvrunRk8IMlWJ MZZcIYnlVHh53sbGaQsuQHxoxvsAydIJf13nJG3xivJEaDSHQCPWblvwgmZRDfMq4Jq5 t4Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=oMRNEkQ9eB0BarbE4B1d9QZR5bXcWtDlnZRoaa+Qats=; b=V+5E0jS9CXe8ZM7A4zaOAeWCxZz21qu/hjJ9vUjU6fYlavuu2VfEcOFTT9XFpgOpbi bG5E+jKcfp6+KaIOTL8EloUCt+yUwn6uWD4D+Fr9pMYArGexC5VhdPCvE2IeM2GUA40Z CABHiRHYIG9tgw64vis8s2wacq4Jz7LfCshtbhTxRTWnebepGaG0LlUivMWJ07PRvMzI 0Fq68JY2hoe+rWaPFkPJ/2LqZhocwuLmsmxm5IG4vMMx8WcCIymPlRpj5oOLvdrWn6Yg 9xGYxhAc0jhMZx25vlHUEtJi8V5RKn6P6VoLJ+W2MgPROOrgUpgE3cJNe/hXSBXpRahx NK0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="dv/qp1cv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si976594ejt.27.2020.09.01.09.40.52; Tue, 01 Sep 2020 09:41:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="dv/qp1cv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732160AbgIAQji (ORCPT + 99 others); Tue, 1 Sep 2020 12:39:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:60510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730335AbgIAQj3 (ORCPT ); Tue, 1 Sep 2020 12:39:29 -0400 Received: from dhcp-10-100-145-180.wdl.wdc.com (unknown [199.255.45.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 18E3120767; Tue, 1 Sep 2020 16:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598978369; bh=dr8lHwwOag/AEGKr0f2JEzvp5F69En5NKrtfPtmoJsU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dv/qp1cvjo4u1Q6QF8ETb659T0g0+yajEQdEqw8WyWSdiVqK4NIr+lbll5oPtdPCR i0klifYzBqWT+ycUZ7i6+OQZL/05aPSXpEQmenRQrJiL7Gw41mVsH+2iqw3NhpsQ42 oKZ51Cvyt5xpKsGv+DOutjEoRCNUsInwthq5Po1E= Date: Tue, 1 Sep 2020 09:39:27 -0700 From: Keith Busch To: Xianting Tian Cc: axboe@fb.com, hch@lst.de, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [v2] nvme-pci: check req to prevent crash in nvme_handle_cqe() Message-ID: <20200901163927.GC2831246@dhcp-10-100-145-180.wdl.wdc.com> References: <20200831105553.1621-1-tian.xianting@h3c.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200831105553.1621-1-tian.xianting@h3c.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 31, 2020 at 06:55:53PM +0800, Xianting Tian wrote: > As blk_mq_tag_to_rq() may return null, so it should be check whether it is > null before using it to prevent a crash. It may return NULL if the command id exceeds the number of tags. We already have a check for a valid command id value, so something is not adding up here if we're still getting NULL. > req = blk_mq_tag_to_rq(nvme_queue_tagset(nvmeq), cqe->command_id); > + if (unlikely(!req)) { > + dev_warn(nvmeq->dev->ctrl.device, > + "req is null(tag:%d) on queue %d\n", > + cqe->command_id, le16_to_cpu(cqe->sq_id)); > + return; > + }