Skip to content

toa: resolve ipv4_specific/tcp_v4_syn_recv_sock via kallsyms - #1067

Open
pubyun wants to merge 2 commits into
iqiyi:masterfrom
pubyun:fix-toa-kallsyms
Open

toa: resolve ipv4_specific/tcp_v4_syn_recv_sock via kallsyms#1067
pubyun wants to merge 2 commits into
iqiyi:masterfrom
pubyun:fix-toa-kallsyms

Conversation

@pubyun

@pubyun pubyun commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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).

🤖 Generated with Claude Code

pubyun and others added 2 commits June 30, 2026 00:34
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant