adapter/syscall: fix ioctl conflicting types compile error on older glibc#1048
Merged
jfb8856606 merged 4 commits intodevfrom Mar 17, 2026
Merged
adapter/syscall: fix ioctl conflicting types compile error on older glibc#1048jfb8856606 merged 4 commits intodevfrom
jfb8856606 merged 4 commits intodevfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On systems where
sys/ioctl.his pulled in transitively before thestrong_aliasmacro expansion (e.g. Amazon Linux 2, glibc 2.26, kernel 5.15), the LD_PRELOAD adapter fails to compile with:Root Cause
ioctl(2)is declared as variadic in glibc:But
ff_declare_syscalls.hregistered it with a fixed-arg prototype:When
strong_alias()expands,__typeof(ff_hook_ioctl)yields a fixed-arg type that conflicts with the already-declared variadicioctlfromsys/ioctl.h. Whether the error triggers depends on the glibc version's header include chain — on newer glibc (2.38+)epoll.hdoes not pull inioctl.h, so the conflict never surfaces; on older glibc it does.Fix
ioctlfromff_declare_syscalls.h(it cannot be handled by the genericFF_SYSCALL_DECL/strong_aliasmechanism due to its variadic signature).ioctl()inff_hook_syscall.cthat extracts the third argument viava_argand forwards toff_hook_ioctl(). This matches glibc's declaration exactly.ff_declare_syscalls.hto auto-generateioctl-related symbols:ff_linux_syscall.h: explicit declaration offf_linux_ioctl()ff_linux_syscall.c: manualpf_ioctlstruct member anddlsym()loadTesting
Compiled and verified on TencentOS (kernel 5.4, GCC 12.3.1, glibc 2.38). The error can be reproduced on any GCC version by manually including
sys/ioctl.hbefore the macro expansion.Fixes #942