Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp38618rdb; Thu, 16 Nov 2023 11:13:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzR/ZphXo+W806YvtYexSRDckAcfEtViPPk9GFWAq3Ojl89WMCgPIFpwBFdaoR03vfS2ZD X-Received: by 2002:a17:902:968c:b0:1cc:fd1:c85f with SMTP id n12-20020a170902968c00b001cc0fd1c85fmr8153406plp.22.1700162008310; Thu, 16 Nov 2023 11:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700162008; cv=none; d=google.com; s=arc-20160816; b=Vn4vKaYmkZgfuh5RBRA2D9M7QIZFkWEwKuJrQ3At48e5qNy96KRwnzveqJaGtKdfpa vtRfOiFRe/RlU4mA6FrTGn+XXPJssNjy2tu9yU0iPHltVC7B8vcS1dPigQZiP3L+/n3d H0+tKBHMcBAhvguExi2DJrZrp+XMiyUGquFB+0wWmfYZrpDZgdkitLkccexv+rpdvTe9 JljE8SMgJBIhMm928puOj0aFWaZ0dNKq3e45dM4fh/XYL8hkUB9XA8GDGJvlohH7ELcv 6c666dZr2eELTuOtVlYNmg9UpshzJ0eoj2RT0yrCteXiTmDM0R8gMHB7Db9LpUHidpEy ScGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=sPxNHo3ULcsNHonG1S3dXxZBWwtHJpSMfZE5XqJO15g=; fh=AG/JXgU0L73PKs+Sss1KWXsYF58MIGjCXCMnxGnkACY=; b=FGdA3hGGkQPmdtw7rHfc+EA7vEZjFt8j4+wtfx0J6y09voaFiWUKmnJkeo+yMAh/Gh ctqwSm4KdSEKvSx0u3668DOJNxijl/11rtxNOFtTmPFQwSbwnGFrhoWhJ6ACcCULbF1j IrPqC0WEfEYEnqOVoK+OVsk0A+JuGjvakX/wsqhg6NJgJsE+zBpdU272bczRgOArSQ9o DjeJJLa3Dxxzmuh9rPXMEvVVEt8FeMC07LQqMA6WCpCv1YIrNT1HbFf1RbuNMLAwfHNx 1tbZeTR4vet0ZTb+rVu1twdQqBbCuN46Une8KubiP7pS6B2/Zy3iznuUOTkDz4Klzmjs RCCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@purestorage.com header.s=google2022 header.b="Pkt/b6k7"; 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=REJECT sp=REJECT dis=NONE) header.from=purestorage.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bc1-20020a170902930100b001beef8ccd05si13076plb.489.2023.11.16.11.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 11:13:28 -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=@purestorage.com header.s=google2022 header.b="Pkt/b6k7"; 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=REJECT sp=REJECT dis=NONE) header.from=purestorage.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4CB38803BE9C; Thu, 16 Nov 2023 11:13:25 -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 S1345465AbjKPTNQ (ORCPT + 99 others); Thu, 16 Nov 2023 14:13:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjKPTNO (ORCPT ); Thu, 16 Nov 2023 14:13:14 -0500 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 794BF1A8 for ; Thu, 16 Nov 2023 11:13:11 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-4219f89ee21so6519591cf.3 for ; Thu, 16 Nov 2023 11:13:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1700161990; x=1700766790; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sPxNHo3ULcsNHonG1S3dXxZBWwtHJpSMfZE5XqJO15g=; b=Pkt/b6k7WA1LfcJr2gjPZUwr7GYpDOoguHruPyHA93EM8WoC3eJZKYGUO9vfbbjHYQ qgLsZjvSQT2O+ngLSdlqUPcw9avI5T5dlRPfJbwpyxGUXZ3J0jpmbCmGQsNo2yzWscQG q3ZaAlIuRvopVQSdwjN73aTA3GTgG0+sSLAhbFiLDN7JkClVA+cfgq+fM1VkV9TvLLz1 LmDVtTSlSguSEPi313DkbV2fVCVJVqJczLD+hdc4ldm12LD7gZGiIQYC3eZnlbwinRP1 59gB8cD68JnxgTejPsC97DaYKK8I8A7qOa9Qnh+HqLZLKWuNo5mlS/LnRlmj3/J8hyHt LJUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700161990; x=1700766790; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sPxNHo3ULcsNHonG1S3dXxZBWwtHJpSMfZE5XqJO15g=; b=p0t2a+TiQcUPQdLR5gHMUjPcYCjXhiabwEWhGJ/9jm4W1/yF/bxd2e2uJ2S+pYdpSu eI+BeVtGEOV5osf4ZCuDYwyib9/BwP8LTDudiJ5isR1lFEpI/ISEIZ8zmLFvyMm2o0Cj vscDfv1jpNcW82gsCLgOAy3WHGYg6pvelNnLIfZCgII3smNmEuXawde3btPOVqfll3ts DuA1oB6VGI+lRG0uhEV8SwkR17ZEBTNLleGDY/egutaGFNzp9Jxs4E/Op0/4uXGM1PP8 06vZX2Gj9BuigWtNu84zRqbzgiDNWapNaWhJYdsg15T+nSLEaLX+B+Poi64mB/+dK7DL mSmw== X-Gm-Message-State: AOJu0YzGbidsPFXeEVvb8PnBki6APPkTToKY73+BEPXDt9psCGLEtXTQ tMyJ8CsChshKJDN0YI/tYy0vZ8Yabfm9o2Sckbz8oA== X-Received: by 2002:a05:622a:56:b0:418:1f52:1421 with SMTP id y22-20020a05622a005600b004181f521421mr11326596qtw.9.1700161990608; Thu, 16 Nov 2023 11:13:10 -0800 (PST) MIME-Version: 1.0 References: <20231115185439.2616073-1-yzhong@purestorage.com> <69218380-45f0-41cc-8a65-50878d44219e@kernel.dk> In-Reply-To: From: Yuanyuan Zhong Date: Thu, 16 Nov 2023 11:12:58 -0800 Message-ID: Subject: Re: [PATCH] nvme-core: remove head->effects to fix use-after-free To: Keith Busch Cc: Jens Axboe , hch@lst.de, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, randyj@purestorage.com, hcoutinho@purestorage.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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]); Thu, 16 Nov 2023 11:13:25 -0800 (PST) On Wed, Nov 15, 2023 at 7:52=E2=80=AFPM Keith Busch wro= te: > > On Wed, Nov 15, 2023 at 02:44:04PM -0800, Yuanyuan Zhong wrote: > > On Wed, Nov 15, 2023 at 11:55=E2=80=AFAM Keith Busch wrote: > > > > > > On Wed, Nov 15, 2023 at 11:21:53AM -0800, Yuanyuan Zhong wrote: > > > > On Wed, Nov 15, 2023 at 11:02=E2=80=AFAM Jens Axboe wrote: > > > > > > > > Do you mean something like this? If not, can you please elaborate > > > > "when we need"? > > > > - struct nvme_effects_log *cel =3D xa_load(&ctrl->cel= s, ns->head->ids.csi); > > > > + struct nvme_effects_log *cel =3D (ns->head->ids.csi= =3D=3D NVME_CSI_NVM) ? > > > > + ctrl->effects : xa_load(&ctrl->cels, ns->he= ad->ids.csi); > > > > Will it be good to change ctrl->effects to ctrl->effects[3] for > > > > already defined CSI? > > > > > > I suggest either re-assign the cached head->effects to one from a sti= ll > > > live controller when current path is removed, or move the saved effec= ts > > > to the subsystem instead of the controller. All controllers in the > > > subsystem should be reporting the same effects log anyway, so > > Is it specified in spec that all controllers in the subsystem > > should be reporting the same effects log? > > Yes, in section 5.16.1.6, "Commands Supported and Effects": > > This log page is used to describe the commands that the controller > supports and the effects of those commands on the state of the NVM > subsystem. > > Oddly enough, Figure 202 says the scope of the log page is "Controller" > rather than "Subsystem". Sounds like ECN potential. You can memcmp the > effects log from each controller for a sanity check if you think some > subsystem controllers messed that up. Yeah, it says scope is controller. I think it=E2=80=99s valid to start upgrading one controller in the subsyst= em to report different effects log, e.g. adding or revoking CSUPP for some opcode. If the saved effects log is kept in the subsystem, how to refresh it for the subsystem?