当前使用的内核版本是5.4.281,报错
[ 1704.342850] Call trace:
[ 1704.345286] hooks_validate+0x34/0x70
[ 1704.348935] __nf_unregister_net_hook+0x128/0x198
[ 1704.353626] nf_unregister_net_hook+0x24/0x60
[ 1704.357972] _6+0x3c/0x188 [app_dpi]
[ 1704.361539] __arm64_sys_delete_module+0x1b0/0x258
[ 1704.366320] el0_svc_common.constprop.2+0x7c/0x110
[ 1704.371098] el0_svc_handler+0x20/0x80
[ 1704.374835] el0_svc+0x8/0x6c0
[ 1704.377880] Code: d503201f f8617883 eb05007f 540000c0 (b9402063)
原始exit函数为
static void __exit fini(void)
{
#if CONFIG_APP_DPI_ENABLE
int i;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,13,0)
#if CONFIG_APP_DPI_ENABLE
nf_unregister_net_hook(&init_net, &app_dpi_hook_ops);
nf_unregister_net_hook(&init_net, &app_dpi_hook_ops_v6);
#endif //CONFIG_APP_DPI_ENABLE
#if (CONFIG_APP_QOS_SUPPORT || WORK_FOR_SKIP_ONLY)
nf_unregister_net_hook(&init_net, &app_qos_hook_ops);
nf_unregister_net_hook(&init_net, &app_qos_hook_ops_v6);
#endif //CONFIG_APP_QOS_SUPPORT || WORK_FOR_SKIP_ONLY
#else //LINUX_VERSION_CODE
#if CONFIG_APP_DPI_ENABLE
nf_unregister_hook(&app_dpi_hook_ops);
nf_unregister_hook(&app_dpi_hook_ops_v6);
#endif //CONFIG_APP_DPI_ENABLE
#if (CONFIG_APP_QOS_SUPPORT || WORK_FOR_SKIP_ONLY)
nf_unregister_hook(&app_qos_hook_ops);
nf_unregister_hook(&app_qos_hook_ops_v6);
#endif //CONFIG_APP_QOS_SUPPORT || WORK_FOR_SKIP_ONLY
#endif //LINUX_VERSION_CODE
#ifdef CONFIG_APP_QOS_SUPPORT
if(app_qos_dir != NULL){
proc_remove(app_qos_dir);
}
#endif
nf_unregister_sockopt(&app_dpi_socket_option);
#if CONFIG_APP_DPI_ENABLE
#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS
nf_conntrack_unregister_notifier(&init_net, &app_dpi_ct_notifier);
#endif
if (timer_pending(&app_dpi_timer)) { del_timer_sync(&app_dpi_timer); } for (i = 0; i < PROFILE_SIZ; ++ i) { spin_lock_bh(&profile_lock); profile_node_free(l_profiles + i); spin_unlock_bh(&profile_lock); }
#endif //CONFIG_APP_DPI_ENABLE
#if ENABLE_AD_GUARD
cache_hashlist_clear(ad_hash);
#endif
#ifdef CONFIG_APP_QOS_SUPPORT
spin_lock_bh(&qos_lock);
cache_hashlist_clear(l_app_qos.hash);
spin_unlock_bh(&qos_lock);
#endif
dbg("app-dpi: Remove module successed!\n"); return;
}
其中hook为
static struct nf_hook_ops app_dpi_hook_ops = {
.hook = app_dpi_hook,
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,4,6))
.owner = THIS_MODULE,
#endif
.pf = PF_INET,
.hooknum = NF_INET_FORWARD,
.priority = NF_IP_PRI_FIRST,
};
static struct nf_hook_ops app_dpi_hook_ops_v6 = {
.hook = app_dpi_hook,
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,4,6))
.owner = THIS_MODULE,
#endif
.pf = PF_INET6,
.hooknum = NF_INET_FORWARD,
.priority = NF_IP_PRI_FIRST,
};
fini反汇编函数为
0000000000000000 <cleanup_module>:
fini():
0: a9bb7bfd stp x29, x30, [sp, #-80]!
4: 910003fd mov x29, sp
8: a90153f3 stp x19, x20, [sp, #16]
c: 90000014 adrp x20, 0 <cleanup_module>
10: 91000294 add x20, x20, #0x0
14: a9025bf5 stp x21, x22, [sp, #32]
18: 90000015 adrp x21, 0 <init_net>
1c: 910002b5 add x21, x21, #0x0
20: 91020281 add x1, x20, #0x80
24: aa1503e0 mov x0, x21
28: a90363f7 stp x23, x24, [sp, #48]
2c: aa1e03f7 mov x23, x30
30: 90000013 adrp x19, 0 <cleanup_module>
34: f90023f9 str x25, [sp, #64]
38: 94000000 bl 0 <nf_unregister_net_hook>
3c: 9102a281 add x1, x20, #0xa8
40: aa1503e0 mov x0, x21
44: 91000273 add x19, x19, #0x0
48: 94000000 bl 0 <nf_unregister_net_hook>
4c: 91034281 add x1, x20, #0xd0
50: aa1503e0 mov x0, x21
54: 94000000 bl 0 <nf_unregister_net_hook>
58: aa1503e0 mov x0, x21
5c: 9103e281 add x1, x20, #0xf8
60: 94000000 bl 0 <nf_unregister_net_hook>
64: f9405260 ldr x0, [x19, #160]
68: b4000040 cbz x0, 70 <cleanup_module+0x70>
6c: 94000000 bl 0 <proc_remove>
70: 91006280 add x0, x20, #0x18
74: 94000000 bl 0 <nf_unregister_sockopt>
78: 9101a281 add x1, x20, #0x68
7c: aa1503e0 mov x0, x21
80: 94000000 bl 0 <nf_conntrack_unregister_notifier>
84: 9101c260 add x0, x19, #0x70
88: f9400401 ldr x1, [x0, #8]
8c: b4000041 cbz x1, 94 <cleanup_module+0x94>
90: 94000000 bl 0 <timer_delete_sync>
94: 90000014 adrp x20, 0 <cleanup_module>
98: 91018279 add x25, x19, #0x60
9c: 91000294 add x20, x20, #0x0
a0: 52800216 mov w22, #0x10 // #16
a4: 52800018 mov w24, #0x0 // #0
a8: d5384115 mrs x21, sp_el0
ac: b94012a0 ldr w0, [x21, #16]
b0: 11080000 add w0, w0, #0x200
b4: b90012a0 str w0, [x21, #16]
b8: aa1903e0 mov x0, x25
bc: 94000000 bl 0 <cleanup_module>
c0: aa1403e0 mov x0, x20
c4: 94000000 bl 0 <cleanup_module>
c8: 91018260 add x0, x19, #0x60
cc: 089ffc18 stlrb w24, [x0]
d0: 52804001 mov w1, #0x200 // #512
d4: aa1703e0 mov x0, x23
d8: 94000000 bl 0 <__local_bh_enable_ip>
dc: 910ac294 add x20, x20, #0x2b0
e0: 710006d6 subs w22, w22, #0x1
e4: 54fffe21 b.ne a8 <cleanup_module+0xa8> // b.any
e8: b94012a0 ldr w0, [x21, #16]
ec: 11080000 add w0, w0, #0x200
f0: b90012a0 str w0, [x21, #16]
f4: 9101a260 add x0, x19, #0x68
f8: 94000000 bl 0 <cleanup_module>
fc: 90000000 adrp x0, 0 <cleanup_module>
100: 91000000 add x0, x0, #0x0
104: 94000000 bl 0 <cleanup_module>
108: 9101a260 add x0, x19, #0x68
10c: 089ffc18 stlrb w24, [x0]
110: aa1703e0 mov x0, x23
114: 52804001 mov w1, #0x200 // #512
118: a94153f3 ldp x19, x20, [sp, #16]
11c: a9425bf5 ldp x21, x22, [sp, #32]
120: a94363f7 ldp x23, x24, [sp, #48]
124: f94023f9 ldr x25, [sp, #64]
128: a8c57bfd ldp x29, x30, [sp], #80
12c: 14000000 b 0 <__local_bh_enable_ip>
此问题仅在使用reboot重启时出现,单独卸载rmmod不出现。
指出对应panic位置,及最小程度的修复方案。