From nobody Tue Sep 23 12:03:43 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 4cWJXv6ypvz68XhC; Tue, 23 Sep 2025 12:03:43 +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 4cWJXv3nFjz3F2h; Tue, 23 Sep 2025 12:03:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758629023; 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=nGlmNKGxSD273gTD2TuGOUIq9HoruRMTtGqxR9kfMOQ=; b=kyHH2WBEW8QzosZ2CHxN9tfaL5P9fTdueI0T2g6bS3yPALYPzhTsyYjnKJ/XnNYoDzdmEi TR0xjN/ibkVryHiYA30lnosDKkfhsRvQu4kXTL/TF7YMW4MkxEIxMgiKU1Psagr5vCjy0P vLZeOLxQrImynUt2v1GHv6nFyhPuxzpQHBQrD55DYTA1L5rJDi1t3rYDxcizfMpbSJGl7I 49t342QAEYOdHXOJVHZvIkW+EewJjKjPrdWO/FsPXyPOJSEa+kR8Zr8gWSAMiWrRf5V/Tm LeiUErbRkpJRPgCuLIN1lYbyCYCo19MNxXgsuuRivaY+C9ckF2qiXK0goE7qCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758629023; 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=nGlmNKGxSD273gTD2TuGOUIq9HoruRMTtGqxR9kfMOQ=; b=L4V4eeJ99Ynap+EACWkx3GEjBqHsMJdAHaWYEEpmLlHe9zaA0R7SUt+/12i9C0wgBYKzoZ Ko2MQl/dP8+rtE5VS1PeEs7Ndz2nA77v63Q9nk1gZ7mdcYh5BV868j+yFhYUA4PuccCupT +EEJoy29jyhFL/NEjLjzR7byrmrGpmTyTCGBngJDA8BqzrV22g6TMOj0rKGH1M1XXSHyR4 ErCizvMCKjzamGh3tgood6yNOTYoW+L85xTqATe01TAphURiA/qcRkO7S71S2SAn3qIqww s89msU2laBHVxDxrFzrHVmRivnXYEX09RknUXtDAtAiAcJNa6S3kxWWV0qYTUg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758629023; a=rsa-sha256; cv=none; b=mDLTuVt8UqEQ7QlKr8CIx5sK7oOoEKxUcbaSQtQZpye/PYpEifHEgG/gTnDagJIs/6vL5C iQ7Zx9hBGdW4nxt9qnVhLlfObNYGwGlgEM2QdRw27yJmfCHUCyKMNo+Tfg+HO5Jt9RprO4 cGH3Fq8/Jktto71qHPAjWcWrwp4LvxDE0hV1SXK4LpM+6d6NWEQtqBblJqJ/Ht27spkc0a O/GYFjYgMLuAXH7gvSi1M/s1RQed2ahgQSiO2DQUu3QNwOwE1QfEyGdo9BLWfhaJL5nyP9 3SuFGGVV4ocTzVf4KUsMYLDoROFcG+f++HVFtF6vGD+m4XKr2JSWeEN2mShxDA== 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 4cWJXv36B9zlfR; Tue, 23 Sep 2025 12:03:43 +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 58NC3hAe008758; Tue, 23 Sep 2025 12:03:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58NC3hHG008755; Tue, 23 Sep 2025 12:03:43 GMT (envelope-from git) Date: Tue, 23 Sep 2025 12:03:43 GMT Message-Id: <202509231203.58NC3hHG008755@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 5eaee33a2a70 - stable/15 - 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/stable/15 X-Git-Reftype: branch X-Git-Commit: 5eaee33a2a701ef86026338fbfa9dda4634e3b2c Auto-Submitted: auto-generated The branch stable/15 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=5eaee33a2a701ef86026338fbfa9dda4634e3b2c commit 5eaee33a2a701ef86026338fbfa9dda4634e3b2c Author: Olivier Certner AuthorDate: 2025-08-29 08:26:59 +0000 Commit: Olivier Certner CommitDate: 2025-09-23 12:02:45 +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 (cherry picked from commit 10b789d7e14862c77f77f07e8af84d73d73012c6) --- 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); }