From nobody Mon Jan 30 20:07:13 2023 X-Original-To: dev-commits-src-all@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 4P5K362KDNz3cQ1b; Mon, 30 Jan 2023 20:07:14 +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 4P5K361g3qz3nsV; Mon, 30 Jan 2023 20:07:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675109234; 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=NezkjV/NjSATTat2YGcSRzQIQfxEI4iDJ4PU6GzQl28=; b=CA9VwagJj5TJYi0lKnbgvqrVXc344sg3lJJ3BTOPfuCLagw9e3vnAGXNdAyBEL4cMlgo2u l2ZvAJTLg2LImqE8SBJhOUMsUvwPiWczxi0CfYSee7wp4y4pBKPZfAhXeRu6SmRqqDXZNW a/Rshz5sWpt+XBdld+6gzJHoRwaspoxW5PDrzoQwKJr98u6m7IJVj/bwqjzaSXGfW8r5n/ jlpQraxWmNNERRcd6rdsSBrEO7hMxtqd7honuz89ouj5RotXwER3uV7a5VmsK+mTR2PrI1 l2cPEoQf3MoVHPlaQhWNSu+yI55tvv5efc0ZvP9iYZkBHuB8qUZqmzfervK5IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675109234; 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=NezkjV/NjSATTat2YGcSRzQIQfxEI4iDJ4PU6GzQl28=; b=cLvwoX0PyTwHGsBmsbzkzO777SBAMvyWYvtGhE+K8PJ8g0Z8OL/Ali08Tk59rPKfvsH9wN K+AOfmSBNsrJuK7r70lQY4MMF9osRxRKsUESrluYs9SX9UkrpuUcCp/dxgDfXKb9gS41a7 FSnGDapDACDeUe5IDvekPvRIndeiUMtIxYwYPBvP36rCiV3fmuBcaL9Sgj5yCiHdEATlsK 2wdAZiKHkcRjO89dl7cX3piJBJGjQz6GDlanaGBitzuy2o8C1bi3S/zw6CfUPra6xF6BaL iNFuYXyg4CecBMcOYBPYGeMObqLR+nOdOihUaJAq8xfN243TuzY2A4FuYZ1t5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675109234; a=rsa-sha256; cv=none; b=rna0ulPRpmrDolU/gAzSaB8+gLAg3fQy8QLs5YgRVNG/I00PKbAKRxAPJQUY5xKVMpQvLp Z94LqqERzggMdcYIQKGQ4uGw9YUTklIE3evDRuEMt7X5CdFzQh/Sm/hCU4KJRW81A6FRu3 JQgDimOqjKHIaEMZQtd0HPgM1aImGSFF7S8njNQGHyz7UzsMrB4gMaGLtJXXO+qcl7boui 4SLN8Ad+Z/Ev7aUvmR5TERmh7c4hunyF+H7QJ8kxNCftTuOkrXLiLRKOlsK9TWQKDUMU1O hQiGJNiVcIX7jW7XXUsGPLfas0tWV2OZFx7AHt0JsU+rUv+MBy8czIWFh17GmA== 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 4P5K360gVMzLN5; Mon, 30 Jan 2023 20:07:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30UK7D4v074183; Mon, 30 Jan 2023 20:07:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30UK7DGT074182; Mon, 30 Jan 2023 20:07:13 GMT (envelope-from git) Date: Mon, 30 Jan 2023 20:07:13 GMT Message-Id: <202301302007.30UK7DGT074182@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brooks Davis Subject: git: 435a2e04f06b - stable/13 - freebsd32_sendmsg: fix control message ABI List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 435a2e04f06b4cb74f41a9805d1eb0f4c30bee00 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=435a2e04f06b4cb74f41a9805d1eb0f4c30bee00 commit 435a2e04f06b4cb74f41a9805d1eb0f4c30bee00 Author: Brooks Davis AuthorDate: 2022-08-24 17:34:39 +0000 Commit: Brooks Davis CommitDate: 2023-01-30 19:22:30 +0000 freebsd32_sendmsg: fix control message ABI When a freebsd32 caller uses all or most allowed space for control messages (MCLBYTES == 2K) then the message may no longer fit when the messages are padded for 64-bit alignment. Historically we've just shrugged and said there is no ABI guarantee. We ran into this on CheriBSD where a capsicumized 64-bit nm would fail when called with more than 64 files. Fix this by not gratutiously capping size of mbuf data we'll allocate to MCLBYTES and let m_get2 allocate up to MJUMPAGESIZE (4K or larger). Instead of hard-coding a length check, let m_get2 do it and check for a NULL return. Reviewed by: markj, jhb, emaste Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D36322 (cherry picked from commit c46697b9cb97a14f61ac0a58758aab081b9e48c5) --- sys/compat/freebsd32/freebsd32_misc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index da49b4b7b415..416cb8fe902e 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -1504,6 +1504,7 @@ freebsd32_copyin_control(struct mbuf **mp, caddr_t buf, u_int buflen) u_int msglen, outlen; int error; + /* Enforce the size limit of the native implementation. */ if (buflen > MCLBYTES) return (EINVAL); @@ -1539,20 +1540,20 @@ freebsd32_copyin_control(struct mbuf **mp, caddr_t buf, u_int buflen) outlen += CMSG_ALIGN(sizeof(*cm)) + CMSG_ALIGN(msglen - FREEBSD32_ALIGN(sizeof(*cm))); } - if (error == 0 && outlen > MCLBYTES) { - /* - * XXXMJ This implies that the upper limit on 32-bit aligned - * control messages is less than MCLBYTES, and so we are not - * perfectly compatible. However, there is no platform - * guarantee that mbuf clusters larger than MCLBYTES can be - * allocated. - */ - error = EINVAL; - } if (error != 0) goto out; + /* + * Allocate up to MJUMPAGESIZE space for the re-aligned and + * re-padded control messages. This allows a full MCLBYTES of + * 32-bit sized and aligned messages to fit and avoids an ABI + * mismatch with the native implementation. + */ m = m_get2(outlen, M_WAITOK, MT_CONTROL, 0); + if (m == NULL) { + error = EINVAL; + goto out; + } m->m_len = outlen; md = mtod(m, void *);