From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512403; b=zulinK19lWkh97Q9zHkLNBVzhKGO7EUtrTY0JoB014X0FM7qz6Mw3tqJOTFrUn2shcdO AqCp9iFSnLWFAHbeC0DyvXYgvn3HXG7Qct4pOc3x91SZubBX6SLSYUnJVZZ0kZRt7hbYa KdFCVBZD3N2dGvKqmlRYdssCouBIWzHbKBmDBw4vJZtVrlKL/usBUXvOcE8Xn3IXoRnGa YB5juB4ZsSOK1uT5ZUXEu+th1KNNHmdRC/cZmn/nFbQ2jbwxdmlt5I1UM0iS9Vb1fQVV5 UISSd+rXiIAnaUnqnQWwKPucixkPDho5AFugObrvgACjV8Dw88+Oa5X9ihado/dyzxA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512403; 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=RRGTLIBiME2L28kcEih49nzAVXAr7sAEZnnCBfsqRdI=; b=dQka+04SxF2znoQkSqXtGoDX54Vn0xoUEVTMgP5KlP4+1vAKCmuNPSpb92+1Nh73L48l hdcBMV3xYrHANc4tsqemanzO/5lSzaMmS9xHl9DCg/jgT83eQeNJSQU0HqhT2wCkgJXcL 2uMsEtM2Y0eduBu2d5Q0w+KzRGwvj3Sbzs6gYGAHg30eRIbSRo8rIUO8zTznyc4covlHU CrXMV9ApezStJL0cLTqs/Ncn2pV+3vqj7J1UhKxy69TQXgG6pzrLE5/2Wfnpdoi2dbTNM m6Bhg9/zFxNNhdMwvaLp3io0QufufirO7+fnlS9fCpnEErk1inUZUTCdvi+wcVcCd5g== 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=C8LgQ6HS; arc=none smtp.remote-ip=209.85.210.46 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (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 6B749606A322 for ; Sat, 5 Dec 2026 23:13:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6B749606A322 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=C8LgQ6HS Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-8253bc5a613so1481722a34.0 for ; Sat, 05 Dec 2026 15:13:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512402; x=1797117202; 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=RRGTLIBiME2L28kcEih49nzAVXAr7sAEZnnCBfsqRdI=; b=C8LgQ6HSwnjnJF/nrAN15ja6AyydqpPP3rCe4h0ZyHwazGrMcUz3DducZQfO5yhRiQ UKBYr4mJmr+uKKYiwGp+iuNVqKFzfSSYfceQA2IgMo6dMeFDM8e3XvMs+CxMPAgREf/s 73jI/4riuzCAJuauu6NxDkArDQ2bIE42bY/pn1NmGaFbe3bh36TBZiVTG3EWLn44pDKZ 2Xn1YoS1EhewF5YYP/VrMEojCAsSkOEL4tom0TFmgyOx1iljVCnzs3/gSbkM0jzxZa4x qZij7ANnpbM1mq9ByCbiuM7w+p3Lo4fS1zZwwxvhexIr8m/qvbi2PitWrC+T3Rch77ps JFOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512402; x=1797117202; 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=RRGTLIBiME2L28kcEih49nzAVXAr7sAEZnnCBfsqRdI=; b=J5ffLeUNpoZV4GJ5rTprlvS8hMfFT8goDSnSzp7OytudKpGJy0ERntHp/KVVgrR9Bn SEsmfwvfMW4b0MVvOSUrmfObknMzphS76eSIY6ZwblcO2n6TzawWF28Eq7cqwJjkG61O zp9fGj1GOsaCdHGZ/lRBPEutc4Rg+iE+Ad82JXCB82WU2e/fcadsFH7y5EhDJLLy6V93 BrmFMtz5JsdDd86aR5aQWtAvkSHzQ9J2UdVikj6KALdkhFlTRPzRFpQogcSHwCGdiTQ/ Ko0NjLzUWOFTFhvhw0QPK34z1MmZI3X5C2cM5fRkPCL5SVkoHHX7e65rFP95qoKTyq+8 JUng== X-Gm-Message-State: APuU4Z/hDhY5aGxDGzP8UiY4r7Y/bMr/DmItCQkZoODmkCyIY6VY4tNm t/voqrA30OIaba1LL5YJLjhTLtLxmC8maKdH0z5k0A06g0VuqeMYUnTghZfdWh35oarCaAJuDMy fnZP+3Eg= X-Gm-Gg: AZFdTZeEayDqwYHziF/GIGUSvfjrQzvBZjQIPIUKO8RkhysCLJucxselucMxPqREnID 7gv+ZV0rmMnNcYa1FozoNKFfXDt6BUANY5YvCRqxBJJo0pHjIh5khEDTUNaiDTaBTF0Sn2oRb4g SMGPNSRwiuxxh+h68dsPt0TWunNaX+ytbiXvLsn79jkxEgVuRqareBaoHNzWslWUiN9u2H/DLch 3uqhOOFtFeqVwg4OgaC4zoAgAKo4zoDD7IP+9IAyRylk9kNGB+zLVxkgjRJQgGLI8g7vHM+rIXU cDJNhII4alzAYvgYTUl1K57I3wdWgFHNGKL//JpCmyMCugGoOvkHVp+zMO0OBGH4pAkGAsKdWTW ydcXm9F+UD1BiPot/ADMmyeYg9mtaxabd1zcxphaezBnmyquHPuwa8pqp8tl0CR/WckfbylBxan g1c1TyvFVrbAvJEYY6PGmbzeseaE6SnviiSbXLzidqrzjMmGpCtaLSlE3rxvBEmTfRRKk062nzJ XWDpZCpOgyg6rjlEWpV0F5auFzl8bC2t45RbVvX05bSAVpwjLLFdQ8aXNsvJ951y+eeDeABfRNq aGPZk9XuZpTASUAKTomFLY9U5A077cOnDm875wQs61Z1I6RR9uZ1gCJuUxIbKoGwUagsaojPI94 8hIeIHRWCPIQUBFOW0jISLS757sRrHoDiJRqs X-Received: by 2002:a05:6830:25c2:b0:84e:4a6e:5ced with SMTP id 46e09a7af769-863f89b83dbmr6349758a34.19.1796512402455; Sat, 05 Dec 2026 15:13:22 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f8331ff6sm6269737a34.22.2026.12.05.15.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:13:22 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 7.3.y 08/15] io_uring/net: don't count the buffers of a send bundle Date: Sat, 5 Dec 2026 23:12:58 +0000 Message-ID: <20261205231305.4158103-9-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231305.4158103-1-axboe@kernel.dk> References: <20261205231305.4158103-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 f218dac1c2e0..2e1d66504266 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -515,12 +515,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