Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp31003rdb; Mon, 18 Dec 2023 08:08:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNHtgi39qcBctkJqqCUr89dXLQlxJm4WUsxBgz6jnIs9ibSVTarU3vRXLOAAHeUloV1GtB X-Received: by 2002:a05:6808:1390:b0:3b9:e861:a8a3 with SMTP id c16-20020a056808139000b003b9e861a8a3mr20756669oiw.76.1702915707492; Mon, 18 Dec 2023 08:08:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702915707; cv=none; d=google.com; s=arc-20160816; b=cVMm7Mx2Ulzrpld7l5OmZy8YHnOMV9Jz3BdduxYmJ5FCSEmnl4iSapCeykScj3U/xv eI2D/fQhkKZWYps+OnQU+HxLJFSFro8hy7SeoanKc84e82w1GAmaqFlDOUSOpMyIA1AE ikMJZY1q0EuBDljqVPsJ2XBUkXIhvcr+lk5jClhDJ+nfeeoWAdzepj7qM4yXD/vpUwnE c0EwrqdMIxx/T8QPu74N4bPClRUlicWfdHz02EKWPEsLMm6uzkG+qVS/fCYkhtPQ8LOn pkgwbFac+krt1yb2UkSjqrJjXIiiuBg4dOEjftBMSXdQvA5oWxlu0/egbTnCMp3nrQa3 Hy4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=n11OfF1QXEDTY8UUINBbHh622YQ31BcFGsGZL13OMCo=; fh=3QIVKsEmsld8rvcEkMSr/XDw53o2lrGJeYcvS7FhzFk=; b=pWmtStvBhRbI/htFiNarXn8sAyKzFqsCDed+oW68NlkAVMSyx108H9af1rdpRqtHPL u8GqS789E2AG/l21SrOMpVxwjBWeJUxOMoc8szU/ymdd8s/fE8WoEdXkfXEvmW2b2v72 F0fgjV8ge+eZIBPNx5+GG9HGBFO3Yh8MKspyV0W+5UOEB2uAAF9qcrxI0BG9Zs71tudO pbenleWIDDeyJtwPwPMXwIFdDQ++8OdRY0/OyScXqHPrURRlQ5kkd+A8sUKbk97DQzJt +HN0OW/O80Dhps2nGJzrN0FReDt5FEJSOcUNJvSXZJ0p/zKumOsTwznyiH5Sailweeji M0FQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4029-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4029-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v17-20020a25c511000000b00dbd47fa3f65si424321ybe.235.2023.12.18.08.08.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:08:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4029-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4029-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4029-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3BD701C25981 for ; Mon, 18 Dec 2023 16:08:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 86D365A843; Mon, 18 Dec 2023 16:05:09 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F95F4FF98 for ; Mon, 18 Dec 2023 16:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6C8831F445; Mon, 18 Dec 2023 16:05:05 +0000 (UTC) Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 5AE7C13BD5; Mon, 18 Dec 2023 16:05:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id LMq+FLFtgGUtBAAAn2gu4w (envelope-from ); Mon, 18 Dec 2023 16:05:05 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , Keith Busch , James Smart , Hannes Reinecke , Daniel Wagner Subject: [PATCH v3 14/16] nvmet-fc: free hostport after release reference to tgtport Date: Mon, 18 Dec 2023 16:31:02 +0100 Message-ID: <20231218153105.12717-15-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218153105.12717-1-dwagner@suse.de> References: <20231218153105.12717-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spam-Level: Authentication-Results: smtp-out2.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 6C8831F445 X-Spam-Flag: NO Give the ref back before destroying the hostport object to prevent a potential UAF. Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 663c51c9fe53..23d8779dc221 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -986,8 +986,8 @@ nvmet_fc_hostport_free(struct kref *ref) spin_unlock_irqrestore(&tgtport->lock, flags); if (tgtport->ops->host_release && hostport->invalid) tgtport->ops->host_release(hostport->hosthandle); - kfree(hostport); nvmet_fc_tgtport_put(tgtport); + kfree(hostport); } static void -- 2.43.0