Article View: linux.kernel.netdev
Article #26507[PATCH] splice: clamp an over-reported sendmsg result in splice_to_socket()
From: Kyuwon Cho
Date: Thu, 03 Dec 2026 16:38
Date: Thu, 03 Dec 2026 16:38
52 lines
11854 bytes
11854 bytes
splice_to_socket() hands sock_sendmsg() a bvec iterator of len - remain
bytes from the pipe and then releases pipe buffers for as many bytes as
sock_sendmsg() reports. A packet socket with a TX ring sends the frames
of its ring instead of the iterator and returns their size, which can
be more than it was given. The loop then walks past the buffers it
handed over and releases an empty pipe buffer:
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
RIP: 0010:splice_to_socket (fs/splice.c:827)
Call Trace:
do_splice (fs/splice.c:863 fs/splice.c:1304)
__do_splice (fs/splice.c:1386)
__x64_sys_splice (fs/splice.c:1583 fs/splice.c:1565)
Commit 2d956723e82c ("fs/splice: clamp an over-reported write_iter
result") does the same for iter_file_splice_write(). Clamp the result
to the bytes that were passed to sock_sendmsg().
Fixes: 2dc334f1a63a ("splice, net: Use sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage()")
Signed-off-by: Kyuwon Cho <kyuwon.cho@skku.edu>
---
The issue was found by an LLM-guided test generator that we are
developing as a research prototype. It reproduces as any user, in
its own user and network namespace: a packet socket with a TX ring
(PACKET_TX_RING, frames queued in the ring) gets a one-byte splice()
from a pipe. packet_sendmsg() sends the ring's frames and returns their
size (write() of one byte to such a socket returns 128 as well), and
splice_to_socket() releases pipe buffers past the one it handed over.
With the patch the splice returns 1 and nothing crashes. The reproducer
is available on request.
Found and tested on mainline fe6ff8d5d675 (v7.4-rc5, with KASAN);
the patch is against mainline.
fs/splice.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/splice.c b/fs/splice.c
index 5397ded643a7..968a98fca238 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -811,6 +811,7 @@ ssize_t splice_to_socket(struct pipe_inode_info *pipe, struct file *out,
ret = sock_sendmsg(sock, &msg);
if (ret <= 0)
break;
+ ret = min_t(ssize_t, ret, len - remain);
spliced += ret;
len -= ret;
--
2.43.0
Technical Details
Message-ID:
<179607207060.562302.2730435649142138817@skku.edu>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376761-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376761-linux-kernel-netdev=dewy.ru From: kyuwon.cho@skku.edu (Kyuwon Cho) Newsgroups: linux.kernel.netdev Subject: [PATCH] splice: clamp an over-reported sendmsg result in splice_to_socket() Date: Fri, 4 Dec 2026 01:38:13 +0900 Organization: Usenet Network Message-ID: <179607207060.562302.2730435649142138817@skku.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2542733"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:PZjxzkO4tuRbPgCWYMyNKROxXFM= sha256:MgN7rycugHiJ05+aQ9T0mFQwo1leOClBhOJYVzIMAv8= sha1:jdbstyWABob/q1+ChihAfOjF1Cg= sha256:va/gfVU80uXNeRMcGQOMm2P/RxxamWhj0uDg8wbQghY= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 6083E1179DA; Thu, 3 Dec 2026 19:38:43 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.299 X-Spam-Status: No, score=-3.299 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=worksmobile.com header.b=KacDOa/0; dkim=pass (2048-bit key) header.d=skku.edu header.b=r4TkZZsB X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Yn2e6wsSb0ue; Thu, 3 Dec 2026 19:38:41 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376761-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=skku.edu X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 7C0301179D5; Thu, 3 Dec 2026 19:38:27 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id DC7F725C42; Thu, 3 Dec 2026 16:38:23 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1796315903; b=mGekCEjnISO5JJOWBNG2R6az4oO4KI01U/T8IGInTrod1aEmazxYV3oJ3Hpiu3J7Hhi4 kDjR7m/qUbTm/ZWRNaTbiPHfRe5UlfBjKVvh+T9BjsGkhfNIFjgtM76W2Gzja1LO3BF5a 9xpsJl51UCU492ndEPbWDOHakcK0v+lGlG1CvPIFbW+XdF3/yYRPOVjh2FCxFl5beW1uz OPSi5uZEzrf3Lkf92qqb2aIV3bL0nfcclJ6ar0DgE3xbLEXu+GJ2PzlEnRrNrGt1Rx28/ lCbW+T/LOZiDuPAb+eR3WiibsGCxDOxSFAbHBFCtxow5ybggK/crxuhiYg8c8IC5yng== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796315903; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received: DKIM-Signature:X-Session-ID:X-Works-Send-Opt:X-Works-Smtp-Source: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Transfer-Encoding; bh=e81Z7dJM9PovW/JgZOtPey6iJ1Vu6E9Na9GQejH2wtg=; b=Z2Mqlf9k/l47arQXNVbR5OiLUfX2tmWhK783Icc/QXV/2ukMxVmWW/74zYs35dxQbPw8 KbKwLgEjypa8p/U5XoUNFxYnJL/+IJjRjXa4CEHhsrZyzet2hqpeSKDYgFeEq4dYUY7rb ehhlvvn4/nidTR/p1Y3Vqjp35421L3vddu9FA7fDEiQ6Q3kzISlk+e3iq9sdNC9u7Y5kg xiJKQZtwNo1Zs/HVfSHo2OaMZBSNFCQorOFBpfQ8GbRnupqs0YHC5rz3beJo3FQXYnHNw e24Wj3Zb8BUiruCj58dYKpDsEl3C5ThsoEqYp0qsSk1ZhHa/SAV2WDowpwXo2WLDFYA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=worksmobile.com header.i=@worksmobile.com header.a=rsa-sha256 header.s=s20171120 header.b="KacDOa/0"; dkim=pass header.d=skku.edu header.i=@skku.edu header.a=rsa-sha256 header.s=naverworks header.b=r4TkZZsB; dmarc=pass header.from=skku.edu; spf=pass smtp.mailfrom=skku.edu; arc=fail smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2BAE1606A339; Thu, 3 Dec 2026 16:38:23 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=worksmobile.com header.i=@worksmobile.com header.a=rsa-sha256 header.s=s20171120 header.b=KacDOa/0; dkim=pass (2048-bit key) header.d=skku.edu header.i=@skku.edu header.a=rsa-sha256 header.s=naverworks header.b=r4TkZZsB X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=125.209.209.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796315902; b=Yem3c/i6gs+dg1+ehq3Oop1WBUBOmhVo9l7qo2vt1Y5pp4D4f2Cy8NhJPjjL2KZcqay4 0HCJmc66nPyV4S8AdTyc0e216EKkm9tbfYrUd5+56noMYvSaOaXeVuRt7mLmZ1tZFr8E7 2i5ptRFyL5uHqyALnQ3m1dH/B8WEUzIW7EaG3td6iAGCAXl93esjU862f6Plsp+PuE1dR QZX5VP+Lhu3rnpRehz5uLmLn9XFv5z/2sLUXzAua4EUzvi7TFRNesytaE6ZgIbxSvb/tk w0tLesPILW0brMCZykL0jae9bg51gC2w1+v2K0mcafZc1exnPsCZqpPJRgN9CDMFsLQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796315902; h=DMARC-Filter:DKIM-Signature:X-Originating-IP:Received:DKIM-Signature: X-Session-ID:X-Originating-IP:X-Works-Send-Opt:X-Works-Smtp-Source: Received:From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding; bh=e81Z7dJM9PovW/JgZOtPey6iJ1Vu6E9Na9GQejH2wtg=; b=Md9R2hEQTMyaizgqmuEynRRBJx2lbhbc/GANieyun5HgdErp07otd8epnq0jv1rEGUj0 0otWlPpJucaMImqjqUcMsohUxq6Vwx7yx3U+T+JvkF9wTkHJXD98mZTKjZNNp+eXaAmXT h7j5TOdycC1uPGqi/mYld2dBiJy46Gn4gOlrcYHd7UgGNWFNVbwgwPisEmfGRz6tPt71Q EofzxLIYPas2Vhu+2K9lIxxYcu9IYoyrQMh1kK1BzSAIWHgBT8vTqtiNS24rdhJiGO+qt qSM4BVi3Ch7mrYEudexdO61sIIPbPM4KfNYQwg9augNwplYRWexOO9uyAEEDJGh3oRg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=skku.edu; spf=pass smtp.mailfrom=skku.edu; dkim=pass header.d=worksmobile.com header.i=@worksmobile.com header.a=rsa-sha256 header.s=s20171120 header.b="KacDOa/0"; dkim=pass header.d=skku.edu header.i=@skku.edu header.a=rsa-sha256 header.s=naverworks header.b=r4TkZZsB; arc=none smtp.remote-ip=125.209.209.18 X-Received: from cvsmtppost103.wmail.worksmobile.com (cvsmtppost103.wmail.worksmobile.com [125.209.209.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81DA4606A32C for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 16:38:21 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 81DA4606A32C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=skku.edu X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=skku.edu X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=worksmobile.com; s=s20171120; t=1796315894; bh=3nFN4aa9I2NN5SCW9YbGisHFMAjqox1xUad5T9kRaC0=; h=From:To:Subject:Date:Message-ID:From:Subject:Feedback-ID: X-Works-Security; b=KacDOa/06EKtpJyjSA0TFyoMOZk9YX9IHaHeKU1uLJnvMzlICrxB+p1jvZLDdtbQD YxTlV/jhASQa2x2amE22+3MqS/3sZedBRNKRXyo0S5Ewldz27rWY/9XLCxy8Qw1R90 CIk2gNDoWDIz+yD1M98pWF8XFnEX/hSTqwMWeKNvON9nzpHBHWPzvfgWLEX+dHOfHv q6T13Qv01j6Pyy/CdgVjrq3JUNHt3VKfecVVE0LYM/mEnQZh+CrK12ORcbLnYD40Dw t+n3dYPk2d4JWFfhI6GfG3+zWePdPhAJxD1WrHzp4GpNzdVq8h7IxBDi0pUBWalTUt b1J+iXN85q4KA== X-Received: from kr1-hmac-real-8 ([10.174.201.129]) by cvsmtppost103.wmail.worksmobile.com with ESMTP id 2OM4CVP8QPKJy8h5+0Y2xg for <netdev@vger.kernel.org>; Thu, 03 Dec 2026 16:38:14 -0000 X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=skku.edu; s=naverworks; t=1796315894; bh=3nFN4aa9I2NN5SCW9YbGisHFMAjqox1xUad5T9kRaC0=; h=From:To:Subject:Date:Message-ID:From:Subject:Feedback-ID: X-Works-Security; b=r4TkZZsBTwrxJijspfQOjNIdlFaKfhy/Q2ZtsJnRIoe8kucR/VxzxLJLK7dA68SXr ILz3gsDUgBvR76EIaKKFuYv+zIA196rJSaA2/0ysUJvf6fO73o6GwTh6ciLUCj9fK5 CL1/8UJql99ipImhNlCTUI9gG/f+8yIniH06RB5J7LDS9MEXZrL1nHYrVzzfuKC23B hDvfoMhVJpgqUFVkVl9W/PPXfMR8+eb450sWnhoFDis2/yZC0dYmwo7Tnw1YhdR7ts wRHQpYIBMROtkERpMGjmZgUWkg2uGR2HigtCFN0+ma+s8SslQqbxrU0TmKRkHVpu5/ 878IQRvLuLiHg== X-Session-ID: 87Y6CLDST2mqMMYo7GnyBw X-Works-Send-Opt: wlbXFqgmKAKmKAFYKqMqKA2mFAurjAumKAgmKxEmKqK/aAtwaBmmjACYKxM/axKmKo2rFBwYjAg= X-Works-Smtp-Source: IqY/KoMlFqJZ+Hmqaxtq+6E= X-Received: from d4082dd914b5.tail196be.ts.net ([115.145.173.180]) by cvnsmtp101.wmail.worksmobile.com with ESMTP id 87Y6CLDST2mqMMYo7GnyBw for <multiple recipients> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 03 Dec 2026 16:38:13 -0000 X-Cc: Jan Kara <jack@suse.cz>, David Howells <dhowells@redhat.com>, Jakub Kicinski <kuba@kernel.org>, Cheng Yongkang <teel4res@gmail.com>, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list