From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512292; b=q6X9I2CXgSDnzMLuN9a08wdpUS/O693d+8okpdJChSSl3dq2hvB/7x+hpjVJd4PWgAuF PmTYvVlGvtT2/j9yom7d07H/E/alXrSfM+OEaUSnUySxKzhNDHq5rwrlNvuwNn8mXLAgg 3bc3cFg68ZX11JFFSIfaZTYM9mC+pyyLm/tqTmkhixZcWddZHp7ZiOxG2bScXXLV2XvaL 6NOc/toRX1mGJZm9wITXgM9LMtjPuGFRX2ugf5TpvrxpYvvx6/+ffup0XdHbNyb/rCDh6 kwkjxSQy59nhyTc2Vivxx4BeyeDURYX12NUPXqYBqJpNQ6UgJ2o316P4aPn/aj0BP4Q== 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=2/rcXOfuuxmXiFZN+mFfwDOsr/idkPmGSXRB5JsGaJKeUhH03PI2ZBxsY8MboX44K0zs B6Kl78fNLTuXeiSUa8X/JhFLC1kvbh0eb9qixBa/aEZQWsEvvQohAfmjc51BLFuijyqbw lbB7oj7E70Rvuya834aFgMfGyFMEjrvvAYXYhLDX3UsDDV8B+tDPQTixN/0J44XtyXrfB tTnDTOyH+b0fj2r4TE2+L5u57Xqk9dKa3dGQDF3WAHx4DqAq94g8Ct0UEMIS8gGU1QFe0 FPEfqqs4OKbYqC3pqs0ISAyjCl5CkVdTrn4GTGmkRH4tTcZBPkjPmZ9JTGPRSuNaV3w== 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.160.42 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (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 19B08606A32F for ; Sat, 5 Dec 2026 23:11:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 19B08606A32F 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-oa1-f42.google.com with SMTP id 586e51a60fabf-4a76f63b243so2640681fac.0 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=nafbDvsTug4wJeKRHcrF9X3tV+BC6cZ5oI350TBiBfEZ2kXQqWs3Xl7495E5jpQoBk xIjWhmM+BeEPacVvUdHdSy6QnTocV+XB9ogVePl684d9myIepsHqMYL6QkTYjMFJeqoG 3NhogEtOXQe7ULBapHg6R0SoLTdbEWdQgqrvXAy3kW/2Ibv2XAcSqGwnpQk19owsa/aW kG93RT38VZRBnkCjSibb8bGN+UQmhZZiLpAM4PUPTIbcXE3J7/KeOxkaTdy0fvvNnAWB t2uP9BarLRWkJV0ARnrVvhA0nmNOqnUeHoo6FsamXtUl5o06xhMVQz6mxX8v7QpsioeR LQbg== X-Gm-Message-State: APuU4Z97iK5ta6uP4zXla8vgQjlohwJ3zTRXktHSXze/o/iMayxZpPPs ykIFGEFiULHgHY5G727w22rkX9dWC+sqVriwh0aYz59OHg7KyC9z3QnKvLrCD/5LpUUVOSAX22c 0abWZk9k= X-Gm-Gg: AZFdTZf1FcUFSaH1BkMbfNDgKDEKI9sI6Ut4IiKBzmF1kpx7QkQTlTLGxg29rwb1Sw8 Dwgs0HfAPNUQmeWhn07lJEawe8zjIEZ+/RIyFiJT0ib3fMWKfz6/h3gAihvV3lA3YO2H6LRBMxs M9ZLxJmNgkfbt5WNUvk+8ZIEyswGWAA0upgSzeTPqhwvJRvYaJHsXprgan5PVlF06EbmSVwHMqF 4k0Ua854OrNIzVrDUCR8oWEjI6USLK6rbKt6y0qCIL+LvPsqKtc9DU4MFyUtxy224YRJOdx/8xr o7e4h66ljTrA0a3N7d8Bq1Z34KQq8aGcVsTd14ITSMWlTC5mjS/xa5RTw0i1u95iN4oMv/dLxok uFdL8hgzqWn7g+D9Yc6JuZE31AtsUDccyBQ+28uJjjEZ92haE2VrAhMCFWqjDX15AFmU4m79hPs jGPkabxFBrPGWKryaI5mdPZRSKAbW3FzUpuNsPa7TrVKS5Co2MoywF+fiEErm76aqKTAa95m3mP SdUqq8OZhqzQ2sVNPCvbV929mKivIj7ZrCLC9QnMAiTjIO6fQr0cAYeWuC/WV4W5znsB+BQHUEu xLqA6rUpmC7KBTXE2covKUsIEwViQeDv41V+jemsNBS0iPkBGqmttLpUyUDqt8dGkrsKb7x5bZe XpZZa4d72nTQZpVeW6QLvRbQm8DbK/zVJcr7S 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: 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 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