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=1796512219; b=h5LwomG75JubqBxkGgXM2zYJdAR8HFZwC+q61p9suG8AiMCgKyLLRl4navR2pUN0WXKi oqbunKnO3WCKtlWIW+P16Jl/PYNddn21FLKs0J4aVQqeLLegjua5egOQG/npOP8BwtLl6 qRFwQEcE9sHqvqlI7rFIXwbKkgEmEIhU4O0VO+bJdqLYgK9D2sVtrfGBgtfMVs9GQhQWb xywcV6ZmPi87W+QC4W9NPDQHJreo7OR/ScM5krCsZXXkOFLA4SiAPFcvEKf8qDL+yfBNQ NLwerV011ybu2TX0KK1vWFb+N3qKmozVfA63/ShVBkXCTr0RWBQJVg9BUUnP9frrz5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512219; 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=NWiro5g7luS94z1X8pNDHmx5v42eaqdUWaehjECrhos=; b=Q0/FeJ+go7i62PY4JOSncneV1mPIic76+v901q+tjTAQf4uFAcXdux1fKNWXifKd0SV4 O3p1CXHAdbDhOOjKpv9PvM5N6hP44/KXWbDNgkUZMcj2H8IGlis2ncf9cssKkitBQv45G XSGGwHrb0RWQTCIGnFBChsX2AIdQWRZ7eF49uL9xecnLCywqbX7i5GOeiyvW1RU2LgILD KEVHgVMF/j5VNhk6sxWk7GpCwjJCF7sTSt8GSRaDClq78PmfElQGDmQ4SYCroijTY2dcO /VhTiq3zx/7C/xo1mAzaMS0o3ZEYBoB7ry8h8KMLKh6oaL92w3d9fAEFKeYy5vT/7Ag== 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=GvVxzW56; 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 A8D45606A334 for ; Sat, 5 Dec 2026 23:10:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A8D45606A334 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=GvVxzW56 Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-847ac7ccd85so1209411a34.3 for ; Sat, 05 Dec 2026 15:10:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512217; x=1797117017; 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=NWiro5g7luS94z1X8pNDHmx5v42eaqdUWaehjECrhos=; b=GvVxzW56BKoSHWY0hNb/V0yGHH84J0xBqPuW8adfiJJRXvppBeE7xei1x1mwwnxpkF FzVYLpw5cFQRGwebvbUz0PlQshIpDyp+PG1qEMxiBRJzobk8/yAaJK83HJw47HUvJzil 6LxEYpl/wTVOB0p+RkLOE6izy2xjUBFyOSOWSeBd94Mdpy9xC5C7Wo6s9uf6NgXP9lEe aVe5Cg7ogHvoHjR2huJXOvne99nBNNFFplREkK+0Uir05TJ6XqtzUzWtLxBPmor5nrNt c28uPj66NcpvhnkPlOy9vWWB0aQR1ebzpcGnwb0894yEeWv12fdlqZ2dAP+zhCiTJvE1 W61g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512217; x=1797117017; 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=NWiro5g7luS94z1X8pNDHmx5v42eaqdUWaehjECrhos=; b=bEu9B6X1DnYg5fJv5RfhvRTjvIKpast7Qxkj22pTXuNkm01JoLYqOEsFqyK3g35Zrp YONKO9S3vlsXXy7Z87ymmJzzo4HlZSSP+GuNn/Dy9wSYabWmJAjuRCc5Zqg3h22zlH59 oR08Eo9fmPFqyFO60PDnSIfT3KIM02nxtWf54k9UL9vcklHBrOPr1nm7IVf123lorQbx mbc9jk+DK2loYk+LmtAwrfRxmUv9Owfmz9Ihj8FeqIwYPha6LikGRsB0qgj+SESnrREF 4OwWasFmLMQCki+p+DQ1J+p7RQWbP0KJg+l5GmcozInZGWg7T4bN3+45/y0x0BJ63SyA KrRg== X-Gm-Message-State: APuU4Z/GkiDmT+Krnvklg4D7aEhQzyu/KpShlHLVLcbPAbQ7Y1O0/g/Y FF9ioAA9xZmyZZj1jLtdmKvHDNeJt0dvY4DLg/rMXoenaS8iBldhqGaEwwvEWs1N0dJn3H9G6bt LBWRj2Hk= X-Gm-Gg: AZFdTZc5gwBy9vOCn9SiiPUlZbg+RLB0gdM52QdDVJ05tiL/eQAvCScVqi2RCrcMjYc /GAT7CGnXl5Oy1fMqnUhafdQmrc7WVgYg56IbjnZkBqXAg3Bki63xZo4jyAMHzC+lK4yXKLQNvS a5YXGnC4w6E16RccQu2finbBnNjfRS+XNZ/djUM98R1aF0rhiVdn9p1+6serN5JG+9E27E5DSn/ jBJTUeksUEJT/LKLKkbK/DFozvhmmrjrDjTSyWv9U33sTuK+a5UJAlRe74SvbPj09h1PAD5eBPK Hrfjyy0ssbf0daYXdWNTYVDQTwyrbH6yNw1m8nbKW9/pORv3gRr9hfTKlta7ysJn/6qCbJuYsAW sZn4PQB0zqEIURqnQixwxGw76Ywt7SA5ci5YE3hz21ZXlm+fYb0oSRuUojjfORPNCS9LJz73W06 yBVRHGyqfWvlpJucEPQMgfUU+gfHaocfDHQ1VvboNQOpq90dIfvHsRyWqGlqZ31H5uA4nE5Juy8 sVvwULCPywHlWSHWdc0xFORoPFzVBtcjAh9swvJGD7vWvOJjQcxlDXvE1+4COIxHjKAfcP7kb4g i6jgfrMYcSUqdyIuaVkmKf5NKj0VdTcyB4XemcAa7sPmHYRk5luiiGipxEGBDJJLmKXHzJQqc1k bUzGw9C2L5/ewXmKsESgWXrjA2kg63CY3L/TD X-Received: by 2002:a05:6830:4c18:b0:862:c4ae:7fca with SMTP id 46e09a7af769-863f8a0db53mr7225926a34.26.1796512217599; Sat, 05 Dec 2026 15:10:17 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f8313082sm6309624a34.16.2026.12.05.15.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:10:16 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6.1.y 1/9] io_uring/net: don't copy msg_name on a recvmsg retry Date: Sat, 5 Dec 2026 23:10:04 +0000 Message-ID: <20261205231012.3977993-2-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231012.3977993-1-axboe@kernel.dk> References: <20261205231012.3977993-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 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 669cd54cccf0..78ae996840c2 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -849,6 +849,8 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags) } if (ret > 0 && io_net_retry(sock, flags)) { sr->done_io += ret; + /* msg_name and msg_namelen are filled in, leave them */ + kmsg->uaddr = NULL; req->flags |= REQ_F_PARTIAL_IO; return io_setup_async_msg(req, kmsg, issue_flags); } -- 2.55.0