Re: Possible incompatible change with initgroups(3)?
Date: Sat, 20 Sep 2025 03:45:35 UTC
On 9/19/25 20:23, Darrin Smith wrote:
> On Sat, 20 Sep 2025 08:43:12 +0900 (JST)
> Yasuhiro Kimura <yasu@FreeBSD.org> wrote:
>
>> From: Kyle Evans <kevans@FreeBSD.org>
>> Subject: Re: Possible incompatible change with initgroups(3)?
>> Date: Fri, 19 Sep 2025 18:35:29 -0500
>>
>>> Are you folks using GENERIC, or a custom kernel config? The more
>>> interesting
>>> commit here is 9dc1ac8691966480ff8bd9c37dd405b981b41dd5, which would
>>> surface a
>>> problem fixed by a rebuild if you're using a custom kernel that does
>>> not have
>>> COMPAT_FREEBSD14 enabled. I don't think I'd quite expect that
>>> failure mode,
>>> though, so maybe not.
>>>
>>
>> I use GENERIC kernel.
>>
>> ---
>> Yasuhiro Kimura
>>
>
> GENERIC here also.
>
Yikes- the compat initgroups is broken by some botched symbol resolution, and
I'm not really sure the ideal solution. The below patch functions as a stop-gap,
but I'm not sure that it's ideal.
The problem is that freebsd14_setgroups is only defined as a weak alias for the
FBSD_1.0 version of setgroups in lib/libc/include/compat.h via __sym_compat(). A
simple ktrace shows that it's ultimately getting resolved to accept(), for whatever
reason, and thus we end up with the nonsensical error for anything trying to take
the legacy initgroups() path.
Thanks,
Kyle Evans
diff --git a/lib/libc/gen/gen-compat.h b/lib/libc/gen/gen-compat.h
index dac8f54b45a2..8cd5a79b3ff7 100644
--- a/lib/libc/gen/gen-compat.h
+++ b/lib/libc/gen/gen-compat.h
@@ -52,6 +52,7 @@ int freebsd11_getmntinfo(struct freebsd11_statfs **, int);
char *freebsd11_devname(__uint32_t dev, __mode_t type);
char *freebsd11_devname_r(__uint32_t dev, __mode_t type, char *buf, int len);
-int freebsd14_setgroups(int gidsize, const __gid_t *gidset);
+int freebsd14_setgroups(int gidsize, const __gid_t *gidset)
+ __asm__("setgroups@FBSD_1.0");
#endif /* _GEN_COMPAT_H_ */