From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388126; b=a3wC3w/sjHeMc6hlL424uf9nPLziNIUG4ObYPGeZA7YULIfIqwz/fDs0GAyywqN1TphO OOz6yYSXlKt7nHJCOpjUzqEs83wQggwa/Iy9juA7woDkEXV43CkoIiBOkYW5DsXULPdPp /ZI0CDx2bBo2k6dzhvTvIcpebryJUxhymAX3YtNZHNdrRGHQTa2AbV/lpVGeqGtXBFIDc 4mid5pDttZyqdyIpuXUq6okankx1OYdA5eGyRq4w4vAFw08l5jhrTaEincVeMDebt0Zz/ J9WWvvuOgzD6bUDZ+CL+EUPWd3x28VyO2OyiTDz8U1E9xE0oBZt3gpUYsRxDoAy2/Cw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388126; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=yKvBuEOR6nl3S8L22AvvuasI40nDBy3RIySeP4+g4JQ=; b=mljQflT9Tn6yquFgq5TBUymWibTI4Ciu8GFuTJ5A3o7DtmrG1d7fTzshLYYtRCVAinr+ VoGnuzyX1q2UGyqwFg6ppdHSZhvubz/nUtaQHtzgiUZ1Z2VEauw2tyz+aeP9WMBygL35C PKQu1Vhc4LnvKxoGx7LjgGALt7+CU8m2mI5+bxWOcIuSXwzl2KyBM5Oucb295nw2btkHs pzicdeGBXNJixZUQm+OZsmvYJiPdyGKqJtLbg/iMhooP9iiC1MCqdllV1rNMMFG74firo F9H/W+WwETyqg5iXL3xk4x2EjTcMDV/t+syG433NIklzxaEIMB3dVKcDm1BSp0G/Ggg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=KcKXA6HM; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1D95606A322; Fri, 4 Dec 2026 12:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=KcKXA6HM Received: by smtp.kernel.org (Postfix) with ESMTPSA id 539351F00897; Fri, 4 Dec 2026 12:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388125; bh=yKvBuEOR6nl3S8L22AvvuasI40nDBy3RIySeP4+g4JQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KcKXA6HMO1XBGTvqJw9+ok8CCVfZBHY9VL0O1bZd0H2E9NdocOda6T+hG5V1aU6NJ yx84HCsXWjQUT6ySUnzIbAdGcDebOsKbrwzl0CUOkojiikjw9pq3Gj8+aLrtBy12+e TRytTn+u1UC3AHUyDh2RbQZ0mpll0YMIELKfT7Dc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= , Jens Axboe , Dave Miller Subject: [PATCH 6.1 0491/1059] net: leave O_NONBLOCK to the sendmsg and recvmsg syscalls Date: Fri, 4 Dec 2026 19:00:22 +0900 Message-ID: <20261204100656.954286138@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jens Axboe commit bdc350ddbcbe4788158019d4d8e8e9345cb16235 upstream. ____sys_sendmsg() and ____sys_recvmsg() turn O_NONBLOCK on the socket into MSG_DONTWAIT. That is right for the system calls, but io_uring uses __sys_sendmsg_sock() and __sys_recvmsg_sock() for a blocking attempt from io-wq as well, after the non-blocking attempts with MSG_DONTWAIT have failed. On an O_NONBLOCK socket that attempt can't block either and the request completes with -EAGAIN, unlike IORING_OP_SEND and RECV, which call sock_sendmsg() and sock_recvmsg() directly and don't look at O_NONBLOCK at all. Move the O_NONBLOCK handling to ___sys_sendmsg() and ___sys_recvmsg(), which the sendmsg, sendmmsg, recvmsg and recvmmsg system calls go through. The io_uring helpers then pass the flags the caller asked for. Cc: stable@vger.kernel.org Fixes: 0fa03c624d8f ("io_uring: add support for sendmsg()") Fixes: aa1fa28fc73e ("io_uring: add support for recvmsg()") Link: https://lore.kernel.org/io-uring/a5589b66-9a20-4b1c-a0f1-1b5b31af3667@app.fastmail.com/ Reported-by: Lukáš Lalinský Signed-off-by: Jens Axboe Signed-off-by: Dave Miller Signed-off-by: Greg Kroah-Hartman --- net/socket.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) --- a/net/socket.c +++ b/net/socket.c @@ -2501,8 +2501,6 @@ static int ____sys_sendmsg(struct socket flags &= ~MSG_INTERNAL_SENDMSG_FLAGS; msg_sys->msg_flags = flags; - if (sock->file->f_flags & O_NONBLOCK) - msg_sys->msg_flags |= MSG_DONTWAIT; /* * If this is sendmmsg() and current destination address is same as * previously succeeded address, omit asking LSM's decision. @@ -2566,6 +2564,9 @@ static int ___sys_sendmsg(struct socket msg_sys->msg_name = &address; + if (sock->file->f_flags & O_NONBLOCK) + flags |= MSG_DONTWAIT; + err = sendmsg_copy_msghdr(msg_sys, msg, flags, &iov); if (err < 0) return err; @@ -2729,9 +2730,6 @@ static int ____sys_recvmsg(struct socket /* We assume all kernel code knows the size of sockaddr_storage */ msg_sys->msg_namelen = 0; - if (sock->file->f_flags & O_NONBLOCK) - flags |= MSG_DONTWAIT; - if (unlikely(nosec)) err = sock_recvmsg_nosec(sock, msg_sys, flags); else @@ -2773,6 +2771,9 @@ static int ___sys_recvmsg(struct socket struct sockaddr __user *uaddr; ssize_t err; + if (sock->file->f_flags & O_NONBLOCK) + flags |= MSG_DONTWAIT; + err = recvmsg_copy_msghdr(msg_sys, msg, flags, &uaddr, &iov); if (err < 0) return err;