From nobody Fri Oct 10 17:16:21 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 4cjtgn6zPMz6BcrX; Fri, 10 Oct 2025 17:16:21 +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 4cjtgn5TDsz3g91; Fri, 10 Oct 2025 17:16:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760116581; 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=XIsrjq5+0yEPqwdMCyuyMCygDDSC/xcLdOCFkB9COlo=; b=oTKfSiFB5rZaYr+A6N97S88Zu8yfUQ+NSigokWJz47RaHcMBdNQB6dcJnof/nJ4U26tlEA KI+mW9X5DoVwu3c18LR5c6zTR/6Zhjwdiq2Dwd9AWZrLQEmBMdjJo04ugU9XJFRoto8uM/ NYq91Ros1u7ICpFrgcx9LK9xRDy2LcYkS5SrFugTXocGQK1YabI2zJZvbLhvnUzx+OJIP+ WxzkUhgJRrUE7Ep3HE4j7I77CPerLRb37Dm3hsTT/eOLDyJlPdk0HkgJcWdOaszLY3PBi9 jgrBsplDVbieEi+nx6ksis+ocZjiZ52ZBmIlwo3kme7Peze6J5CvDsHSeP9OXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760116581; 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=XIsrjq5+0yEPqwdMCyuyMCygDDSC/xcLdOCFkB9COlo=; b=FJ6uVloSnMOUhVqRl1HRh1Di9/HRd+E1fhVEDlxnvt89dNTYQTXCpNdtyDlsSxSz3qSOO3 9V8xdbDQ/bXGzP3LbEC0j2nicOaMp7jhzW3TyDLZnhbpSOSsZ+62O/emKit2PZD54Be9/w Wm0n67tJIwAP2P5oF+mHVdtJkU6rlPB3Ya/nFKOcN3G/7ZCGIioQiDvPDxe2yjwvv42EGB DmDxTDG3aYL9sY7EbpxDqOnSI8XmowQyy2UzcyQaxuflpob/VzPhP2SFBcTWyN05GKrvXw GTUom3ozxDf3ogc05Gp3mkwdwDqcAliYIVvHIUGmbzC4xWpYGL6t5q0pgAoVHA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760116581; a=rsa-sha256; cv=none; b=UjQdzQ2DfL75RLrZ+kpBv9OCUWfu8dq3Wfc3fBFWM1DfIa4yE6TVFkgRy8l9g9VB/mMYoY KlkNhx+FgQXnNb6Ym+Nn8ORUg645MKIWOZMwnRjbOLzmAxgcW+Nn6gUR73R3J8YxaQ/3sc aoTUNGwERd57n1jV0FzWAZJA0baTozH2VEW6Cspi8FSD1l19FXvPBfazRSVRfYagzQ8VN/ yw6sBvWlEZA2dSDkvln1yQ56hgUjGT5gy1Dx7lYq/wLD0nj3fO+2DTMhpOp2xh1n3haLx7 Jeu/QRPPTaSDkiRotTJk16wa0DiKuL53B8FBBDWSBf6ToxtSBOxqguNy+tVaDg== 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 4cjtgn4j76z1Bnd; Fri, 10 Oct 2025 17:16:21 +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 59AHGLNA009246; Fri, 10 Oct 2025 17:16:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59AHGL5h009243; Fri, 10 Oct 2025 17:16:21 GMT (envelope-from git) Date: Fri, 10 Oct 2025 17:16:21 GMT Message-Id: <202510101716.59AHGL5h009243@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: 1086299d7abf - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 1086299d7abf67440668513bf387f03a8c667c21 Auto-Submitted: auto-generated The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=1086299d7abf67440668513bf387f03a8c667c21 commit 1086299d7abf67440668513bf387f03a8c667c21 Author: Olivier Certner AuthorDate: 2025-08-29 08:26:59 +0000 Commit: Olivier Certner CommitDate: 2025-10-10 17:15:57 +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 ee93ba9a6034..50e960528bf5 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -2178,6 +2178,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; @@ -2196,13 +2197,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); }