From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512393; b=jcuKFfmX/obPIpQpCXxS4G72NyzySzVrw6t9qtLMxBpKJfeEokImYr0LVgedmKCQQh3K +IrjQzp5f2srmsme3VqYbDmXqeCcLwFsGjE4l9eQYxRHlPjn8a5cgYZtCAkGXexJViDlk YfGXBcBZjTVzr3U7YmSj0/wBqXJ/3XtecQuq0Uz/UaawVON5nvSR3oe7rMKRpLMaCNc4K GBELUhFgbEFUJLYw+FEApGkuCoFDbYQ5/24McAC8JIbVA/I5mkWw0JacQqeQgOy9ADOZ6 S69IFUhTB18Aj3j3RabRCLRXr7yQy7KviNbwCjArHaf+qT27zj7H5r94QUBZETEV/Ng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512393; 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=7Dn03GyHQfxWUSjP4/7z/ts7TJidZCxXPRElt4So+ek=; b=Etc6d6ElkG5vHAWoz2wPl+rMIs2mkPfkl8hwzaADR5iyScudVxKyOgxatJJhXUxg+hSP R7FMIvffbBQxfXqDduLxzWiTd6XnC/zBdmMxts0lDZ4Nr8phRv7ZquwRUCogs1CuNHuFB mdOGUGYYBtNxk1wrDBumVEeqz1BldtkOfdlcPzd3A+VAdq8qoxPsc5396nR7bJABf8CsX 52Iqu6Kb1nYokVZoyzIr9k2KdrXqDRvHIPFWCyTnUS++5S1jAAhdxXjjjb9b+z8s7qi4E /HqWRci42w6Ba1udhuHbbne3REZ/9xB0YKngKo8TvU5nkYXa4V19dnw0UDxPgNh3G+g== 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="CBhY4c6/"; arc=none smtp.remote-ip=209.85.210.42 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.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 3EC76606A32F for ; Sat, 5 Dec 2026 23:13:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3EC76606A32F 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=CBhY4c6/ Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-8629fc8ad64so1177020a34.1 for ; Sat, 05 Dec 2026 15:13:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512392; x=1797117192; 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=7Dn03GyHQfxWUSjP4/7z/ts7TJidZCxXPRElt4So+ek=; b=CBhY4c6/O8seL5kdDCaeglcte2kFZafKu7yRhCO+/aI5jtunY4SaFj38xcZ9fPXv5q NzCrOsu7B/Ias65UKlsvi8AcCFD+xrQbNUj1MMh/SVjgdrcTFi8xPjmABD9Pq/R+Q7zM Vm2KcN6zMtDF/IC/tHvgk208l9k3mtMPVmtwwtvzcJor7T02xaGi3CUHyV37kRdIsaDJ BDwJ2RoUKKEryNYaS9FDOvXon+3gWV+D+KyC2S6971DcLvJLg4uTb9XLRt0DGVVbPGQH Sfps/6yp0HQUZeLuNQqoNuvjtG0+9+4+zlkvIxTsfOM8K44yIrroDDTw8s6hdIQhAfvo jHPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512392; x=1797117192; 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=7Dn03GyHQfxWUSjP4/7z/ts7TJidZCxXPRElt4So+ek=; b=SxtbV5/F+4FdJSTQ7mInRx6U2dq2/UdkI+2i7w2jq53Cdk8blOnjGyUcwlzUVJWRai cskhboUYOs9T15zbLaab7jTNAJh8B4A4a5HS7pGSotbEwBOaRefiojtT9V9tVOstFLR/ UKcSjPimCt4AaIYAy5rgSHVJZ95QcJQDS3e/KDv7okCX1AWCP4U1DJBpphzOPHMXc6OG OxyoDLytRSuRMp962yZCeDP80QJhhSxV4H/SnvNSgKo+8WHtvBFerzuRpRgcDOUwxmmy RTQFeI0+PBYLANlQSFRvuFcxUXBNWf6SEyAGN9TrypocPcvaZ8e42hM+gaifjunu3w6o aS8g== X-Gm-Message-State: APuU4Z8vJr722Lct8wkCoIejnnD2cMKs1e9+UbAkoVmz5Tet36mBNLPe BhrlzweG3P3DJeHD9YfTz9KdpQvuXSq2vjH4qOzoNswdpHz/aB4Sv5O1oLO/PlTMpcKXt1Cd3OA xmQFbiR4= X-Gm-Gg: AZFdTZcV7i8Ll8IGBQgcJbumTMRVO44ubDa3uXEPOS9iCkKkLvQYuXY7nuzGRHN8yzs okkq8VxaM6qV/B4qUnFsdJY/3Tbi3W3XsgBwiQuVZ/8dWWHBjzgubiXQsBpI7RylioTP9+NJIMB XjrGmaqDaAwYmNCVVoXPit382TUnMRg27djPYpiond4We9/5psYc1NvesKQfdcHWieU5TBw9arq Sy9SYoOKNdwFXWI1EZVBZwus/LL1/O/BFkUMA4MBi08PsqxwgO0zKGLUdBgw8vkqgH9YEyKrt5e 2uKp7KE63nWHjUdyfrhghrwgotJZ+Hn3NRr7gBwRv0OLlKc8MZXs/22fb2WKoJSKi2Ms7YmZARh as4RkYjKlSN98zHJQAOXLjEn8WQHvjmR45bm6mK+btYkRLXbqdw4QLB+9XXY3qRp52Ybcy797Zo b4QWeFb8adee5hVaIuyAHaHms0d8xPfi/rmgOBzcpSDj3Js4CfK9Q6o0ps9a4tFwEWz+YUDkDTO UOdM/ru5QXX3N8mkpiMu/kHKJ4iFDoIX/DzndsSGhGbTj0XAKpX/fgeRwEv0yMGpCdiMAqw1Tbk qA6zqdjnP1wK89Ko9dES7vPqqvaeZKj/uOnaoCMtQtT4OfCrxe2uPCWqxxNQWfGpvrU8Az3bMLi Ssapq2T8wQAsTJF+yE+zun1O/Qa3mlpv65PAe X-Received: by 2002:a05:6830:2e10:b0:862:9f06:8655 with SMTP id 46e09a7af769-863f89e1b7fmr6857581a34.8.1796512392248; Sat, 05 Dec 2026 15:13:12 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f8331ff6sm6269737a34.22.2026.12.05.15.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:13:11 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 7.3.y 02/15] io_uring/net: don't copy msg_name on a recvmsg retry Date: Sat, 5 Dec 2026 23:12:52 +0000 Message-ID: <20261205231305.4158103-3-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: 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 d9eecff5a935..f218dac1c2e0 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1116,6 +1116,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