From patchwork Mon Dec 18 15:31:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 180540 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1348194dyi; Mon, 18 Dec 2023 08:08:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlSJZGCo4A82pgYLyMdSBThta0nhIDZDRqouykzqsBOa1/Y9tKTDs9ltZK3xXwLray1X1Q X-Received: by 2002:a17:902:9a82:b0:1d0:6ffd:f21b with SMTP id w2-20020a1709029a8200b001d06ffdf21bmr7309321plp.113.1702915716091; Mon, 18 Dec 2023 08:08:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702915716; cv=none; d=google.com; s=arc-20160816; b=Aqi3u/guLvtynh5XL8NMpxeq1rdvHi5aHGb2Yf1H4Jid50XEhOMPoSat2eRZWDbasI MQ39s+NrtPrFs0RNCDtnei6QD5mmFKezyEIbkzXB/VZGSGDEgieqvHd2RaaJmJt3fgIu X+JZRnYOiBOmlx8YOE+YWFFpwQiW5Hi1+iiuHQ/aC22GetYHT38BHeeD3YtDRotWNmiV LavNljIqEE5Qn3oCChgb1a8E++moz9pVHQHwlaOdPWPKTCbBY92vdqQxxdZI+ehGsNDh VwhYlWY2XH6BV4V/KSM33rW8WGl/iDGc8b4Pc+q4vP43GkLyJXwhkuKZd+kgJyRPSA1t ARWA== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4029-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bj17-20020a056a02019100b005c65ed0f688si18312778pgb.296.2023.12.18.08.08.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:08:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4029-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4029-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4029-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DCE39285188 for ; Mon, 18 Dec 2023 16:08:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A817D5A856; Mon, 18 Dec 2023 16:05:10 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785636549555930026 X-GMAIL-MSGID: 1785636549555930026 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