From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512360; b=YA5Vj0vzaJ2c5irCeAv7X35kH1exWRAxFuDdQJQdN1FSGV0rkih36sFTpLe3tj+IJl67 lC2d+Qsj36oWp2n7nitqn3QxTGsBarW3hGjevF6IaBsv5QW1Z48Nk0yiLya7DZX9UstJl ISYNkE0y9NmLpO+o7eTsPr42v7Vg78VnRT8J+bcpkJ8cAu0hBardrrgU4AGG3sxkmLy94 fWSnqLn79tkgRLIxTvJ7HvELKOq6vPLAnsP78jpIo5OdLNshnprmKANdSDsoK1xZHOSQX XuEjrVDEIN5LcCXsIDr3WgVuZSVuXJzW1RFApPfG7663zKu3rv1rhx61O9F1lxGZKrQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512360; 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=HSX4ExF14mVsZ47ucDMvMVz2EkG9yFLQwDYHikOjQt8=; b=lIvcQfpWOjoHthCgwL/Gv6vqxcu/jlJij2LsXd6J+3gjtalRvS0UJd6RG9ybOA+Sjmsr 15YMxhiSozfdY4yFOwE36BMB/pTijPRY0/zew5J40iSVsFivRjDCbgkIICMpEGfPxKlyo 3HtJ4W63CWOmZkobc1OUEKvc7eEiV3G+YzlHq0XN6GlllF5D/BLQhagZ48Dn75ejYvFnJ 1DfG2dZhw9NpkMgKgd8lN4Pk4LbXTvza5sx/gpkGeUdQNCIq3JpBSRXN/2IBhGoqOmgSg tKlxhlOTALYAYqJq4skZj7SIv0+YRMdj41x81UtDvPzolV8Kfe+OeuICgrcSzkyBpdw== 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=QexvuHmf; arc=none smtp.remote-ip=209.85.161.41 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (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 B3AFF606A686 for ; Sat, 5 Dec 2026 23:12:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B3AFF606A686 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=QexvuHmf Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-6df5e315bd1so2205880eaf.2 for ; Sat, 05 Dec 2026 15:12:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512359; x=1797117159; 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=HSX4ExF14mVsZ47ucDMvMVz2EkG9yFLQwDYHikOjQt8=; b=QexvuHmf5b/7wkaXjd39MoLRM1XBvMtraf4effHLe8T55C7iQM7YBqOY/pulaxekMK 8+Ay81YZE3eDpiz/wkvQ/7c8TRwuKvwfftgUfB0949BEi3CoEcfQPupV3RwMQYUJ6W+l wOfQjhANxr0qSFH2B68cApJduS/U1z+Wn3BrB1oUj8m6JqcZ3tG+xDIukIerA2UKcp01 f81PeQQpjGwimLSzbwpaGT5nOtkWSspAMvTgEWoVQcrIvlSyoXWoCFz6t0YdwuuC2fHV uvlzfZrxMOQghriKV+7ibG+Qxr4oaVkkwcBe5RWegTF/cF+CMbaQl4ya/s6R9eVxgemU W8kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512359; x=1797117159; 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=HSX4ExF14mVsZ47ucDMvMVz2EkG9yFLQwDYHikOjQt8=; b=vvmycwKTui094wv5elpLe72ZtFuDwaE0oYXYzZhImCDswnTNdOQdyeBcRqdZESNKaT 93F+i4dDkhOU7xWBgQtUrep7WxM8pU++cNN2ElaQul0Ph4SUNiREJTzB3BPFmT1RVazH 2a022eZsMiWdqx9msU4dAipvLqCaipXIdFmk+FID+DPoIG5uaFJ5SdVJ1MhRSERYlWsL 2l+YDY/s1+YQUahgMLA0LYefCrJjofeYlKgD8P/JK4TTGGXXitFuSrIVkx5JLQCKMuyj cjS86Bh1ZnVxi3wJqRhCDt21PrFG+cwPqKCQoo6LOIhjMYrF1taUI1oE1uN9UObtU/8x xV3Q== X-Gm-Message-State: APuU4Z86T1pzEkkWyHBC/osfPMg0hopV6lR0b38HZJ4h/RuRmLqkSVJD b2IXXmXhppQuY71cx0H/E7akPYu/l0S9zlhu8I77qtwPMIAMYnhl6+yLa4fvmVEztnSLGGi9ti+ pnrzkKA4= X-Gm-Gg: AZFdTZfV/5KOO6tJH7Gdd/URVUW2oVbo4NXoKhWUYVgfGeV9ND8pONb0gnXXDgVXoIk aaV41nvfTUzu7s6kW6wF33yTzooi/AZNDOKamqaFMaGInYdLCEgKy9sVKBiJnDqKE903EJ7V+2v sWvtyWtCdSDGfw305xEUt9d6poB8thiEmmOnTKVFqaRDpsU+Pnr4lXdcXrNHa2tJmbwGPophBg0 x9DZ+I1oFf4wptXsUet0wNL+ZF7lwuCvyIuNEt2DuPDTERvb4j0Y78fgSOjvCE4DlS++OmobWtl D9OXrVnXTpmWXVLZUEOdsmyBi0Pxo1/60tjp9E15XtJarMpaFX/dApn9Ef2W4fpCa2XYvdKbld5 S//Q+ghNW4atrX0HJfrKI+93PtUHWIUjEBVLW12DTwmJi1wuXi7lPSKZpbBkUt6BQr6hvl9im7a FYAtmFnEbz9TduwHVqCxzf8DvUWCW0m2Hi3GIS48biVFFzVObzFXD4WcSqBGOkYJdQAb5dfwm/T o6jlBtpjZuWdXFWaZuClBH5yeYrjPjlCVWcNbjyuavEkPVuHm66FKBkGQbbiJrjn+ph6s4mQmlk ddux0IXCcU3d+H9e3kXThzWQoi52+ak00JlNET4+rV8DYPLJxM5alx29a1neWyA6EWwKn6I/ep6 BUxXB5ajOqInJ2pu6Vjn867plrN6jY5Qbm3pb X-Received: by 2002:a05:6820:704f:b0:71a:fb85:d07b with SMTP id 006d021491bc7-71bf207bd13mr4404705eaf.54.1796512358679; Sat, 05 Dec 2026 15:12:38 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f7dd42a8sm6279788a34.0.2026.12.05.15.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:12:37 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6.6.y 02/13] io_uring/net: don't copy msg_name on a recvmsg retry Date: Sat, 5 Dec 2026 23:12:22 +0000 Message-ID: <20261205231233.4140988-3-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231233.4140988-1-axboe@kernel.dk> References: <20261205231233.4140988-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 67a9cf004e13..3705b50673eb 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -899,6 +899,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; io_net_kbuf_recyle(req); return io_setup_async_msg(req, kmsg, issue_flags); } -- 2.55.0