infinet / xt_wgobfs

Iptables WireGuard obfuscation extension
GNU General Public License v2.0
223 stars 24 forks source link

Kernel panic, when use relay #19

Closed artemws closed 12 months ago

artemws commented 1 year ago

Could anyone help me? I'm trying to install relay server. This is my rules for iptables

1.1.1.1 = IP of WAN (VDS) 2.2.2.2 = IP of WG server

iptables -t nat -A PREROUTING -p udp -d 1.1.1.1 --dport 5555 -j DNAT --to-destination 2.2.2.2:5555
iptables -t nat -A POSTROUTING -p udp -d 2.2.2.2 --dport 5555 -j MASQUERADE

iptables -t mangle -A FORWARD -p udp -d 2.2.2.2 --dport 5555 -j WGOBFS --key mysecretkey --obfs
iptables -t mangle -A FORWARD -p udp -s 2.2.2.2--sport 5555 -j WGOBFS --key mysecretkey --unobfs

But, i have kernel panic, when package incoming to mangle for obfs.

I've tried:

Debian 10/11/12, Centos 7 - unsuccessful Different kernel versions - unsuccessful Build version 0.4.0 and 0.4.1 - still unsuccessful((

Can someone try to test relay option?

romanrm commented 1 year ago

Developers will need you to post the actual kernel panic message. If no other way to capture, then at least make a photo. And report the actual kernel versions tried.

artemws commented 1 year ago

Developers will need you to post the actual kernel panic message. If no other way to capture, then at least make a photo. And report the actual kernel versions tried.

Ok. For example Centos 7, kernel 3.10.0-1160.90.1.el7.x86_64

kernel

artemws commented 1 year ago

kernel2

artemws commented 1 year ago
   45.136475] ------------[ cut here ]------------
[   45.137997] kernel BUG at net/core/skbuff.c:1488!
[   45.139094] invalid opcode: 0000 [#1] SMP 
[   45.140293] Modules linked in: ipt_MASQUERADE nf_nat_masquerade_ipv4 xt_nat ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 xt_conntrack ebtable_nat ebtable_broute bridge stp llc ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat iptable_mangle iptable_security iptable_raw nf_conntrack libcrc32c ip_set ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter snd_hda_codec_generic snd_hda_intel snd_hda_codec crc32_pclmul snd_hda_core snd_hwdep snd_seq ghash_clmulni_intel snd_seq_device snd_pcm aesni_intel iTCO_wdt iTCO_vendor_support snd_timer lrw gf128mul snd glue_helper sg ablk_helper cryptd soundcore pcspkr lpc_ich i2c_i801 joydev virtio_rng virtio_balloon
[   45.162084]  i6300esb sch_fq xt_WGOBFS(OE) ip_tables ext4 mbcache jbd2 sr_mod cdrom drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm ahci libahci drm libata virtio_net net_failover failover virtio_blk crct10dif_pclmul crct10dif_common crc32c_intel virtio_pci virtio_ring virtio drm_panel_orientation_quirks serio_raw nvme nvme_core mpt3sas raid_class scsi_transport_sas megaraid_sas ixgbe mdio ptp pps_core dca bnxt_en devlink
[   45.173648] CPU: 0 PID: 0 Comm: swapper/0 Kdump: loaded Tainted: G           OE  ------------   3.10.0-1160.90.1.el7.x86_64 #1
[   45.176201] Hardware name: Vultr VHP, BIOS  
[   45.177150] task: ffffffff9ce18480 ti: ffffffff9ce00000 task.ti: ffffffff9ce00000
[   45.178861] RIP: 0010:[<ffffffff9c8678f3>]  [<ffffffff9c8678f3>] skb_put+0x33/0x50
[   45.180829] RSP: 0018:ffff8eccbfc03948  EFLAGS: 00010202
[   45.181992] RAX: ffff8eccbd0abcc0 RBX: ffff8ecc8001f500 RCX: 000000000000003e
[   45.183614] RDX: 00000000000000c0 RSI: 0000000000000005 RDI: ffff8ecc8001f500
[   45.185285] RBP: ffff8eccbfc03a08 R08: ffff8eccbfc1f160 R09: ffff8eccbe001500
[   45.187142] R10: ffff8eccbe001500 R11: 000000009bbf1a58 R12: 0000000000000005
[   45.189215] R13: ffff8eccbfc03997 R14: 0000000000000020 R15: 0000000000000005
[   45.190857] FS:  0000000000000000(0000) GS:ffff8eccbfc00000(0000) knlGS:0000000000000000
[   45.192824] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   45.196277] CR2: 00007f98d97c8000 CR3: 00000000365f4000 CR4: 0000000000140ff0
[   45.197959] Call Trace:
[   45.198551]  <IRQ> 
[   45.199041]  [<ffffffffc04ca34b>] ? xt_wg_obfs_target+0x2fb/0x5a0 [xt_WGOBFS]
[   45.200912]  [<ffffffffc04ef70b>] ipt_do_table+0x30b/0x750 [ip_tables]
[   45.202460]  [<ffffffffc07540d7>] ? xt_dnat_target_v0+0x77/0xa0 [xt_nat]
[   45.204188]  [<ffffffff9c911aa5>] ? __fib_validate_source.isra.13+0xf5/0x380
[   45.205915]  [<ffffffffc069e043>] iptable_mangle_hook+0x43/0x140 [iptable_mangle]
[   45.207838]  [<ffffffff9c8c0ef8>] nf_iterate+0x98/0xe0
[   45.209060]  [<ffffffff9c8c0fe8>] nf_hook_slow+0xa8/0x110
[   45.210499]  [<ffffffff9c8ce5fa>] ip_forward+0x45a/0x4b0
[   45.211766]  [<ffffffff9c8cab02>] ? ip_mc_validate_source+0x52/0xf0
[   45.213249]  [<ffffffff9c8ce110>] ? ip_frag_mem+0x20/0x20
[   45.214528]  [<ffffffff9c8cbfa0>] ip_rcv_finish+0x90/0x380
[   45.215932]  [<ffffffff9c8cc9a0>] ip_rcv+0x2c0/0x420
[   45.217195]  [<ffffffff9c98b102>] ? packet_create+0x1f2/0x2a0
[   45.218616]  [<ffffffff9c8cbf10>] ? inet_del_offload+0x40/0x40
[   45.220105]  [<ffffffff9c87f669>] __netif_receive_skb_core+0x739/0xa20
[   45.221664]  [<ffffffff9c30ea2f>] ? __getnstimeofday64+0x3f/0xd0
[   45.223222]  [<ffffffff9c87f968>] __netif_receive_skb+0x18/0x70
[   45.224805]  [<ffffffff9c87fa00>] netif_receive_skb_internal+0x40/0xc0
[   45.226627]  [<ffffffff9c8806b8>] napi_gro_receive+0xd8/0x100
[   45.229800]  [<ffffffffc02b7515>] virtnet_poll+0x265/0x750 [virtio_net]
[   45.232009]  [<ffffffff9c880037>] net_rx_action+0x277/0x3a0
[   45.233472]  [<ffffffff9c2a9595>] __do_softirq+0xf5/0x290
[   45.234745]  [<ffffffff9c9c8aac>] call_softirq+0x1c/0x30
[   45.236052]  [<ffffffff9c230825>] do_softirq+0x65/0xa0
[   45.237369]  [<ffffffff9c2a9945>] irq_exit+0x115/0x120
[   45.238584]  [<ffffffff9c9c9ef6>] do_IRQ+0x56/0x100
[   45.239893]  [<ffffffff9c9bb3b2>] common_interrupt+0x172/0x172
[   45.241350]  <EOI> 
[   45.241838]  [<ffffffff9c9b9bc0>] ? __sched_text_end+0x4/0x4
[   45.243349]  [<ffffffff9c9b9e1b>] ? native_safe_halt+0xb/0x30
[   45.244774]  [<ffffffff9c9b9bde>] default_idle+0x1e/0xd0
[   45.246029]  [<ffffffff9c239570>] arch_cpu_idle+0x20/0xc0
[   45.247473]  [<ffffffff9c30820a>] cpu_startup_entry+0x14a/0x1e0
[   45.248837]  [<ffffffff9c9a03f7>] rest_init+0x77/0x80
[   45.250171]  [<ffffffff9cf8c22b>] start_kernel+0x44b/0x470
[   45.251834]  [<ffffffff9cf8bbc8>] ? repair_env_string+0x64/0x64
[   45.253959]  [<ffffffff9cf8b120>] ? early_idt_handler_array+0x120/0x120
[   45.255638]  [<ffffffff9cf8b748>] x86_64_start_reservations+0x24/0x2a
[   45.257055]  [<ffffffff9cf8b8a2>] x86_64_start_kernel+0x154/0x17b
[   45.259715]  [<ffffffff9c2000d5>] start_cpu+0x5/0x14
[   45.260974] Code: 00 00 00 8b 4f 6c 89 d0 48 03 87 e0 00 00 00 85 c9 75 18 01 f2 01 77 68 3b 97 dc 00 00 00 89 97 d8 00 00 00 77 07 c3 cc cc cc cc <0f> 0b 55 48 c7 c1 70 e6 a9 9c 48 89 e5 48 8b 55 08 e8 1a c8 14 
[   45.267828] RIP  [<ffffffff9c8678f3>] skb_put+0x33/0x50
[   45.269080]  RSP <ffff8eccbfc03948>
infinet commented 1 year ago

Thank you for the bug report! I can reproduce this problem. Looks like something wrong when combine with DNAT.

artemws commented 1 year ago

Thank you for the bug report! I can reproduce this problem. Looks like something wrong when combine with DNAT.

Well, some research for you....

Latest kernel 6.5.1

[  254.909284] ------------[ cut here ]------------
[  254.909296] kernel BUG at net/core/skbuff.c:2372!
[  254.909461] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
/**
 *  skb_put - add data to a buffer
 *  @skb: buffer to use
 *  @len: amount of data to add
 *
 *  This function extends the used data area of the buffer. If this would
 *  exceed the total buffer size the kernel will panic. A pointer to the
 *  first byte of the extra data is returned.
 */
void *skb_put(struct sk_buff *skb, unsigned int len)
{
  void *tmp = skb_tail_pointer(skb);
  SKB_LINEAR_ASSERT(skb);
  skb->tail += len;
  skb->len  += len;
  if (unlikely(skb->tail > skb->end))
    skb_over_panic(skb, len, __builtin_return_address(0));
  return tmp;
}
infinet commented 1 year ago

Please try the latest commit. Tested on Centos 7.

artemws commented 1 year ago

Please try the latest commit. Tested on Centos 7.

Works perfectly! Continuing testing