toa: resolve ipv4_specific/tcp_v4_syn_recv_sock via kallsyms - #1067
Open
pubyun wants to merge 2 commits into
Open
toa: resolve ipv4_specific/tcp_v4_syn_recv_sock via kallsyms#1067pubyun wants to merge 2 commits into
pubyun wants to merge 2 commits into
Conversation
Debian kernel 6.12.94 stopped exporting ipv4_specific and tcp_v4_syn_recv_sock, so the IPv4 hook path failed to link (modpost: "xxx" undefined; 6.12.90 still built). Resolve both at runtime with kallsyms_lookup_name() in toa_init(), mirroring the existing IPv6 path, and route hook/unhook and the original syn_recv_sock chain-call through the saved pointers. Also unregister the kprobe on the toa_init() error path: a failed module_init() never triggers module_exit(), so the kprobe registered to bootstrap kallsyms_lookup_name() would otherwise leak (also covers the pre-existing goto-err paths). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
) Upstream commit 858d2a4f67ff ("tcp: fix potential race in tcp_v6_syn_recv_sock()", merged in v7.0) added a 7th argument void (*opt_child_init)(struct sock *, const struct sock *) to inet_connection_sock_af_ops.syn_recv_sock. It is backported per stable/distro: AlmaLinux/RHEL 10 carries it since kernel-6.12.0-211.28.1.el10_2 (10.0/10.1 and earlier 10.2 z-streams are still 6-arg); Debian/Ubuntu 6.12.y LTS will follow. Detect the argument by probing the kernel header for opt_child_init at build time (kmod/toa/Makefile) instead of any version macro: RHEL_RELEASE_CODE only has minor granularity and cannot express the z-stream boundary (211.7.4 and 211.30.1 are both 2562, yet 6- vs 7-arg). toa.c gates the 7-arg typedef, v4/v6 wrapper signatures and forwarding calls on TOA_SYN_RECV_SOCK_HAS_OPT_CHILD_INIT, forwarding opt_child_init untouched (the original syn_recv_sock owns invoking it). Verified on AlmaLinux 10.2 (6.12.0-211.30.1.el10_2): build + DKMS load + v4/v6 syn_recv_sock hook OK; Debian 6.12.x still takes the 6-arg path; older kernels 4-arg path unchanged.
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.
Debian kernel 6.12.94 stopped exporting
ipv4_specificandtcp_v4_syn_recv_sock, so the IPv4 hook path failed to link (modpost: "xxx" undefined; 6.12.90 still built). Resolve both at runtime withkallsyms_lookup_name()intoa_init(), mirroring the existing IPv6 path, and route hook/unhook and the originalsyn_recv_sockchain-call through the saved pointers.Also unregister the kprobe on the
toa_init()error path: a failedmodule_init()never triggersmodule_exit(), so the kprobe registered to bootstrapkallsyms_lookup_name()would otherwise leak (also covers the pre-existing goto-err paths).🤖 Generated with Claude Code