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=u6LAhkMA2zYLp4OKbzdO/4QK35bIB0jaAYsNPwG/QZ286HaGHlmo6eYXkCt3xT/y3HV3 Tu5N7uUyXhLdM2lvQwaDM8hwvL/mZ6TYEUCevnkY2mf+rmrXBcoa6rb0TuarfJUXcVIYI 7L4pp088d7OKQ2Sm+NYZW647bMXwg+OKsqSV/W8ojyG/+vvt7KpJHooXd5TrDkf+TdE4k dhk4Lj0mIgz+6BCMeCtVde2/FWWbHkDjVNZCzwfr1w368c3MJdKrlt25aS47FpB7lW9KH SfUW7v3OyOG9Qhp+Hahp2j115x0GxmWd806KYqjswfb/LIaHcZ7C1rJlkIvjxk/4ydw== 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=WZJS+u10V32sqQJ1ZM/aVrt0aUv9t0xfuEvkeJL8Yq9MNuizrxmN4s/QSfWEOzDDrX5e v9IqjAxs+Uq+FO1F1vYS7AIMJ/y+U/KM62rxvzHt//g4yQihmQnWiNwe7fw3qjyWAeIkE bOZENi+mfFnFZrCbPYPknm/EJBkEOvvCAmOsdfGdH5Ol4iY11SpcHVfmp/y8wSrcYYBV+ fQAU2pfOUX/i1S6D35CR12zQgmfzsgVcXaDKHgoltSyUjmik8aass1F3v5Rz92JSLAn8B qX0Qjc9iTv3SyJooaVKSMiq+DoEgZJpegjpqGBavOjEKagX++J8iYSDEXxWViRXqCVg== 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 A8DF3606A335 for ; Sat, 5 Dec 2026 23:10:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A8DF3606A335 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-84a248254f4so1376449a34.0 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=AKcLhOMo2FTHkMkyuvzQtDprPNpku9dACMovWl1ai7d4/BKA9xqhhkRDQb4mrRBI19 FLADmvXcqI0PgEyGiWCf2Vr6nY6C3OGed6XRPqn2cIn3orfu6SomTpm/3S0D592UOyl2 E7Z7uQhnl8cQLSl0ej1ofXwDSFFlRUwcN1II3iYMqAB48J+QAZd82/e0baDbtftNClVO kV69mYpBlEiUqtszTTVOuKDTlehggtoPo6OFOwldRWEB6x+ITjwQ68etegeqNHpS/lcu GIE4MgsWQgYbfWJ0j86Nog+TLrWQyo/xok0I7xNHAizEgxgNTFHjM/h2v80qZg6h06zs E6pQ== X-Gm-Message-State: APuU4Z8zzBC6B3u54UUVXdLnM7n4d63ubFf9A/X08w7Rbc3VA09vIZ/i gPB56AxlhAciskc5ivBHIm5bOYFmuJVMiBi25KH2EQ+hI8KCErEhvpqhsl+xCJ2l8UhyNdY4XCJ z62K7Y5Q= X-Gm-Gg: AZFdTZdOgb0alzroOjzQUaSPitgzpLmz2zskk/D4gWaaAZbjPYlOxEuldpHShUmVZKD 52wCpfS8fAKSZqV/KppzwYFM6abGZjIz0c4uZ0uffe6LOSFNy1kbdAlx7b1EQogcvfkuTV7tgBv j7h4BTdPTVH7/tlucnQvSUj4kPmqTXjpEZ722SsI6/RFH2gDGQgVk8ngMoaupW8gXzuPYqmZ/ak U51VL8gDenLyiB53yJdY9dyTeMgkHDr7t2nQDfUKPMtGin0E+XT5V4R52BZXdDRX+IAct0C/m+O Y59TuXq/EoOPs6El1T8gSorsVZuQcIhZMziusHlVUsTUKHQo9RNWdcTf1JVXjRthyEJ+KcWc6WB lL7CGmSqfMP38kkWapx5RBxlBs74PLkP8lgvc0QRWtYRHgbq2yut2fck8OqwOyD94FkCPefypHB oKu4DDlBkFFEthe5mPafQSdy9Wuse7wrcTOVIuUxTL/FmEzvbPzdrCD3QgpD4qeURl4iPbggBqH TCfilfvJuqPYLadPTsEjE+IB/flAr+SDLYXPxlXIaMwkFCCHUCmn/lGU53Zc5QcqTa9a8lGwhAh IREqI/sewBNGipWM54nTLtgIs+39mxi0RycSRLNlHd6Fvq9vR4qvuL07XDDaBZXgPG/Etu94zVd u/+18R6S146sh4v9Ht3P7arZGgb2xo/Tic0j7 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: 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 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