From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512292; b=INWJMxUu3Bm9vc+ZmDRIrCHL0hj42N/BzKXAgR4CU2cQLlJsDviQ6eR7ZbmUtTg8CM8L ixUrS+UoKg2zKNzBYb6nk6Bs8r2CjFObm38tF/o/eEOlin9708OHIeeYUTuGKoIQtENGV cyokLPsKvF4A/gywPnYx9HNPaF/s3uYjw1K3YcS2SmLLEZcQWwzBdKIrywIAesG1jGPAj uFMnznrFkAyl/FadDLf+v44MoY+p35fj7/DWsOVvoXrT/tRWj4v1rhga4bvm0OXxlZf8f LEjnIG3h+Tc7GGAgxEBVErTFPD8gukfayqdbWc6z5XVD1pyR1Msq0GwrtJuQ8jm9VqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512292; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=ZnhNzbn03QxMrbT1dmd0YMMPCthnv02qEyd3u7IulPs=; b=w30fVRFgEtRn05LO5qed0rBqi8Kn02Ku6UmLoRNYuZr8lPTIWrocdZefczIrbp6R8BXK TMLYTBxr/tZDjwThyPXyGnA3m2DXpKCBYT8v0ZbtgiRMPaWqPcKEu5wdGnSw26H4Tc2nJ a5sxusfNlm7gS3kRUskmZGvdHJqC/YiKbhpEEgaZrkMD4eBd3f2fJKLMghlnTbIsYndbM CpC1Cn6mPCThaNzNBRdKD7QW7x1iwaMYBLFZClu4IcopsRjZC4tCcyg59gznkYu6ijRF1 FzlCvh2HrhRQFc8552QehG7RCfhz1gwl40vDWul5zTQUlJarbqjeaKo7ZxmVqlCI3Bw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass header.d=kernel.dk header.i=@kernel.dk header.a=rsa-sha256 header.s=google header.b="Tpdqi/Ji"; arc=none smtp.remote-ip=209.85.167.178 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17EBE606A31F for ; Sat, 5 Dec 2026 23:11:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 17EBE606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.dk header.i=@kernel.dk header.a=rsa-sha256 header.s=google header.b=Tpdqi/Ji Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-51f2e9e6987so2283472b6e.1 for ; Sat, 05 Dec 2026 15:11:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512291; x=1797117091; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZnhNzbn03QxMrbT1dmd0YMMPCthnv02qEyd3u7IulPs=; b=Tpdqi/JigUSb7Ozm4wpeE0boeoDWBbu7EY9RXNXQzlJUQQubk6ezIAfKjqCybJfD28 9AaXJ58+rnSdrljHkx/YsgqUz5DvDJBEMF5aUTi9yvjB6ZIUZX1O6NYx1pMpN777Hni4 tdLTgrBqjbk4HzYl1D6v6bXKUciX7/zzEYqTwI9LhS92nK1bxP3JpMnJBEj2nJSocThh i+5VN4GxNWYprt7j8x2w5M3hDvdtR3HwBm9je57AvHQBqH+cepjEgFzCT4VTNEbu6CPl a0XnesnM2yhrWnoyp8UmwQKFayQ5n6dfDgISt7SxroNlD1g06ulncGZencJgLNKG0V5G dbfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512291; x=1797117091; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZnhNzbn03QxMrbT1dmd0YMMPCthnv02qEyd3u7IulPs=; b=sYdmakfOIAO0dJIkWJ0yQgc2Jzt0mNyUDn88Vzc6tXSNYVsX5aQHBqiNZpgOr48Zq9 Z29dGkjgNdX5eELAt/caL6iEEU1yliIpoux95bTepJjYgoljZYkdJfRggX/J9r+flN1f lYY0tUBI4Y0gnOxUlxya5vlxgSs7JNLVoWXO8BxXqp7wprseKw5lVTDpR5zZQQHgxYLP sekGkas1ZvHVnxm/BKf1pAjP3oCBMRDoWZ/QH2snX2yr2ZwzrZH8nxa/A464EweSn4EU MQZMt6HGNoldxtdN4owQcvzOKIkZRteOST4hw7YLNOzvMqdis59p54fOOZomx0EKschO hlhg== X-Gm-Message-State: APuU4Z/AgOTWA2COhHEulLYsG03VWjHzNvbkGXBf4Iol2epHTh61Kzd1 f02wdb8zEpzSnoRtIsXECy6gEtG8PcSPZ40QNIiTne8cu4DPaGRLe6bXe8yXvuNLHpo= X-Gm-Gg: AZFdTZfbYJCOQgkTa8/ayIflIXmV0Pufdjxf05ZUtlx80FyKUE5Zdtp6oeDaAuKaFTu kfzGvMmz5gWwZYGdDujCnUigbs0jYqEVimkWlO5TfYGAN2DjyRB+Gs5//BhIHUVyEbTMLkgsLtw 2PfxciUT4pnJZNGJeXd0lrforVMCrWyb77+mt+0Kc/f1/cHPiIYttfpvXd7k3GJl+2BsGemczT9 Uu3JjrPcm+T5RAON1l6vQrr2hWzZglVyFRHyXaMmt4vC5RIXCvhp91LFRSrpV1MqyAyWwg3YBAW qctWb2MHEASjADR7XjkXuv6L/n+JZtTllBoAFeaaLfKIz034BywQwsmnOuOWnFXnrYNOZxuzi+/ ssMN+cF+mytdGQKcYEGp69WSwli5KscdsWeHebus3FCc407+hPLiM75Css1jp/LmicBqD3vEqQW R1EK40IKRBjh+XuHHsVDRvvUJgB+DoHzbmNBOipjcaSh/pnrNTQzqp5qJWZ78lO4y1wzWJUMiEk j5FV3FHzjOtxKsn8+M254qkKVy0n1xr1QDjPYK5QrpdkRVLYwWUAkuMLlZIHarM92nYC9XuOyxb 4mkTUC73n8yBOnFFmed6fMVjnldFo8VWGyleC+e2K3L7BLjhd6Z5hzM3nO9ETKapMst703gP/Lq 5hs0KHGqCM5B9+7aPRLO3vh+oxagZNYmmb0TZ X-Received: by 2002:a05:6808:1244:b0:4a4:64b0:bf5e with SMTP id 5614622812f47-57f204044bfmr3666345b6e.2.1796512291099; Sat, 05 Dec 2026 15:11:31 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57f1f65febbsm4163964b6e.6.2026.12.05.15.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:11:30 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6.12.y 11/15] io_uring/net: don't count the buffers of a send bundle Date: Sat, 5 Dec 2026 23:11:03 +0000 Message-ID: <20261205231107.4023506-12-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231107.4023506-1-axboe@kernel.dk> References: <20261205231107.4023506-1-axboe@kernel.dk> X-Mailing-List: io-uring@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 From: Chris Mason Commit 449c7dc8502404b3a95ffa75cf5b54be5350fc49 upstream. A bundle send on a packet socket with a TX ring can cause a slab-out-of-bounds read, if the frames in the ring hold more bytes than the iovecs of the send. io_send_finish() hands the result of the send to io_bundle_nbufs(), which walks the iovec array and subtracts each iov_len from the result. The walk only stops at zero, so the iovecs have to cover the result. But io_send() only tests if the result is below the count of the iter, and tpacket_snd() ignores msg_iter and returns the length of the frames that it took from the TX ring: iovecs = 2, of 1 byte each frames in the TX ring = 1, of 64 bytes sock_sendmsg() = 64 64 - iov[0].iov_len = 63 63 - iov[1].iov_len = 62 62 - iov[2].iov_len is out of bounds The send side doesn't use the number of buffers: io_buffers_select() commits them at selection, so at completion io_kbuf_commit() returns before it reads the number. The fix used here is to put the buffers of a send bundle without counting them, so that nothing walks the iovecs with the result of the send. Fixes: a05d1f625c7a ("io_uring/net: support bundles for send") Signed-off-by: Chris Mason Signed-off-by: Jens Axboe --- io_uring/net.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/io_uring/net.c b/io_uring/net.c index cc92e892fb53..01a3ad67474b 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -535,12 +535,10 @@ static inline bool io_send_finish(struct io_kiocb *req, bool bundle_finished = sel->val <= 0; unsigned int cflags; - if (!(sr->flags & IORING_RECVSEND_BUNDLE)) { - cflags = io_put_kbuf(req, sel->val, sel->buf_list); + /* Committed at selection time, so a bundle needs no buffer count */ + cflags = io_put_kbuf(req, sel->val, sel->buf_list); + if (!(sr->flags & IORING_RECVSEND_BUNDLE)) goto finish; - } - - cflags = io_put_kbufs(req, sel->val, sel->buf_list, io_bundle_nbufs(kmsg, sel->val)); /* * Don't start new bundles if the buffer list is empty, or if the -- 2.55.0