From nobody Thu Feb 8 17:01:03 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TW3Cg6Nghz5B2Rs; Thu, 8 Feb 2024 17:01:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TW3Cg4R0jz4VFl; Thu, 8 Feb 2024 17:01:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707411663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oOynqtPfiCdBSaDd/scTIEb8gCFLxh1/BSQUD8RBNUE=; b=pov8V3gv/16asPLKtF2rSDITWbriD9dgx/58SjU9fkKwxm46rVarcTjOBFIzAChg6gy1/h 5ycY9/Qb4U7pyQ1aoP2MYhQuDsOex7NeaFL7J4f8E0C7duzJSradicZbyRlzbNJnia+Zz2 Yk9uLFV2ud/wJog5pmvM1lda+kToZgOm8P3kKqPMnM71Mn2ruZB7f8Y0w7aTYIDw7ZFBRu iXmcyEk/gatGfNIj7IQEmkWTSIOM1u5gKmePph1BLM7BIQKX4Mi60w/bmB49phkxfSUq6x Lz3QLTQVWZE4QG2DeXqlUpDwsGgA3LVWcwMDjojZN7VpQXSDFXMk+tgDu7C8lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707411663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oOynqtPfiCdBSaDd/scTIEb8gCFLxh1/BSQUD8RBNUE=; b=AnBivWa8KK2JxqHCDFy0p7duGW9tHd0vQXY5IVs345+/uXZ8hKJq2Te1DoLoKgzpnzNduE 6U5DBCJaCwsRZEN6lgr8JoSS68eZ3ILkAgNIx/zep84R6Y3jbf0fwahRTFdpemXB8Dst/L 3kNdvFNOo4GBK1D4Zl6p4hbmhwx1qxEyfKyKbkaYAIluI5RHeBC+w7LtAn3TZ5flYW7cmg +CuunNbsF81Vr5zfDQSCe4j+D8T4w4aZRHXWpfpPV4pfZo6vuDqfZUMTV37IbgHOkwbJQp mWR7KW+DbBJKe6A/HWYe5I+IpYcGUtoITnZ9EhjrE7R6Z4FN5vpyeQ3qiPsMFQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707411663; a=rsa-sha256; cv=none; b=SRJfiskEVasCL0qmEkcbhYjbqGOGiSbype8UL6uFFC4OByMosRTtEa+B6ahlx7MUHqG79Y CFiFeou0b7dwt19m27Q4vQ5vwanVTY6vXc3rEa3o82Rld18RwpheGqUfF9UPg9FJL9hdOB csGtN9/3PtFnJduhKMewRtugZz5uqgl7k1rD6R0jLtF4Ce1o/DlkTyOId9+QkYrVBrmT6h J0Pn9pligIwef0Zf5jLri6JoMZaCu9wZpGYxIiYTs+W3SsSN3EzP1BC3kZwclrmU1u/6kC +TS/l07FUm1l4sjKwi6WGAuCaY2N1DbA6dn3gL4J4w4LIhScQBiwWWFwPx69qg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TW3Cg3VtSzyFC; Thu, 8 Feb 2024 17:01:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 418H13iw065633; Thu, 8 Feb 2024 17:01:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 418H136l065630; Thu, 8 Feb 2024 17:01:03 GMT (envelope-from git) Date: Thu, 8 Feb 2024 17:01:03 GMT Message-Id: <202402081701.418H136l065630@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 541e6a989cae - main - unix/stream: do not put empty mbufs on the socket List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 541e6a989caec749aff7851a3dc8fb546a53dcba Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=541e6a989caec749aff7851a3dc8fb546a53dcba commit 541e6a989caec749aff7851a3dc8fb546a53dcba Author: Gleb Smirnoff AuthorDate: 2024-02-08 17:00:23 +0000 Commit: Gleb Smirnoff CommitDate: 2024-02-08 17:00:23 +0000 unix/stream: do not put empty mbufs on the socket It is a legitimate case to use sendmsg(2) to send control only, with zero bytes of data and then recvmsg(2) them with zero length iov, receiving control only. This sendmsg(2)+recmsg(2) would leave a zero length mbuf on the top of the socket buffer. If you now try to repeat this combo again, your recvmsg(2) would not return control data, because it sits behind an MT_DATA mbuf and you have provided zero length uio_resid. IMHO, best strategy to deal with zero length buffers in a chain is to not put them there in the first place. Thus, solve this right in uipc_send() instead of touching soreceive_generic(). Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D43733 --- sys/kern/uipc_usrreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index a9a7dd3a1189..80458cd6a4fe 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -999,8 +999,8 @@ uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, switch (so->so_type) { case SOCK_STREAM: if (control != NULL) { - sbappendcontrol_locked(&so2->so_rcv, m, - control, flags); + sbappendcontrol_locked(&so2->so_rcv, + m->m_len > 0 ? m : NULL, control, flags); control = NULL; } else sbappend_locked(&so2->so_rcv, m, flags);