Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2182854iof; Tue, 7 Jun 2022 22:26:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyK+XjMgba97Ztr6PxRTl4EUs7nlzgRQ9J/otAH3DXiGlNLwJP5XTmOQvTGUopvUm9pft5L X-Received: by 2002:a63:8bc9:0:b0:3fc:b9ca:4516 with SMTP id j192-20020a638bc9000000b003fcb9ca4516mr28355924pge.224.1654666014922; Tue, 07 Jun 2022 22:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666014; cv=none; d=google.com; s=arc-20160816; b=SY4mJwUBI8wRmM436vEFcU1H2mwShIj1GSosP7BtFSFPy3MFF6M6aGd3Rd/QVrSg55 FE0E3vyaubK+GOOEJmRxINUOlJcgfWfRw8NCAOefOCn6vAADQlf3TG+e0WhPJGuJEIZa wHuBqWmmaZOYbgXJG7M+eoAEO/Uq8jwIv8S6iRpFlUuEOPKyooLby0VqRRj1V5YbYDCN CEE9IRaDxg0MHlISGdDMAq29htLKeyFp/actO5Mr99N+u30BBWRkeiowiKGUAsmp8+XI LSZHF22cBYt88Z++t9T6YRlAvIxdWXczbjzd+PVlkjQnCZuUtthfcjgw0FVb1cnMXszF 7ryw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6TgGhXCap5ot+HKc4DVWI/Tu4OmUEbbfSMPN/X8JLeQ=; b=rUxNLVtOU98ZQ8cjFRsRL7ZCY4ByL8Ux73tdrK0Z7Q9gtma1R87edPga7bjCZJ8vnY bQrjs+dNTclmNJoT4JDsnUjRpi/PoUghYc9b3sDgL5nT5cpBISvcQPYLS8ldWz0szvYr zXYTeYRXlmx+zCXwulQ06yhAuxmk/Ax07+mLHtTu7Z8acYAjBCoEzPKhrspBdnmEMAtf /VlVAx8jI5FqdIzeORZLBaosj9vuLIO07wWW9BYkV5M+ZtCQH+ILSTTJvatBp9baGOmF 1ulHlAGStcHkJUvZ0Bysc/aBteWwVUo5vftFIPxzTLvTpDIcwapgu47eA73ZsgNvKdjk ZmrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YFSaAM6+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h14-20020a056a00170e00b004faac3a73f4si26186387pfc.17.2022.06.07.22.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:26:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YFSaAM6+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F02C213129D; Tue, 7 Jun 2022 21:53:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346689AbiFGR2N (ORCPT + 99 others); Tue, 7 Jun 2022 13:28:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346279AbiFGRXl (ORCPT ); Tue, 7 Jun 2022 13:23:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34D6C10A612; Tue, 7 Jun 2022 10:21:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BAD536077B; Tue, 7 Jun 2022 17:21:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA5D9C385A5; Tue, 7 Jun 2022 17:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622500; bh=UMy7WkdOANGsNd0OvoRXIa3HyHp58+lil8VtMJFr4eM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YFSaAM6+nM1HWYhiOo6vvWWL2rmAHP7r0aKF2iKG0AK5+KKIWlZqmBwhuteaqOaNs frHyWQpBjuFHSXdgyYYefVsCnDwC+5oroC9InBojZAgTsZJxHURfTrcATXiAeURyAD zD3yd6lH1E/1T6w0FMcvjmUlhkP9i2r/JNlrlp0E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kyle Smith , Chaitanya Kulkarni , Hannes Reinecke , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.10 082/452] nvme-pci: fix a NULL pointer dereference in nvme_alloc_admin_tags Date: Tue, 7 Jun 2022 18:58:59 +0200 Message-Id: <20220607164910.997254107@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Smith, Kyle Miller (Nimble Kernel) [ Upstream commit da42761181627e9bdc37d18368b827948a583929 ] In nvme_alloc_admin_tags, the admin_q can be set to an error (typically -ENOMEM) if the blk_mq_init_queue call fails to set up the queue, which is checked immediately after the call. However, when we return the error message up the stack, to nvme_reset_work the error takes us to nvme_remove_dead_ctrl() nvme_dev_disable() nvme_suspend_queue(&dev->queues[0]). Here, we only check that the admin_q is non-NULL, rather than not an error or NULL, and begin quiescing a queue that never existed, leading to bad / NULL pointer dereference. Signed-off-by: Kyle Smith Reviewed-by: Chaitanya Kulkarni Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index a36db0701d17..7de24a10dd92 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1666,6 +1666,7 @@ static int nvme_alloc_admin_tags(struct nvme_dev *dev) dev->ctrl.admin_q = blk_mq_init_queue(&dev->admin_tagset); if (IS_ERR(dev->ctrl.admin_q)) { blk_mq_free_tag_set(&dev->admin_tagset); + dev->ctrl.admin_q = NULL; return -ENOMEM; } if (!blk_get_queue(dev->ctrl.admin_q)) { -- 2.35.1