Re: [PATCH ipsec] xfrm/compat: pass on the translated length of a socket policy

From: Andrii Tereshchenko

Date: Wed Nov 25 2026 - 15:04:20 EST


The netdev AI review [1] raised two older issues, outside this patch.
Adding Willem de Bruijn, whom I missed in the Cc.

Sashiko (netdev AI review) wrote:
> This is a pre-existing issue and was not introduced by this patch. Does
> this translation also run for x32 tasks, whose layout already matches the
> 64-bit one?
[...]
> Would compat_need_64bit_alignment_fixup() be the better gate here? On x86
> it is in_ia32_syscall, and net/ethtool/ioctl.c already uses it.

Yes, confirmed on ipsec master with X86_X32_ABI=y: x32 requests are
translated as i386 ones, so their SA and socket policy requests are
refused and a NEWPOLICY loses its template, leaving its traffic in
clear text. Gating on compat_need_64bit_alignment_fixup() fixes it; the
fix will come with the other xfrm compat fixes. x32 readers of dumps
and notifications still get the i386 layout, which needs a separate
af_netlink change.

Sashiko (netdev AI review) wrote:
> This is a pre-existing issue, but should this translation be limited to
> IP_XFRM_POLICY and IPV6_XFRM_POLICY?
[...]
> As a result, a compat task's PF_KEY socket policy shorter than 164 bytes
> is refused before any key manager sees it:
[...]
> The gap came in with 96392ee5a13b. That commit replaced the
> in_compat_syscall() -EOPNOTSUPP refusal for all optnames with the
> xfrm-format translator. Could an optname check be added to this fix?

Yes, it should. I have that fix ready as a separate patch, which runs
the translator only for IP_XFRM_POLICY and IPV6_XFRM_POLICY, and will
post it with the other xfrm compat fixes rather than fold it in here,
as it is a different bug.

[1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/5249741d-fa84-4d54-bf77-45f48dbbb169%40mid.andrii.net

Andrii Tereshchenko