lapi/xfrm.h: Include system XFRM header and force kernel IPv6 definition
PATCH 1/6 lapi/xfrm.h: Include system XFRM header and force kernel IPv6 definition
--- include/lapi/xfrm.h | 4 ++++ 1 file changed, 4 insertions(+)
include/lapi/xfrm.h +4 -0
@@ -6,6 +6,10 @@#ifndef LAPI_XFRM_H__ #define LAPI_XFRM_H__ +/* Force use of kernel IPv6 definitions to avoid redefinition errors */ +#define _UAPI_IPV6_H +#include <linux/xfrm.h> +#ifndef XFRMNLGRP_NONE # define XFRMNLGRP_NONE 0#endif
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/6 xfrm01: Use NETDEV_SET_STATE() to activate loopback
--- testcases/network/sockets/xfrm01.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
testcases/network/sockets/xfrm01.c +2 -8
@@ -27,6 +27,7 @@#include "tst_test.h" #include "tst_net.h" +#include "tst_netdevice.h" #include "lapi/udp.h" #include "lapi/splice.h"
@@ -72,14 +73,7 @@ static void setup(void)int i, ret;tst_setup_netns (); - -const char *const lo_cmd[] = { -"ip" ,"link" ,"set" ,"lo" ,"up" ,NULL - }; - - ret =tst_cmd (lo_cmd,NULL ,NULL ,TST_CMD_PASS_RETVAL ); -if (ret) -tst_brk (TBROK ,"Failed to bring up loopback interface" ); +NETDEV_SET_STATE ("lo" ,1 ); keyhex[0 ] ='0' ; keyhex[1 ] ='x' ;
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/6 xfrm01: Configure xfrm using direct netlink request
In reply to Martin DouchaSome kernels may not support ESP-in-UDP even though the necessary modules are enabled in kernel config. Rewrite the xfrm setup using direct netlink request so that the test can check errno and exit with TCONF if the support is missing.
--- testcases/network/sockets/xfrm01.c | 87 +++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 24 deletions(-)
testcases/network/sockets/xfrm01.c +63 -24
@@ -25,8 +25,10 @@#define _GNU_SOURCE +#include "lapi/xfrm.h" #include "tst_test.h" #include "tst_net.h" +#include "tst_netlink.h" #include "tst_netdevice.h" #include "lapi/udp.h" #include "lapi/splice.h"
@@ -44,13 +46,40 @@#define SALT_LEN 4#define KEYTOTAL (AES_KEYLEN + SALT_LEN) -#define XFRM_CMD \ - "ip xfrm state add" \ - " src 127.0.0.1 dst 127.0.0.1" \ - " proto esp spi 0x%08x" \ - " encap espinudp %d %d 0.0.0.0" \ - " aead 'rfc4106(gcm(aes))' %s 128" \ - " replay-window 32" +static struct xfrm_usersa_info xs_payload = { + .family =AF_INET , + .id.proto = (uint8_t )IPPROTO_ESP , + .replay_window =32 , + .reqid =1 , + .lft = { + .soft_byte_limit =XFRM_INF , + .hard_byte_limit =XFRM_INF , + .soft_packet_limit =XFRM_INF , + .hard_packet_limit =XFRM_INF , + }, +}; + +static struct xfrm_encap_tmpl esp_encap = { + .encap_type =UDP_ENCAP_ESPINUDP +}; + +static struct { +struct xfrm_algo_aead alg; +char buf[KEYTOTAL ]; +} aead_alg_info = { + .alg = { + .alg_name ="rfc4106(gcm(aes))" , + .alg_key_len =KEYTOTAL *8 , + .alg_icv_len =ICV_SIZE *8 + } +}; + +static const struct tst_netlink_attr_list alg_config[] = { + {XFRMA_ENCAP , &esp_encap,sizeof (esp_encap),NULL }, + {XFRMA_ALG_AEAD , &aead_alg_info,sizeof (aead_alg_info.alg) +KEYTOTAL , +NULL }, + {0 ,NULL ,-1 ,NULL } +};static const uint8_t original[DATA_SIZE ] = {'T' ,'E' ,'S' ,'T' };
@@ -68,23 +97,37 @@ static int pipefd[2] = { -1, -1 };static void setup (void ) { -char keyhex[KEYTOTAL *2 +3 ]; -char cmd[512 ]; -int i, ret; +int ret; +struct tst_netlink_context *ctx; +struct nlmsghdr header = { + .nlmsg_type =XFRM_MSG_NEWSA , + .nlmsg_flags =NLM_F_REQUEST |NLM_F_CREATE |NLM_F_EXCL | +NLM_F_ACK + };tst_setup_netns ();NETDEV_SET_STATE ("lo" ,1 ); - keyhex[0 ] ='0' ; - keyhex[1 ] ='x' ; -for (i =0 ; i <KEYTOTAL ; i++) -sprintf (keyhex +2 + i *2 ,"%02x" , aead_key[i]); - -snprintf (cmd,sizeof (cmd),XFRM_CMD ,SPI ,ENC_PORT ,ENC_PORT , keyhex); - - ret =tst_system (cmd); -if (ret) -tst_brk (TBROK ,"Failed to install xfrm ESP state" ); +memcpy (aead_alg_info.alg.alg_key, aead_key,KEYTOTAL ); + xs_payload.saddr.a4 =htonl (INADDR_LOOPBACK ); + xs_payload.id.daddr.a4 =htonl (INADDR_LOOPBACK ); + xs_payload.id.spi =htonl (SPI ); + esp_encap.encap_sport =htons (ENC_PORT ); + esp_encap.encap_dport =htons (ENC_PORT ); + + ctx =NETLINK_CREATE_CONTEXT (NETLINK_XFRM ); +NETLINK_ADD_MESSAGE (ctx, &header, &xs_payload,sizeof (xs_payload)); +NETLINK_ADD_ATTR_LIST (ctx, alg_config); + ret =NETLINK_SEND_VALIDATE (ctx); +TST_ERR = tst_netlink_errno; +NETLINK_DESTROY_CONTEXT (ctx); + +if (!ret) { +if (TST_ERR ==EPROTONOSUPPORT ) +tst_brk (TCONF ,"xfrm ESP is not supported by kernel" ); + +tst_brk (TBROK |TTERRNO ,"Failed to install xfrm ESP state" ); + } }static void try_corrupt (void )
@@ -227,10 +270,6 @@ static struct tst_test test = { {"/proc/sys/user/max_user_namespaces", "1024", TST_SR_SKIP}, {} }, - .needs_cmds = (struct tst_cmd[]) { - {.cmd ="ip" }, - {} - }, .tags = (const struct tst_tag[]) { {"linux-git" ,"f4c50a4034e6" }, {"CVE", "2026-43284"},
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 4/6 lapi/udp.h: Add fallback constant for ESP-in-TCP
In reply to Martin DouchaThe system constant is defined in linux/udp.h but not in netinet/udp.h. Define it in lapi/udp.h anyway.
--- include/lapi/udp.h | 4 ++++ 1 file changed, 4 insertions(+)
include/lapi/udp.h +4 -0
@@ -23,4 +23,8 @@# define UDP_ENCAP_ESPINUDP 2#endif +#ifndef TCP_ENCAP_ESPINTCP +# define TCP_ENCAP_ESPINTCP 7 +#endif +#endif /* LAPI_UDP_H__ */
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 5/6 xfrm02: Configure xfrm using direct netlink request
In reply to Martin DouchaSome kernels may not support ESP-in-TCP even though the necessary modules are enabled in kernel config. Rewrite the xfrm setup using direct netlink request so that the test can check errno and exit with TCONF if the support is missing.
--- testcases/network/sockets/xfrm02.c | 87 ++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 23 deletions(-)
testcases/network/sockets/xfrm02.c +64 -23
@@ -26,9 +26,11 @@#define _GNU_SOURCE +#include "lapi/xfrm.h" #include "tst_test.h" #include "tst_net.h" #include "tst_netdevice.h" +#include "lapi/udp.h" #include "lapi/tcp.h" #include "lapi/splice.h"
@@ -46,6 +48,45 @@/* ESP-in-TCP frame prefix: 2-byte length + ESP header */ #define PREFIX_SIZE (2 + ESP_HDR_SIZE) +static struct xfrm_usersa_info xs_payload = { + .family =AF_INET6 , + .mode =XFRM_MODE_TRANSPORT , + .reqid =1 , + .saddr.in6 =IN6ADDR_LOOPBACK_INIT , + .id = { + .proto = (uint8_t )IPPROTO_ESP , + .daddr.in6 =IN6ADDR_LOOPBACK_INIT + }, + .lft = { + .soft_byte_limit =XFRM_INF , + .hard_byte_limit =XFRM_INF , + .soft_packet_limit =XFRM_INF , + .hard_packet_limit =XFRM_INF , + }, +}; + +static struct xfrm_encap_tmpl esp_encap = { + .encap_type =TCP_ENCAP_ESPINTCP +}; + +static struct { +struct xfrm_algo_aead alg; +char buf[KEYTOTAL ]; +} aead_alg_info = { + .alg = { + .alg_name ="rfc4106(gcm(aes))" , + .alg_key_len =KEYTOTAL *8 , + .alg_icv_len =128 + } +}; + +static const struct tst_netlink_attr_list alg_config[] = { + {XFRMA_ENCAP , &esp_encap,sizeof (esp_encap),NULL }, + {XFRMA_ALG_AEAD , &aead_alg_info,sizeof (aead_alg_info.alg) +KEYTOTAL , +NULL }, + {0 ,NULL ,-1 ,NULL } +}; +static const uint8_t aead_key[KEYTOTAL ] = {0x00 ,0x11 ,0x22 ,0x33 ,0x44 ,0x55 ,0x66 ,0x77 ,0x88 ,0x99 ,0xaa ,0xbb ,0xcc ,0xdd ,0xee ,0xff ,
@@ -58,35 +99,35 @@ static int srv_fd = -1;static void setup (void ) { -char keyhex[KEYTOTAL *2 +3 ]; -char spihex[16 ]; -char port_str[8 ];int i, ret; +struct tst_netlink_context *ctx; +struct nlmsghdr header = { + .nlmsg_type =XFRM_MSG_NEWSA , + .nlmsg_flags =NLM_F_REQUEST |NLM_F_CREATE |NLM_F_EXCL | +NLM_F_ACK + };tst_setup_netns ();NETDEV_SET_STATE ("lo" ,1 ); - keyhex[0 ] ='0' ; - keyhex[1 ] ='x' ; -for (i =0 ; i <KEYTOTAL ; i++) -sprintf (keyhex +2 + i *2 ,"%02x" , aead_key[i]); - -snprintf (spihex,sizeof (spihex),"0x%08x" ,SPI ); -snprintf (port_str,sizeof (port_str),"%d" ,TCP_PORT ); - -const char *const xfrm_cmd[] = { -"ip" ,"xfrm" ,"state" ,"add" , -"src" ,"::1" ,"dst" ,"::1" , -"proto" ,"esp" ,"spi" , spihex, -"encap" ,"espintcp" , port_str, port_str,"::" , -"aead" ,"rfc4106(gcm(aes))" , keyhex,"128" , -"mode" ,"transport" , -NULL - }; +memcpy (aead_alg_info.alg.alg_key, aead_key,KEYTOTAL ); + xs_payload.id.spi =htonl (SPI ); + esp_encap.encap_sport =htons (TCP_PORT ); + esp_encap.encap_dport =htons (TCP_PORT ); + + ctx =NETLINK_CREATE_CONTEXT (NETLINK_XFRM ); +NETLINK_ADD_MESSAGE (ctx, &header, &xs_payload,sizeof (xs_payload)); +NETLINK_ADD_ATTR_LIST (ctx, alg_config); + ret =NETLINK_SEND_VALIDATE (ctx); +TST_ERR = tst_netlink_errno; +NETLINK_DESTROY_CONTEXT (ctx); - ret =tst_cmd (xfrm_cmd,NULL ,NULL ,TST_CMD_PASS_RETVAL ); -if (ret) -tst_brk (TBROK ,"Failed to install xfrm ESP-in-TCP state" ); +if (!ret) { +if (TST_ERR ==EPROTONOSUPPORT ) +tst_brk (TCONF ,"xfrm ESP is not supported by kernel" ); + +tst_brk (TBROK |TTERRNO ,"Failed to install xfrm ESP state" ); + }for (i =0 ; i <DATA_SIZE ; i++) original[i] = (uint8_t )(i &0xff );
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 6/6 xfrm03: Configure xfrm using direct netlink request
In reply to Martin DouchaSome kernels may not support ESP-in-TCP even though the necessary modules are enabled in kernel config. Rewrite the xfrm setup using direct netlink request so that the test can check errno and exit with TCONF if the support is missing.
--- testcases/network/sockets/xfrm03.c | 87 +++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 24 deletions(-)
testcases/network/sockets/xfrm03.c +63 -24
@@ -36,9 +36,11 @@#include <linux/sockios.h> #include <net/if.h> +#include "lapi/xfrm.h" #include "tst_test.h" #include "tst_net.h" #include "tst_netdevice.h" +#include "lapi/udp.h" #include "lapi/tcp.h" #include "lapi/splice.h" #include "lapi/sched.h"
@@ -61,6 +63,41 @@#define MIDDLE_ADDR2 0x0a000201/* 10.0.2.1 */ #define RECEIVER_ADDR 0x0a000202/* 10.0.2.2 */ +static struct xfrm_usersa_info xs_payload = { + .family =AF_INET , + .id.proto = (uint8_t )IPPROTO_ESP , + .mode =XFRM_MODE_TRANSPORT , + .reqid =1 , + .lft = { + .soft_byte_limit =XFRM_INF , + .hard_byte_limit =XFRM_INF , + .soft_packet_limit =XFRM_INF , + .hard_packet_limit =XFRM_INF , + }, +}; + +static struct xfrm_encap_tmpl esp_encap = { + .encap_type =TCP_ENCAP_ESPINTCP +}; + +static struct { +struct xfrm_algo_aead alg; +char buf[KEYTOTAL ]; +} aead_alg_info = { + .alg = { + .alg_name ="rfc4106(gcm(aes))" , + .alg_key_len =KEYTOTAL *8 , + .alg_icv_len =128 + } +}; + +static const struct tst_netlink_attr_list alg_config[] = { + {XFRMA_ENCAP , &esp_encap,sizeof (esp_encap),NULL }, + {XFRMA_ALG_AEAD , &aead_alg_info,sizeof (aead_alg_info.alg) +KEYTOTAL , +NULL }, + {0 ,NULL ,-1 ,NULL } +}; +static const uint8_t aead_key[KEYTOTAL ] = {0x00 ,0x11 ,0x22 ,0x33 ,0x44 ,0x55 ,0x66 ,0x77 ,0x88 ,0x99 ,0xaa ,0xbb ,0xcc ,0xdd ,0xee ,0xff ,
@@ -100,10 +137,13 @@ static void disable_offloads(const char *ifname)static void setup (void ) { -char keyhex[KEYTOTAL *2 +3 ]; -char spihex[16 ]; -char port_str[8 ];int i, ret; +struct tst_netlink_context *ctx; +struct nlmsghdr header = { + .nlmsg_type =XFRM_MSG_NEWSA , + .nlmsg_flags =NLM_F_REQUEST |NLM_F_CREATE |NLM_F_EXCL | +NLM_F_ACK + };tst_setup_netns ();NETDEV_SET_STATE ("lo" ,1 );
@@ -144,27 +184,26 @@ static void setup(void)NETDEV_SET_STATE ("veth_r" ,1 );NETDEV_ADD_ROUTE_INET ("veth_r" ,0 ,0 ,0 ,0 ,htonl (MIDDLE_ADDR2 )); - keyhex[0 ] ='0' ; - keyhex[1 ] ='x' ; -for (i =0 ; i <KEYTOTAL ; i++) -sprintf (keyhex +2 + i *2 ,"%02x" , aead_key[i]); - -snprintf (spihex,sizeof (spihex),"0x%08x" ,SPI ); -snprintf (port_str,sizeof (port_str),"%d" ,TCP_PORT ); - -const char *const xfrm_cmd[] = { -"ip" ,"xfrm" ,"state" ,"add" , -"src" ,"10.0.2.2" ,"dst" ,"10.0.2.2" , -"proto" ,"esp" ,"spi" , spihex, -"encap" ,"espintcp" , port_str, port_str,"0.0.0.0" , -"aead" ,"rfc4106(gcm(aes))" , keyhex,"128" , -"mode" ,"transport" , -NULL - }; - - ret =tst_cmd (xfrm_cmd,NULL ,NULL ,TST_CMD_PASS_RETVAL ); -if (ret) -tst_brk (TCONF ,"Failed to install xfrm ESP-in-TCP state" ); +memcpy (aead_alg_info.alg.alg_key, aead_key,KEYTOTAL ); + xs_payload.id.spi =htonl (SPI ); + xs_payload.saddr.a4 =htonl (RECEIVER_ADDR ); + xs_payload.id.daddr.a4 =htonl (RECEIVER_ADDR ); + esp_encap.encap_sport =htons (TCP_PORT ); + esp_encap.encap_dport =htons (TCP_PORT ); + + ctx =NETLINK_CREATE_CONTEXT (NETLINK_XFRM ); +NETLINK_ADD_MESSAGE (ctx, &header, &xs_payload,sizeof (xs_payload)); +NETLINK_ADD_ATTR_LIST (ctx, alg_config); + ret =NETLINK_SEND_VALIDATE (ctx); +TST_ERR = tst_netlink_errno; +NETLINK_DESTROY_CONTEXT (ctx); + +if (!ret) { +if (TST_ERR ==EPROTONOSUPPORT ) +tst_brk (TCONF ,"xfrm ESP is not supported by kernel" ); + +tst_brk (TBROK |TTERRNO ,"Failed to install xfrm ESP state" ); + }SAFE_SETNS (middlens,CLONE_NEWNET );
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Martin,
Quoted 1 line · Martin Doucha
[PATCH 1/6]
lapi/xfrm.h: Include system XFRM header and force kernel IPv6 definition
The commit subject and the in-code comment contradict what the code actually does. #define _UAPI_IPV6_H satisfies the include guard of linux/ipv6.h, preventing that header from being pulled in — it does not "force" kernel IPv6 definitions. Both the subject and comment should be corrected.
include/lapi/xfrm.h line 11
Quoted 3 lines
include/lapi/xfrm.h +3
-0+/* Force use of kernel IPv6 definitions to avoid redefinition errors */ +#define _UAPI_IPV6_H +#include <linux/xfrm.h>
Also needs a commit body explaining what specific redefinition error this fixes. linux/ipv6.h contains struct ipv6hdr and friends; the struct in6_addr redefinition that typically bites when mixing userspace and kernel IPv6 headers comes from linux/in6.h (include guard: _UAPI_LINUX_IN6_H). Please confirm that blocking linux/ipv6.h is sufficient and that the real conflict is not coming from linux/in6.h, and document the reasoning in the commit message.
[...]
--- [PATCH 5/6] xfrm02: Configure xfrm using direct netlink request ---
Review
Quoted 4 lines
(quoted diff) +1
-3- ret = tst_cmd(xfrm_cmd, NULL, NULL, TST_CMD_PASS_RETVAL); - if (ret) - tst_brk(TBROK, "Failed to install xfrm ESP-in-TCP state"); + ctx = NETLINK_CREATE_CONTEXT(NETLINK_XFRM);
The patch correctly removes .needs_cmds from xfrm01 after dropping the ip(8) call, but the equivalent removal is missing from xfrm02:
.needs_cmds = (struct tst_cmd[]) {
{.cmd = "ip"},
{}
},ip(8) is no longer invoked; drop .needs_cmds here too.
No linux-git tag for CVE-2026-46300. If a kernel fix commit exists, add one.
--- [PATCH 6/6] xfrm03: Configure xfrm using direct netlink request ---
Same stale .needs_cmds as patch 5/6 — xfrm03 still requires ip(8) in the test descriptor even though it is no longer called.
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 5 lines · On 5/27/26 15:04, [email protected] wrote:
Hi Martin,
Quoted 1 line · Martin Doucha
[PATCH 1/6]
lapi/xfrm.h: Include system XFRM header and force kernel IPv6 definition
Quoted 8 lines
The commit subject and the in-code comment contradict what the code actually does. #define
_UAPI_IPV6_Hsatisfies the include guard oflinux/ipv6.h, preventing that header from being pulled in — it does not "force" kernel IPv6 definitions. Both the subject and comment should be corrected.include/lapi/xfrm.h line 11
Quoted 3 lines
include/lapi/xfrm.h +3
-0+/* Force use of kernel IPv6 definitions to avoid redefinition errors */ +#define _UAPI_IPV6_H +#include <linux/xfrm.h>
The include guard for <linux/ipv6.h> is _IPV6_H so the lapi #define will not prevent it from being included. It will, however, prevent redefinition of struct in6_addr in <netinet/in.h> as intended.
The _UAPI_IPV6_H is used in the internal kernel header "uapi/linux/ipv6.h" which is not used by the test.
Quoted 6 lines
Also needs a commit body explaining what specific redefinition error this fixes.
linux/ipv6.hcontains struct ipv6hdr and friends; the structin6_addrredefinition that typically bites when mixing userspace and kernel IPv6 headers comes fromlinux/in6.h(include guard:_UAPI_LINUX_IN6_H). Please confirm that blockinglinux/ipv6.his sufficient and that the real conflict is not coming fromlinux/in6.h, and document the reasoning in the commit message.
The conflict exists only on older systems. The commit message is sufficient as is.
Quoted 15 lines
--- [PATCH 5/6] xfrm02: Configure xfrm using direct netlink request ---
Review
Quoted 4 lines
(quoted diff) +1
-3- ret = tst_cmd(xfrm_cmd, NULL, NULL, TST_CMD_PASS_RETVAL); - if (ret) - tst_brk(TBROK, "Failed to install xfrm ESP-in-TCP state"); + ctx = NETLINK_CREATE_CONTEXT(NETLINK_XFRM);The patch correctly removes .needs_cmds from xfrm01 after dropping the ip(8) call, but the equivalent removal is missing from xfrm02:
.needs_cmds = (struct tst_cmd[]) { {.cmd = "ip"}, {} },
Quoted 8 lines
ip(8) is no longer invoked; drop .needs_cmds here too.
No linux-git tag for CVE-2026-46300. If a kernel fix commit exists, add one.
--- [PATCH 6/6] xfrm03: Configure xfrm using direct netlink request ---
Same stale .needs_cmds as patch 5/6 — xfrm03 still requires ip(8) in the test descriptor even though it is no longer called.
Yes, I forgot to drop .needs_cmds in patch 5 and 6. I can send v2 after the preceding patches get merged.
Signature · 10 lines
Martin Doucha [email protected] SW Quality Engineer SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Martin,
thanks for checking. The CI is also not building on alpine, so I will move this patch-set to change requested.
https://github.com/linux-test-project/ltp/actions/runs/26509749446/job/78071109354
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp