From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512275; b=KvvqPQpidAowBLgNxK0dB53gFVVKPyv/oaN9mZh4sWNBWw5yiWzZNKyS81K8b9lRmtnC I69oIZ7MyJWyxOo6u0QA7o+2hpMxiDz8Wb9FZOq2MDZEmjv21JHKwN64pdPy1A+HtOnzc pUlBhvC9kboOHmKoe6BMESz0n0vS9F0beJygw4IxCsPA7RI1omwregVzqkFB2iyhnb2uF 8Oqmka9CKnTidhqs5Ok5RBtKqhxVwuCAQ3DxrEGtpNfeLcMt2d/DfYZJU18nZJ3N0MB1s 9SJEQwCcbElis2sAii7/zNRS9rfSgs0AAzSdzgVB0T2AvI8WT50mFeX44Yy8jqFHHHA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512275; 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=0sjjJR23xrOroqPAQsYZLm+c4j+YulBlBg8XhbQjmZw=; b=iaHAc9Q5RkbbE4ETm/G+b91lToXKkjCvXzTS5CmaP9vr5xES7uVDgNdS6mKssk48CCuF Cj/v23pzXwEFZSE8+h2uTXEwy81TRyhDlswh2n107eYCstwKKCrIoccIbBf6fXgGA76dX J8bcvPcC+0o25Y0bUI0MiC34ZTt5EfmQxBKTVH4ANCzVBVwWuV7pkj0aj7jhTHRQolsWG bAEzYdFvLRwuzTgk71AQNlkp7NlsVQGoZzZwc5jpBj8JaeuKQkymiDTe8xYsdgkmjVx4v BBqwlwVX+9XsmWQi92d3o7ZjZOv21BDA2vE+rJftrxIPor4h2u+62OgeeOUzBlMsu0w== 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=gf7B8hgN; arc=none smtp.remote-ip=209.85.210.48 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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 11129606A31F for ; Sat, 5 Dec 2026 23:11:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 11129606A31F 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=gf7B8hgN Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-862a5b64755so1180415a34.2 for ; Sat, 05 Dec 2026 15:11:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512274; x=1797117074; 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=0sjjJR23xrOroqPAQsYZLm+c4j+YulBlBg8XhbQjmZw=; b=gf7B8hgNAUxrrBhLQLLawGNa0Np/oHM+fPDAfM1CAc/E78fKEwrepCiNzUGI7bsOC8 D8VfDWc9CVsvMbiFaLQETddNr2IDLey8odF/ehEaCO2zT7YKdU23B85WWAK2jjJa1MMh gH91SgcJwiFdgZZAXb+aJ45IvH6ePFYsdomupmr3B5jlbyNNFn4EWXu5kLpauIbFCntU 6OEBcc0JHq2fDtqR1Cm2hlvMMjvSjgtJA8/6MPrf8GjaofypZWwUHZDjniBXrG2ozpdy r7Erf6wmlXw9OkEw/qsgWqPrcLeu5gIn0xlgtnvyBzaeJiYBEUSjOmMNQlMamhc4tpvO O+sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512274; x=1797117074; 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=0sjjJR23xrOroqPAQsYZLm+c4j+YulBlBg8XhbQjmZw=; b=Z/dLit6TFHkG0eCv1dS5hQcaLpFmzyVc7I/Is2cELnXyQl36NOTxqRSmesSIGfemvz 0da8/HegkHI6M/h0t1v26x84/yghXsmbkN6wE1VpzENlWo6qAz/9kOZZ22FoN1ZAMUtK asEJw/jsgjVEwuqcac0gBrA9x9+tZlw5984w+5Cpjl6dgFcURtXhj19NJmpg7CmtORo9 lZlGQxM1NQzcymdRvW/ddO3/xlp7ftcSVfYr6J/UuJ5HNVuZOuyGK1qdKXoR3RTR3Zt2 n+hNTAwlyCR0hP/YZILZXI6oTvhqko64WZ7qsdCtCxTkvGUXcRNTYSi9OIil17XGEq3I +JHg== X-Gm-Message-State: APuU4Z8PcTCOJiPPfbrMq0fyBNch1rP23SR/fbtJg+KvPRZ0B8yRBfN3 sao/ZHm8e2RkCre2g0tCB3nDq9EFD+jpizjnp2WG0ZscL9OifPzbpHtKcsubyKkpgWMOqyqMa3P EN/TAoaI= X-Gm-Gg: AZFdTZfj/SGDPUFwnkwweGCbkfDhye58SGb3/bFY/MQkWJ8nmARW4BlUMbMVcsfPvZY MsoRsfI4OXSCmrKpjGwYgElpOW0Vf6c1DXa2ENp+r5BBxPn2jA2eYknrgAJHQ/pMtdy5mQvCTDA 1UiwbpKuHDBt/M6tbzT35yUa940ufJKSoO0nQOch+625QKLn/gmopcGF08WkIPXxRr0QAOUlA0+ 7J5XJ1y+cxkwQzCTmS1O6/wNKYw52jQ9wCSKYj8WtKhg9wO0TqUeXa1N7exS672HQ18LmyVqc5d Rip1f2P5TqYdXjKJyrvirozN1HPDyxrx3jzsWR/pJDa9taHqYBXZECAq0F4LckWuYk1FxkmqJ6f 84BRmizMFgj0kwVCDvR5vuc87uoBU7z+rvZU1SAhAWIP8W+d4lHEHgqb3sWqIIRmvr4fr0tN8RN 0esl/z8/VbPSF7B9jWcD6+2zODbAY/jD10aHkUaxwdoAZ6wZDGgykqPZa9KCMsLziNKd0o9ZaT/ QkJDr7vIXRHC7Pc0a5su40hsXeXvjWAvkc3LOs2VJg0iL9oIjZQpL7ZI3hMOxYVqmaHWC49K5dt htApsDvS/SMmEl/iPghL1826Ztt1SwR1AA8e67eLJYcehF8o5kaWarewXtKb3Fq9O7FwbVmGa9S dklZogNBZaEgmVRnJSTUnXnOC4e9QIkX6GYMKsQ8lhA5/m3JUjEbs1SVJHQ== X-Received: by 2002:a05:6808:3091:b0:57e:8312:4dc1 with SMTP id 5614622812f47-57f207f523amr6584306b6e.25.1796512274070; Sat, 05 Dec 2026 15:11:14 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57f1f65febbsm4163964b6e.6.2026.12.05.15.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:11:13 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6.12.y 02/15] io_uring/net: don't copy msg_name on a recvmsg retry Date: Sat, 5 Dec 2026 23:10:54 +0000 Message-ID: <20261205231107.4023506-3-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 bbdf19889585f036692a0c77a1402a37cf07c417 upstream. IORING_OP_RECVMSG with MSG_WAITALL can write past the end of the user's msg_name buffer, if a partial receive is retried and the source address is longer than the buffer. msg_namelen is an in/out field: move_addr_to_user() reads the size of the buffer from it, and then stores the untruncated length of the address there. So the size is valid for one call to ____sys_recvmsg() only. But io_recvmsg() passes the same umsg and uaddr again when it retries a partial receive, and nothing restores msg_namelen in between: msg_namelen = 16, AF_UNIX source address of 110 bytes size read bytes copied msg_namelen stored receive 1 16 16 110 receive 2 110 110 110 If the copy in the retry faults, the result of the request lacks the data that the retry took off the socket. A retry that hits EOF has no address, so it stores a msg_namelen of 0 while the buffer holds the address. And an address that is longer than the one before it is truncated to the length of the one before. The fix used here is to copy the address out with the first part of the data only, and to leave msg_name and msg_namelen alone in the retries. The address is now that of the first part of the data and no longer that of the last part. The two differ only if the source address changes within one request: on an unconnected SOCK_SEQPACKET socket that receives from several peers, or if an AF_UNIX peer binds between two parts. A program that passes a msg_namelen smaller than its buffer got the whole address from the second receive on, and now gets the truncated address, as from recvmsg(2). The retries also no longer reach audit_sockaddr(), so with an audit rule for IORING_OP_RECVMSG the event of the retry that completes the request can lack its SOCKADDR record. The event that keeps the record is that of the first partial receive, which audit logs as failed with -EAGAIN. Fixes: 7ba89d2af17a ("io_uring: ensure recv and recvmsg handle MSG_WAITALL correctly") Signed-off-by: Chris Mason Signed-off-by: Jens Axboe --- io_uring/net.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/io_uring/net.c b/io_uring/net.c index 53773b0d5276..cc92e892fb53 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1108,6 +1108,8 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags) if (ret > 0 && io_net_retry(sock, flags) && io_net_kbuf_can_retry(req, sel.buf_list, kmsg)) { sr->done_io += ret; + /* msg_name and msg_namelen are filled in, leave them */ + kmsg->uaddr = NULL; return io_net_kbuf_recyle(req, sel.buf_list, kmsg, ret); } if (ret == -ERESTARTSYS) -- 2.55.0