From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385909; b=Ii4eAf5TEFxe21Q8sr7RHRzsVvIhDgoGWNSRCr28kz4sxC5g5biEbCpDJhV6HehNYVMm IGgDyPnnzeQZPKnG/11FLuUX3032w6/TQMj4y7/0JZCOimHchnbN2emcX94iD/tf9y9UZ FolStLgY4vkScbEbhquY2UiUrcO7x4uAvJvfCEWzC5PVNx7nd50z8w6LGjlJz+DKbbJuS rNERpx3Rr/sR2JpJTaoU/55S96+2M8HNTjQYH+uakOQjnpT/EymaPv5t6xJ5ypj0M+7Js o4YEK1nmlrx7HYoH8BPkyjyqcKjR+N4BLROHhaVMf8s3ASBFXDrXCWnNYypkk9yqG6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385909; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=AXs63JkALLUXviphfXgGd8c1wzD9UZBAye02vybOw4E=; b=n7EPCZ2pkqe1zcKZSQ+YWTytKdGlw8hYHI2cCv8x/5tJ7G66NFmV3IcrpMO3tdcMVet2 usJlK1jMmMoVfgYa22McGU2wUCxE+w9dt6iS2/lebj/2wbgmlolVWpirsKxtaMNbammE+ b12LXz0f2JKUH83thsmZjX1S6EfR4qO9LBOGGDufdw3iSzHvNWeBTlMZ9U6vw2TqOHjLF 90H/mfQ/4Y47neS0vvLNvNJf7ZEHsRt4+aZKR8gGsf0meSmvKv0rjF2+xrmvVuXG0DAQ6 gy3g7MTnxPaFKnj4IuW1uI/Yuw9NhZsiMJfR+gCNt9E8PVD1/SUcgkuwqJMyX8QtdOQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=k2OvNKrn; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9F6A606A32C; Fri, 4 Dec 2026 12:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=k2OvNKrn Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E9DD1F00897; Fri, 4 Dec 2026 12:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385909; bh=AXs63JkALLUXviphfXgGd8c1wzD9UZBAye02vybOw4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=k2OvNKrnybIU76ZEhmnhZwxdrzjGi8IgZS9krHrMk15FDUDfjHxi/4B8wKCIrTUP3 MtlpN9+wAs2eV8EgWWzPjGf4V40XNmQWzSOH8A1zp07bMVR/5K7twFBbpRM4uHLveb WDzJ8G4vHRmynBbX+NMruIHlmHaRIO4ri95eFHHM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Cheng Yongkang , "Christian Brauner (Amutable)" , Sasha Levin Subject: [PATCH 6.6 0743/1167] fs/splice: clamp an over-reported write_iter result Date: Fri, 4 Dec 2026 19:02:50 +0900 Message-ID: <20261204100721.422117381@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cheng Yongkang [ Upstream commit 2d956723e82cddae8ff8e9da99a666217b02065f ] iter_file_splice_write() builds a bvec iterator of at most sd.total_len - left bytes and passes it to ->write_iter(). It then subtracts the returned length from sd.total_len and walks the pipe buffers by that length. A ->write_iter() implementation that reports more bytes than the iterator held makes sd.total_len underflow and the dismissal loop advance pipe->tail past pipe->head, releasing a zeroed pipe buffer: Splice Exceeded! ret=7 tot=1 left=0 Oops: general protection fault RIP: 0010:iter_file_splice_write+0xb6f/0x1170 Commit a3de58b12ce0 ("netfs: Fix unbuffered write error handling") added the warning for this condition but only reports it. Clamp the return value to the size of the iterator that was actually handed to ->write_iter(), so the pipe accounting stays consistent even when a producer violates the iterator contract. Fixes: 8d0207652cbe ("->splice_write() via ->write_iter()") Cc: stable@vger.kernel.org Signed-off-by: Cheng Yongkang Link: https://patch.msgid.link/179328314072.648427.13388575162083843840@gmail.com Signed-off-by: Christian Brauner (Amutable) [ sashal: Added the over-reported write_iter clamp as a standalone block, since the context lacked the existing WARN_ONCE line that upstream rewrites. ] Signed-off-by: Sasha Levin --- fs/splice.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index 63d37481baa25..c673b31324c3e 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -736,6 +736,12 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out, ret = vfs_iter_write(out, &from, &sd.pos, 0); if (ret <= 0) break; + if (unlikely(ret > sd.total_len - left)) { + WARN_ONCE(1, + "Splice Exceeded! ret=%zd tot=%zu left=%zu\n", + ret, sd.total_len, left); + ret = sd.total_len - left; + } sd.num_spliced += ret; sd.total_len -= ret; -- 2.53.0