Hi guys,
Just wanted to clarify a few things and some potential new findings which might help us get closer to wrapping this up (I fantasize about that day tbh at this point, given all the fu*kery we have to deal with..)
I built a LEDE/Chinese branch a few weeks ago, stripped all the Chinese crap and potentially nasty things, added all of @robimarko's incredible work with the patches, and after literally days of failing builds etc. (let's just say I included almost everything one would need on OpenWRT - the resulting image was around 48MB), I got a successful build.
I flashed it to mtd13 with ubiformat, because at some point (early January-February), I flashed the Chinese QSDK which messed up the partition table and made the second partition huge.
First thing to clarify, it is possible to dual-boot/dual-partition with stock Xiaomi INT on mtd12 and OpenWRT on mtd13. You can actually go back and forth between them, with the nvram flags. sysupgrade will destroy your router most likely, I have not attempted flashing mtd12 or sysupgrade, because I don't have serial connectivity to the router, and it wasn't clear if I can revert to the "stock" partition table without serial/tftp recovery. I don't mind dual-booting and just ubiformat-ing and restoring the configuration manually for OpenWRT after each "upgrade" for now, until we get a stable build.
WireGuard worked - I was able to get around 390MBps max with Mullvad, but the CPU load is NOTICEABLE. All the cores were pinned to around 50-60% when doing a speedtest.
Everything else more or less worked (NAT, NAT6, mwan3, sqm/traffic shaping etc.).
This is where the fun begins though.. In order to get NAT-ing and everything else operational, I had to enable ecm and/or nss. There are some weird issues with the Chinese forks and modprobe/insmod, I literally had to insmod full module path, and I also had to create a symlink to the NSS firmware manually, to match the .bin filename expected by the kernel.
I need IPv6 (my cheap ISP offers a /128 only, so I'm doing NAT6 and split-routing with mwan3). As soon as ECM is modprobe'd and some traffic flows across the network, in literally a few minutes, the router would crash and reboot.. in an eternal loop of hell. So there are other serious issues, not just the Wi-Fi leaks. As @robimarko mentioned multiple times in the past, this NSS junk is a nightmare and in an ideal world, we'd somehow need to get rid of all of it.
Just before one of the crashes, I was able to capture this..:
[ 218.444578] wlan1-1: NSS TX failed with error[8]: NSS_TX_FAILURE_NOT_ENABLED
[ 218.570220] wlan1-1: NSS TX failed with error[8]: NSS_TX_FAILURE_NOT_ENABLED
[ 218.616791] wlan1-1: NSS TX failed with error[8]: NSS_TX_FAILURE_NOT_ENABLED
[ 218.634884] wlan1-1: NSS TX failed with error[8]: NSS_TX_FAILURE_NOT_ENABLED
[ 218.656867] wlan1-1: NSS TX failed with error[8]: NSS_TX_FAILURE_NOT_ENABLED
**[ 240.416755] detected buffer overflow in memcpy**
[ 240.416804] ------------[ cut here ]------------
[ 240.420102] Kernel BUG at fortify_panic+0x20/0x24 [verbose debug info unavailable]
[ 240.424872] Internal error: Oops - BUG: 0 [#1] SMP
[ 240.432243] Modules linked in: shortcut_fe_drv ecm xt_FULLCONENAT nf_nat_amanda nf_conntrack_amanda cdc_mbim ath11k_ahb ath11k ath10k_pci ath10k_core ath wireguard rndis_host qmi_wwan nft_fib_inet nf_flow_table_ipv6 nf_flow_table_ipv4 nf_flow_table_inet mac80211 lz4 libchacha20poly1305 libblake2s ipt_REJECT ebtable_nat ebtable_filter ebtable_broute chacha_neon cfg80211 cdc_subset cdc_ncm cdc_ether cdc_eem xt_u32 xt_time xt_tcpudp xt_tcpmss xt_string xt_statistic xt_state xt_socket xt_recent xt_quota2 xt_quota xt_policy xt_pkttype xt_physdev xt_owner xt_nat xt_multiport xt_mark xt_mac xt_limit xt_length2 xt_length xt_ipv4options xt_iprange xt_ipp2p xt_iface xt_hl xt_helper xt_hashlimit xt_esp xt_ecn xt_dscp xt_conntrack xt_connmark xt_connlimit xt_connlabel xt_connbytes xt_condition xt_comment xt_cluster xt_cgroup xt_bpf xt_addrtype xt_TRACE xt_TPROXY xt_TCPMSS xt_TARPIT xt_REDIRECT xt_PROTO xt_NFQUEUE xt_NFLOG xt_NETMAP xt_MASQUERADE xt_LOGMARK xt_LOG xt_LED xt_IPMARK xt_HL xt_FLOWOFFLOAD
[ 240.432433] xt_DSCP xt_DNETMAP xt_DHCPMAC xt_DELUDE xt_CT xt_CLASSIFY xt_CHECKSUM xt_CHAOS xt_ACCOUNT xfrm_interface vhci_hcd usbserial usbnet usbmon usbip_host usbip_core usbhid ums_usbat ums_sddr55 ums_sddr09 ums_karma ums_jumpshot ums_isd200 ums_freecom ums_datafab ums_cypress ums_alauda ts_kmp ts_fsm ts_bm tcp_hybla tcp_bbr sch_mqprio sch_cake pptp ppp_mppe ppp_async poly1305_neon ntfs3 nlmon nft_reject_ipv6 nft_reject_ipv4 nft_reject_inet nft_reject_bridge nft_reject nft_redir nft_quota nft_queue nft_objref nft_numgen nft_nat nft_meta_bridge nft_masq nft_log nft_limit nft_hash nft_fwd_netdev nft_flow_offload nft_fib_ipv6 nft_fib_ipv4 nft_fib nft_dup_netdev nft_ct nft_counter nft_chain_nat nfnetlink_queue nfnetlink_log nf_tproxy_ipv6 nf_tproxy_ipv4 nf_tables nf_socket_ipv6 nf_socket_ipv4 nf_reject_ipv4 nf_nat_tftp nf_nat_snmp_basic nf_nat_sip nf_nat_rtsp nf_nat_pptp nf_nat_irc nf_nat_h323 nf_nat_ftp nf_log_ipv4 nf_flow_table nf_dup_netdev nf_conntrack_tftp nf_conntrack_snmp
[ 240.502371] nf_conntrack_sip nf_conntrack_rtsp nf_conntrack_pptp nf_conntrack_netlink nf_conntrack_irc nf_conntrack_h323 nf_conntrack_ftp nf_conntrack_broadcast nf_conncount mdio_gpio mdio_bitbang macvlan macremapper lz4_decompress lz4_compress libcurve25519_generic libchacha libblake2s_generic l2tp_ppp ipvlan iptable_raw iptable_nat iptable_mangle iptable_filter ipt_rpfilter ipt_ah ipt_ECN ipt_CLUSTERIP ip6table_raw ip6t_rpfilter ip_tables hid_generic ebtables ebt_vlan ebt_stp ebt_snat ebt_redirect ebt_pkttype ebt_nflog ebt_mark_m ebt_mark ebt_log ebt_limit ebt_ip6 ebt_ip ebt_dnat ebt_arpreply ebt_arp ebt_among ebt_802_3 crc_ccitt compat_xtables compat cls_flower cdc_wdm cdc_acm asn1_decoder arptable_filter arpt_mangle arp_tables act_vlan fuse sch_teql sch_sfq sch_red sch_prio sch_pie sch_multiq sch_gred sch_fq sch_dsmark sch_codel em_text em_nbyte em_meta em_cmp act_simple act_police act_pedit act_ipt act_csum em_ipset cls_bpf act_bpf act_ctinfo act_connmark sch_tbf sch_ingress sch_htb
[ 240.589182] sch_hfsc em_u32 cls_u32 cls_tcindex cls_route cls_matchall cls_fw cls_flow cls_basic act_skbedit act_mirred act_gact sg hid evdev gpio_fan hwmon i2c_gpio industrialio i2c_algo_bit qca_nss_pppoe pppoe pppox i2c_mux_gpio i2c_mux ledtrig_usbport trelay cryptodev xt_set ip_set_list_set ip_set_hash_netportnet ip_set_hash_netport ip_set_hash_netnet ip_set_hash_netiface ip_set_hash_net ip_set_hash_mac ip_set_hash_ipportnet ip_set_hash_ipportip ip_set_hash_ipport ip_set_hash_ipmark ip_set_hash_ip ip_set_bitmap_port ip_set_bitmap_ipmac ip_set_bitmap_ip ip_set nfnetlink ip6table_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ip6t_NPT ip6t_rt ip6t_mh ip6t_ipv6header ip6t_hbh ip6t_frag ip6t_eui64 ip6t_ah nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 nfsv4 pppoatm ppp_generic nfsd nfs nfs_ssc bonding ip6_gre ip_gre gre ifb nat46 l2tp_ip6 l2tp_ip l2tp_eth ip6_vti ip_vti sit sctp libcrc32c qca_nss_drv l2tp_netlink l2tp_core
I enabled SELinux, fortify, full ASLR / PIE and RELRO, and compiled with the latest toolchain. This is why the buffer overflow was caught. I wouldn't be surprised if the infamous "leak" was just memory overflowing..
I'm gonna try a build from @robimarko's latest branch tonight, with the same .config and will update this with my results.