From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512403; b=15iXll2C6Y9XGJro/u5OMu+T+FY8pQ6Zgz2ddtpBr/rP7B8expDnDlQpVOb/aJMY8QQM 2e4k4GsdzRUztsXnY0q5AHTqu5LNFFKBn7CkIbct6CFpheWvBTi1st7zWXk6hBiQR223U TJ4AbvAuamEfaYqPi0IfYjy0xzYXFrIALVCVmh0B/+HST5v40xBeVan/4aTSwD5qx4DyK 9/GLgMK5d6BzHuAo9tbgz42c8PEHTGCo8kjpsj1wcRfFWbwTxbkHDHsoxiHchS5wp6Fy0 9tuq+njXuI1klj+4vJVEu/A4FIvQTTQSNFzqAlHxWCi3lE/lrMjBc6GWzssQm5HPTzw== 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=DPNvpxPpbApWPVITz0j/jyBNyyAvaDcbALwhRlBiXn6A8DTCuVGPKmLLdeKW+NyK5UR9 1g0PDsixvZHiuudNXQuy7RDPEJ9sAi6s5TmwuXt5VoRfXzFvtp8AvEwfQpwU8IzvYeR/c +FLleMDdmtY5oMbiu2+1lCpnZcyWFIqK50XDzsX9mEpSNj+vABkHjDJ7n/d8PJpteo0LU SWwEED3YW12QJH+dmzUc0pIZDQpbiE5XJgjCX6zThkMQlRIv3pHiuIsud9k1c1o6wocJL rhAaRkN2eqOA882bCjhhZwkjO/3C7xXw5rCwbKQfXEvmozLvMSoho38fV/otMtfEKnA== 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.43 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (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 5EFD8606A31F for ; Sat, 5 Dec 2026 23:13:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5EFD8606A31F 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-f43.google.com with SMTP id 46e09a7af769-843b6f8e2c7so3245923a34.1 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=lRgfnnGYwHRxfmuNZSEJNWZkRt9IbF4cYwy9kUtcIAjKQxxxTCxivAzxNshfe3dxcE NXyT5jZhV1M0hyyxrTSegvepaRb/tDQAMUv2OG7XZrE9AWxG1mk1bYugDrBGFMMfEdj/ y8yZZLMU5XBO+c55DeTGO/kB2NG2MoVNZthyEfpTM1HFkna9nDxUDq4/zEHOFB1pY4d/ tohcf+kkkXfEtPoUPmME7eSYYeldcGoOLJpo8Gr2BAbO8MydKLrpE3Vsh0a3FGV2THxu lXVUgE0Zz52fV2ewFQg6BWnABt7RfCJ+2+YHm40fVxzon+cNPGy53dfj8Q17oc6AKXhr 85tQ== X-Gm-Message-State: APuU4Z/QxT0aeU9pPfayjfLnLWe/9vPQFd5B4elcU5re0rwbyMoHbI65 VCqB17u1v3+pQSK09gByilAv8CDK0Q3pzt11Ji6d72eW3UcCrbrS2XVSyY3OTgFxMKXST1qpY+N yKO3Nvfs= X-Gm-Gg: AZFdTZdaO+ns+KWYsnWrpsNq4WGiNV7Xd9OK3kjxtnhISIk1ACoKCsEYBGpqFuAxTjC vK2GIRqQotIGQEE/qhfwEJ6tf1un16+LIsFGJXwCi5be3y3HY9KK3AAW1K7BN2tFds9KdzmgF0G oxT/OUwHDbdIjRY6wd2iD9MQx50NqTpNOeuxU+HsFQndrD5hwhXBCrNBV6+zvHZGbn0Vm30ep4M YEbYYiLjErFcYpzAtTO1BpvMxI2uqYA3DR/4pAm7rxuKLfo3wGQmvHlo7xFixpmQXcILXxt9Qok ELlvMyeucBlHqRGkmEXwGzfJcvRVFuaWxjK8D46d/K+ww1DCoUmRLCzxJv+Pi+67TH/a0lBvvUy FniNW0mmXNSgL8gJezVhgIONfZcA8DyaKub87rt5eT9Hp4ndx/SAByXXIwNFjdQcqkHnasygqTM 2PtI9a6TjI00hdpOievLAH9MwUfzT9hTZYNSbnuxEXbF33tpnvVvNNU2GvvFMo0wSXyo+YO1Ile pgwGguyvs/h++xzSKKCH0UUDjfK1X+4jDfCBz5Di5EGdHNijHaZkJXjwkL6dD3wJCQY0qzWp31W OOTs38+dLCm8yT+bfahohHOFFlRe0QuW7/zZQke+gXXpGCATDYdbuS1GWz68XhYzeGXZ+PZYm9O QzRQYie97PEY6kwUl091ZqeFbdI47JYQDlngC 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: 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 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