From nobody Wed Sep 17 12:19:11 2025 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 4cRd9X0zbpz67HsY; Wed, 17 Sep 2025 12:19:12 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cRd9W5XpGz3W60; Wed, 17 Sep 2025 12:19:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758111551; 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=EGsqyloQozuUdMOCFGGBKlvpbY944sDuUAZzGYMowCE=; b=mnUHZ8DmBjTiUF+YWmG9blCxE4hZ74xtMrpPMc1PkHvmG9gKdKRac4d8NAGkEJBwARvz1q P81+Ww/YK/0bMHwtsLgFeOYV+JiSyLmfqdZDh6HxxxKp13Qs46+IlqxYccWFK114szgLWK 7piDkGENgG96N3W48duCw39Nu1aCyolFUVDXfDdWZvhRRfClTTkARtm7oQfYazBwm3mFgj uL9JlvH+25/IR3s9rMaOwNIBsp2FswMdhVJXuvpnqDIQ0AUYQ7wDvuorG57N2/MRwW2l93 vQ0i3ZzyRa3klJiXokRqF1b6ednOL4VT+nrcto2mo5oD/sgOd9fDLYg0C382ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758111551; 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=EGsqyloQozuUdMOCFGGBKlvpbY944sDuUAZzGYMowCE=; b=JQwpq/TZAlLhUxniCQ3iyC0DtDNtt3uw4rXCTzmMO0TyLxWn4SUUpm/S2i2612G9xcBxA/ 13TejpLZgsj8+uXnkyovnPOT+SpaUh7YoaC3VNY/O3fNlJEhvqrYPKysrFpP0HnpN2Pier HVNH9Xba0jG2SqFZmdTmcCXcQKjtVAvRqnAulIveSeam3E6YXC4cwjpvDqVjhPvC27LGE0 KKJg8U/aRuq+wRXjZPOXE5Ww78xdec9sL+z2VQ+eV7uav9MGmQJagwim6HE0Tf6UiaYx4D 6D2Cwn8eYaaSq05lGa/gURGeYZy406vwoDTiqxEL2e4QiMnuCjfZmTAwR50+ig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758111551; a=rsa-sha256; cv=none; b=oRWUgyh9ZXsZa4U811GJeOTY94LqgdtqcdLwQVFT6s4G/PVuBlDh1bEMu1+5uZ7BtZGQqE 2iSibbKgDcFMdCZufIaWi0PbbI1TWDd/mSlF4rPVcg4I/imcF4bOP0RCnMEsZXeZzyZHHN wy+ZQPk0HrhUZCVLtX+9empSdi2+uDdOkFVNmRKGu55bDSkMO9mThztX/Z7aQ4EooQHwhb Sg1HwfiTpmD28cQFov9ZoFVaiys+36oH8KL+qnGRq9Giu4vESbNVVBpJ37Z4kvGSRzYQZT IP7FUitI1DBDNRo/D4qFlcjrHK0PId7gvAIm2kydJ88WwtaQG4PGjxwrW7O65A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cRd9W4lNsz9Lr; Wed, 17 Sep 2025 12:19:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58HCJBR7085957; Wed, 17 Sep 2025 12:19:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58HCJBun085954; Wed, 17 Sep 2025 12:19:11 GMT (envelope-from git) Date: Wed, 17 Sep 2025 12:19:11 GMT Message-Id: <202509171219.58HCJBun085954@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 10b789d7e148 - main - linux: getsockopt(): Simplify exporting groups a bit 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 10b789d7e14862c77f77f07e8af84d73d73012c6 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=10b789d7e14862c77f77f07e8af84d73d73012c6 commit 10b789d7e14862c77f77f07e8af84d73d73012c6 Author: Olivier Certner AuthorDate: 2025-08-29 08:26:59 +0000 Commit: Olivier Certner CommitDate: 2025-09-17 12:16:05 +0000 linux: getsockopt(): Simplify exporting groups a bit No functional change (intended). Go through conversion to a 'l_gid_t' before copying out in order to cope with differing group types (except for not representable values, of course). This is what is done, e.g., for getgroups() in 'linux_misc.c'. As Linux's group type is the same as ours on all architectures, we could as well just stop bothering and copy out our memory representation, eliminating the loop here. Whatever the choice, though, it has to be consistent here and there. Introduce 'out' of type 'l_gid_t' to avoid performing "by hand" array arithmetics when copying out. MFC after: 5 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52280 --- sys/compat/linux/linux_socket.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 539d153431c4..0e07b0a60ced 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -2179,6 +2179,7 @@ static int linux_getsockopt_so_peergroups(struct thread *td, struct linux_getsockopt_args *args) { + l_gid_t *out = PTRIN(args->optval); struct xucred xu; socklen_t xulen, len; int error, i; @@ -2197,13 +2198,12 @@ linux_getsockopt_so_peergroups(struct thread *td, return (error); } - /* - * "- 1" to skip the primary group. - */ + /* "- 1" to skip the primary group. */ for (i = 0; i < xu.cr_ngroups - 1; i++) { - error = copyout(xu.cr_groups + i + 1, - (void *)(args->optval + i * sizeof(l_gid_t)), - sizeof(l_gid_t)); + /* Copy to cope with a possible type discrepancy. */ + const l_gid_t g = xu.cr_groups[i + 1]; + + error = copyout(&g, out + i, sizeof(l_gid_t)); if (error != 0) return (error); }