From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from oss.cyber.gouv.fr (oss.cyber.gouv.fr [51.159.188.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20EF43E51CC; Wed, 7 Oct 2026 19:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.159.188.251 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791401348; cv=none; b=ePUuOIrwCoy3puS6VyUOebgqT3ZOG3J0MRj//dg6GUazDbvXuwbLes5WE9IjiU0xXiF495RyBYsB3eujFj5jEOy8TidChn0AmQ1ZtfcjiLNBRyqy+VKO81ZlSCWEU+tMVkHtpkTotXDam0aGTl/Q8QaPvLHISs4M9wPv/+NiOf4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791401348; c=relaxed/simple; bh=k6YpfiEdh2GP3hWib01y5/9ivoMzHcTvSETC56yQqc0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=gZM1L93+yiyf9FzBEhF4oYeHvCF1PyBvbCT9comHCe0iTROMCfMSa/J6QS/qiivx4FM0SxKTLSXD+fXnqfM3BrDo+kUQ4gYI3vE1DOzHhApyLj9CtJc9ycoX8ecdK++AnN5k5TUKNNzNLQZwRSQDVTcDi7quFaDqURPlCUISJ+o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.cyber.gouv.fr; spf=pass smtp.mailfrom=oss.cyber.gouv.fr; dkim=pass (2048-bit key) header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.b=ck2FKZ6t; arc=none smtp.client-ip=51.159.188.251 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.cyber.gouv.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.cyber.gouv.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.b="ck2FKZ6t" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=oss.cyber.gouv.fr; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Sender:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=6+69slp1fYXOYdcZNcZCy0X/KP79xkjSAOAlv4FvrV4=; b=ck2FKZ6tp3oFqAIrJwQf/Ym4vn b3dZJ6jVP/PtTQ+QvHxJv0begFHohHzEEONVVHdWHkUnadC3nKK9Zg9YhEyu96FvD6Y5WV0hxKo9D Bj6y4JZe0A4zesMdPKdnAwQH8wEas1JZh989IJ6lwX5Bzjj5dCq/WcSII15BPJGXjIQG695JZ44j3 HCN4RztSI1C7u7Mj1cmbqbVGUxdK+xOcHXFjyfNycmRylBE68uLVVB/372tuFWwj+04dLLOD2hxX4 fSGv9kQlQ60oCGmEnioUpcF5hwY4tO3aigTns/cGIazRD1CRBUL/SJSK2fNhpioWgxdEMM3ZVK5AE +fKzZigw==; Received: from [151.115.150.205] (port=42584 helo=gepetto..) by pf-012.whm.fr-par.scw.cloud with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xEXK1-0000000GBW7-04Sh; Wed, 07 Oct 2026 21:28:58 +0200 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Jean?= To: Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=A9my=20Jean?= , stable@vger.kernel.org Subject: [PATCH] nvmet: free the bvec on file namespace range errors Date: Wed, 7 Oct 2026 19:27:46 +0000 Message-ID: <20261007192745.160060-2-Jeremy.Jean@oss.cyber.gouv.fr> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - pf-012.whm.fr-par.scw.cloud X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - oss.cyber.gouv.fr X-Get-Message-Sender-Via: pf-012.whm.fr-par.scw.cloud: authenticated_id: jeremy.jean@oss.cyber.gouv.fr X-Authenticated-Sender: pf-012.whm.fr-par.scw.cloud: jeremy.jean@oss.cyber.gouv.fr X-Source: X-Source-Args: X-Source-Dir: nvmet_file_execute_rw() allocates the bvec before nvmet_file_execute_io() checks whether the request fits in the backing file. If the request extends beyond the file, nvmet_file_execute_io() calls nvmet_req_complete() to return an error. This skips nvmet_file_io_done(), so the allocated memory is never freed. Repeated requests can exhaust memory. Use nvmet_file_io_done() to free the bvec before returning the range error to the client. Fixes: 50a909db36f2 ("nvmet: use IOCB_NOWAIT for file-ns buffered I/O") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Jérémy Jean --- drivers/nvme/target/io-cmd-file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c index 0b22d18..695963d 100644 --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c @@ -133,8 +133,8 @@ static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags) pos = le64_to_cpu(req->cmd->rw.slba) << req->ns->blksize_shift; if (unlikely(pos + req->transfer_len > req->ns->size)) { - nvmet_req_complete(req, errno_to_nvme_status(req, -ENOSPC)); - return true; + ret = -ENOSPC; + goto complete; } memset(&req->f.iocb, 0, sizeof(struct kiocb));