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=1796512328; b=yYITXIGMpnMk2QAVA+TjfJqwiBfTm4TLF4hbjkOsReoAQqMhMjEhdeQlokAtJFQALFzW uoCcExGMnRCVnfiKQcsJz0IeNqiA6hpzIiISiXumjfJfr9aMLApsyvyNVsWAK0zFcwVgw yWJIp1Z47UTbcVZdbHSBHQJKK6Yxw1t9av3oIjiQzaBvvFPq2/IT0kaD+4UF7HtFw5dDJ mxWALa+NlHmtBexrhyGr3CN/NxQLmLYox2qnfKo0R9wU4CZkboA7OI8uvmSdKR5G4NyI5 ufYfXnvdweU4sixyDCOY75ofk5x1fqQIaWTyTnotn3Y2eSrvqqzG8iOhQ5/bHJGTLUw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512328; 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=Mj5d6cpDNOJ8IMNM/FrFlgtOpiZT6rEKeNGdh2ieXt0=; b=y/gcMS/U+kRbjJqFjTxyqsvx1EGHIffnh47aXp9Z5150LABVXWIC79KL62SS7BmLSkGC zrte2R380YH8Www5EXSE32p0s/3zzcrGYXU7k+8C4qi6yMZx+HfPxmPGna28q0B5upN0M q7qgBMq9mZl8vMpf06yrV/AaIvxiCCYJt+YVe9TDmc/vA8vLCpl+AZKChEBTH2hCypZIT 4kgI2Pp6nS/eyRN/AD8bvjpowPCcXU+/Qht/HT9SfRE94Da0G0S1zZzo7okfPHCJJBNLO ZG02xMac2b6Cq8XwQinLrHnkkcCXUk1XNIeuKDhszZMKoFbZ+cLLPWULlLxi3Y9mpPA== 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=cmGtqllz; 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 96A9B606A31F for ; Sat, 5 Dec 2026 23:12:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 96A9B606A31F 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=cmGtqllz Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-4a76f63b243so2640916fac.0 for ; Sat, 05 Dec 2026 15:12:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512327; x=1797117127; 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=Mj5d6cpDNOJ8IMNM/FrFlgtOpiZT6rEKeNGdh2ieXt0=; b=cmGtqllzDo4iW4eRzqlbfjgQRxOba1k29LtrEC1mIuqwrp9vlYkp7Itp+i+lxWh4yD qalZ24W9lCb6OoV2al21e13/JZGk7rrZZSw2O3A30OVvqn1t4DFZCKf6fFVYN8zWEsI+ 6Sv+Mk+Ok9pUqF1ueR9aB/eRKSW1/cP+UcR9UBsyMt0CYV7yWgQ8Tds8jd+dhlQesTmG vWcJE4nOfJuwE6/CYdsE4ZOAYl+DuNfGLG6QZd7Tgs8hrM40x01fSCaIcICCXMGw2J8V 3HM2rI0L2DEclS3pzFg6UPodqfX0d5Mq53tbfuMCzH6e6kOEZ4D16xQst6cwdTyRPgqP ntCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512327; x=1797117127; 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=Mj5d6cpDNOJ8IMNM/FrFlgtOpiZT6rEKeNGdh2ieXt0=; b=T8k/8qUkpmM5CWH6LTCehReS1t9jrpp00rqEXUjjw57a0C7YW5y66KHuBoSgDfjF37 K6CL5xC4QoXCI2XjrVtbvFxqiAl03SMd61Ldcy7MY3E0BZuRFtYdygYHCI+vm428M9h8 hEJx92TSUy1xS2JyodWUaY2yJnjSHF5MMqV84l8q6QGwddmyFiQz4HnzYrXRTiRWGQUq bQAuhobDaas0bvNLHzK6oIwIbC7KZPSRKHZfQyXtpNVgbm9N87an5b58vjDxXLOgxgpY 6yc0bdXIiXuOPiZ0LJenHY5T7v5H/IKQQdWdVZbpArjzcNofovNmaPF9B7KJhPllOgW/ o7kw== X-Gm-Message-State: APuU4Z/nq2yP0ft9v3B4nzh3fYt2gXKP8eH3wk6P1BUwfZlQpduarMTF 0MjLVkP5wbpTjvod2h4wKmzST599bYD08p7+OwUFaRWJ6o/syIiYaYhYRQtuQrgecVI= X-Gm-Gg: AZFdTZc61qcrAx+hWD0Sdm9wdATDrO2hRx0UnJpR+weA+o99nSJD8jWZvWUlePYMm8n l6PLvn+ItyVzaw7dgsgUVgBvw/7JSSh+it0hSodEhy994a880pKX+tIN787s7AMvoorVi08E9XE N8OjqkKpH5lgTymtBYMX/5XlyDhzQDRFtj14wN1HRX/TMy5qaittqencgddMtX6mJ4Sa+rsvsd/ V4nK1qIW/WhJiyfjFVxI5psoNPIavvwAsjDC+wLciFZMdxOu8o+FklVRWOiuTBV3HoyQs545RCU TXf18vmJyW/3l4BeHjU3x8Oz+fMwjdc/VzDc0C8ItT7kVJo6zAFurftozQOvPpmIYQ2ocw8DLiH 5mkzSizXMMneG91w0DDPhah3b20pYcpeKObPaxS8lq869RrUuF0FED/ThSew37IRGemfBo0fVkx 0itlREcNVGXqEliZ0EngCVQjaBpsF3onqxdOcPHACRCkpfjxx6pNbvUHft25CSvnJIRCeu2yIJs 8QPBVaEKbCdPWR4k43LG8waobHRSEGEP/P4CkoKc2l8Q0Sd9PMy7KWmeY+hopC2CLMxBPtrWAsh Yrg01xTEZ055TzjnU+PCTIepj7RCm+t4LLRXlqTK18LWWtwAbw6Ds2k8LDbpxuASxvSVR/cGA+G 9ucCHcBaxYEfbNOj4G7wTmar5J2hfHFEqOCKYqg== X-Received: by 2002:a05:6808:4487:b0:4f1:a3ac:a637 with SMTP id 5614622812f47-57f20811306mr4383822b6e.27.1796512327663; Sat, 05 Dec 2026 15:12:07 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57f1f6fe2ecsm4086916b6e.14.2026.12.05.15.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:12:06 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6.18.y 09/14] io_uring/net: don't count the buffers of a send bundle Date: Sat, 5 Dec 2026 23:11:42 +0000 Message-ID: <20261205231147.4095031-10-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231147.4095031-1-axboe@kernel.dk> References: <20261205231147.4095031-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 fa70b07b73f8..09ef15e0700e 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -533,12 +533,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