AnsweredAssumed Answered

use sock can api will crash in kernel

Question asked by jesse stone on Nov 28, 2017
Latest reply on Feb 2, 2018 by jesse stone

in canutils/candump.c

...

...

socket(PF_CAN, SOCK_RAW, CAN_RAW);

...

...

nbytes = recvmsg(s[i], &msg, 0);

 

//

sometimes crash in linux kernel

 

[  250.778583] Unable to handle kernel paging request at virtual address 3ce84c10
[  250.779549] pgd = c0004000
[  250.779930] [3ce84c10] *pgd=00000000
[  250.780450] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[  250.781154] Modules linked in:
[  250.781607] CPU: 0 PID: 87 Comm: ci_otg Not tainted 4.1.27-svn1470 #2
[  250.782454] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[  250.783322] Workqueue: P� 0xc89befc4 (��1���1���1�)
[  250.784023] task: ca3d5140 ti: ca6dc000 task.ti: ca6dc000
[  250.784764] PC is at cpuacct_charge+0xcc/0x150
[  250.785371] LR is at cpuacct_charge+0x3c/0x150
[  250.785973] pc : [<c01e0cac>]    lr : [<c01e0c1c>]    psr: a00e0193
[  250.785973] sp : ca6ddf18  ip : ca6ddf18  fp : ca6ddf7c
[  250.787453] r10: ca277010  r9 : 00000000  r8 : 00000002
[  250.788149] r7 : 00000001  r6 : ca6df578  r5 : c1304c04  r4 : 00000000
[  250.789006] r3 : c1304a7c  r2 : 1eee0065  r1 : 00000000  r0 : ca4c7080
[  250.789864] Flags: NzCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
[  250.790829] Control: 10c53c7d  Table: 19b1804a  DAC: 00000015
[  250.791586]
[  250.791586] PC: 0xc01e0c2c:
[  250.792160] 0c2c  e3a03001 e50b3030 e3a03000 e50b3034 e51b302c e2833d16 e5933000 e50b3038
[  250.793436] 0c4c  e51b3038 e50b303c e51b303c e51b2030 e282200a e7933102 e50b3040 e51b3040
[  250.794703] 0c6c  e3530000 0a000003 e51b3040 e50b3044 e51b3044 ea000000 e3a03000 e50b3010
[  250.795972] 0c8c  e3a03000 e50b3018 e51b3010 e5933068 e50b301c e3043a7c e34c3130 e51b2014
[  250.797236] 0cac  e7932102 e51b301c e0823003 e50b3020 e51b3020 e1c300d0 e14b26d4 e0922000
[  250.798502] 0ccc  e0a33001 e51b1020 e1c120f0 e51b3010 e50b3048 e51b3048 e5933024 e50b304c
[  250.799768] 0cec  e51b304c e3530000 0a000003 e51b304c e50b3050 e51b3050 ea000000 e3a03000
[  250.801032] 0d0c  e50b3010 e51b3010 e3530000 1a000000 ea000000 eaffffd9 eb009e91 e24bd00c
[  250.802304]
[  250.802304] LR: 0xc01e0b9c:
[  250.802878] 0b9c  eb00e847 e1a02000 e1a03001 e14b21fc e30cc424 e34cc0e0 e14b21dc e1cd20f0
[  250.804149] 0bbc  e51b0060 e30c1434 e34c10e0 e1a0200c eb0646dd e3a03000 e1a00003 e24bd00c
[  250.805421] 0bdc  e89da800 e1a0c00d e92dd800 e24cb004 e24dd058 e52de004 e8bd4000 e50b0058
[  250.806687] 0bfc  e14b26f4 e51b3058 e50b3024 e51b3024 e5933004 e5933010 e50b3014 eb009ec7
[  250.807952] 0c1c  e51b3058 e50b3028 e51b3028 e50b302c e3a03001 e50b3030 e3a03000 e50b3034
[  250.809216] 0c3c  e51b302c e2833d16 e5933000 e50b3038 e51b3038 e50b303c e51b303c e51b2030
[  250.810480] 0c5c  e282200a e7933102 e50b3040 e51b3040 e3530000 0a000003 e51b3040 e50b3044
[  250.811746] 0c7c  e51b3044 ea000000 e3a03000 e50b3010 e3a03000 e50b3018 e51b3010 e5933068
[  250.813016]
[  250.813016] SP: 0xca6dde98:
[  250.813589] de98  60000113 c12e4c40 00000000 c0d6d5f0 00000002 ca3d5140 c01e0cac a00e0193
[  250.814860] deb8  ffffffff ca6ddf04 ca6ddf7c ca6dded0 c0114518 c01011e0 ca4c7080 00000000
[  250.816125] ded8  1eee0065 c1304a7c 00000000 c1304c04 ca6df578 00000001 00000002 00000000
[  250.817392] def8  ca277010 ca6ddf7c ca6ddf18 ca6ddf18 c01e0c1c c01e0cac a00e0193 ffffffff
[  250.818657] df18  0001dddd 00000000 ca6ddfac ca4c7080 c018b3d0 cd6f9c80 0001dddd 00000000
[  250.819921] df38  c13179e8 c13179e8 c131a1b8 c131a1b8 00000000 00000001 ca4c7080 ca4c7080
[  250.821194] df58  ca4c7080 ca6ddf5c c12e0348 00000000 1eee0065 c13179e8 ca6de074 ca6ddf80
[  250.822464] df78  c01b4450 c01e0bec 00000000 ca6ddf44 ca6ddf54 cd6f9c80 001e8c50 00000000
[  250.823732]
[  250.823732] IP: 0xca6dde98:
[  250.824306] de98  60000113 c12e4c40 00000000 c0d6d5f0 00000002 ca3d5140 c01e0cac a00e0193
[  250.825571] deb8  ffffffff ca6ddf04 ca6ddf7c ca6dded0 c0114518 c01011e0 ca4c7080 00000000
[  250.826837] ded8  1eee0065 c1304a7c 00000000 c1304c04 ca6df578 00000001 00000002 00000000
[  250.828103] def8  ca277010 ca6ddf7c ca6ddf18 ca6ddf18 c01e0c1c c01e0cac a00e0193 ffffffff
[  250.829369] df18  0001dddd 00000000 ca6ddfac ca4c7080 c018b3d0 cd6f9c80 0001dddd 00000000
[  250.830631] df38  c13179e8 c13179e8 c131a1b8 c131a1b8 00000000 00000001 ca4c7080 ca4c7080
[  250.831903] df58  ca4c7080 ca6ddf5c c12e0348 00000000 1eee0065 c13179e8 ca6de074 ca6ddf80
[  250.833172] df78  c01b4450 c01e0bec 00000000 ca6ddf44 ca6ddf54 cd6f9c80 001e8c50 00000000
[  250.834440]
[  250.834440] FP: 0xca6ddefc:
[  250.835015] defc  ca6ddf7c ca6ddf18 ca6ddf18 c01e0c1c c01e0cac a00e0193 ffffffff 0001dddd
[  250.836282] df1c  00000000 ca6ddfac ca4c7080 c018b3d0 cd6f9c80 0001dddd 00000000 c13179e8
[  250.837553] df3c  c13179e8 c131a1b8 c131a1b8 00000000 00000001 ca4c7080 ca4c7080 ca4c7080
[  250.838825] df5c  ca6ddf5c c12e0348 00000000 1eee0065 c13179e8 ca6de074 ca6ddf80 c01b4450
[  250.840096] df7c  c01e0bec 00000000 ca6ddf44 ca6ddf54 cd6f9c80 001e8c50 00000000 0001dddd
[  250.841363] df9c  00000000 00000000 ca6ddfb0 c0109288 c018b18c 00000000 00000000 00000000
[  250.842630] dfbc  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  250.843897] dfdc  00000000 00000000 00000000 00000000 00000000 00000013 00000000 00000000
[  250.845163]
[  250.845163] R0: 0xca4c7000:
[  250.845737] 7000  ca4c6ffc c0d6d5f0 00000000 00000000 00000000 00000000 00000000 00000000
[  250.847009] 7020  00000020 00000000 0000c350 0000c350 ffffffff 00000000 00000000 00000000
[  250.848275] 7040  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  250.849542] 7060  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  250.850805] 7080  00000000 ca6de000 00000002 04208060 00000000 00000000 00000001 c960d780
[  250.852075] 70a0  0000007e 00000000 00000000 00000001 00000078 00000078 00000078 00000000
[  250.853341] 70c0  c0e0a838 00000000 00000400 00400000 00000001 00000000 00000000 cd6fa170
[  250.854612] 70e0  cd6fa170 00000001 6390fe19 0000003a 9b60ba39 00000000 1eee0065 00000035
[  250.855880]
[  250.855880] R3: 0xc13049fc:
[  250.856455] 49fc  000009c4 00000019 00000000 0003d983 00001980 00001980 01ffffff 00000000
[  250.857725] 4a1c  00000001 00000001 00000001 00000001 00000001 00018000 00000064 00000000
[  250.858987] 4a3c  cdfff400 0000000d cdfff3c0 00000001 0000d000 0000000f cdfff340 00000044
[  250.860253] 4a5c  cdfff900 cdfff440 00000001 00001000 00000002 00000000 00000001 cd6f5000
[  250.861520] 4a7c  0c415000 0c422000 00000000 00000000 00000001 00019600 00000002 0001df37
[  250.862786] 4a9c  00010000 0004ffff 00007a4a 00002000 00000001 0000fffa 00000000 00000000
[  250.864049] 4abc  00000032 00000001 ca001e00 ca25f910 00000000 00000000 ca001a00 cd671000
[  250.865320] 4adc  00000011 ca001380 ca001b80 0001ffff 00000064 00000010 0000ffff ca001300
[  250.866590]
[  250.866590] R5: 0xc1304b84:
[  250.867164] 4b84  00000000 ca001400 00000001 c10d4240 00000000 00000004 c10d424c 00000000
[  250.868433] 4ba4  00000010 c10d4258 ca001e00 00000040 c10d4264 ca1bd100 00000080 c10d4270
[  250.869700] 4bc4  ca1bd180 00000100 c10d427c ca1bd200 00000100 00000000 0000003f 00000fff
[  250.870966] 4be4  0003ffff 00ffffff 3fffffff ffffffff 00000002 00000000 00000000 00000020
[  250.872237] 4c04  e6800000 f4a00100 00000000 00000000 00000000 00000000 00000000 00000000
[  250.873501] 4c24  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  250.874762] 4c44  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  250.876029] 4c64  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  250.877295]
[  250.877295] R6: 0xca6df4f8:
[  250.877870] f4f8  cd6fa0d8 00000000 638e9784 c01bad3c ca4c70c8 cd6f9c80 0c415000 c12e2d10
[  250.879136] f518  00000000 00000000 00000000 00000000 0c415000 c12e2d10 00000000 00000000
[  250.880400] f538  ca6df578 00000000 00000000 0000001f ca6df574 ca6df558 c01015e4 c01f74e0
[  250.881664] f558  c01a1ec0 800e0013 ffffffff ca6df5ac ca6df5ec ca6df578 c0114580 c01015a0
[  250.882928] f578  00000001 c109b7e6 00000002 00000001 c0d6d5f0 ca277010 ca277238 ca6dfa7c
[  250.884191] f598  00000002 00000000 ca277010 ca6df5ec ca6df5f0 ca6df5c0 c0d76d20 c01a1ec0
[  250.885462] f5b8  800e0013 ffffffff 00000004 00000001 c1319c40 00000000 00000000 00000000
[  250.886724] f5d8  00000000 00000000 ca6df624 ca6df5f0 c0d76d20 c01a1db8 c01c1450 cd6f9c40
[  250.888002]
[  250.888002] R10: 0xca276f90:
[  250.888585] 6f90  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  250.889857] 6fb0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  250.891121] 6fd0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  250.892388] 6ff0  00000000 00000000 00000000 00000000 ca28d4c0 ca28d400 c0690e64 00000000
[  250.893655] 7010  00000000 00000000 c13760e4 00000000 12b912b9 00000000 00000000 ca4c7080
[  250.894923] 7030  00000064 00000003 ca21c210 ca28ca00 ca28d600 ca28282c ca275c6c ca21c218
[  250.896188] 7050  ca14b840 c135fc08 ca28bf50 0000000f 00000007 00000000 c13754f4 00000001
[  250.897454] 7070  00000000 ca277074 ca277074 00000000 00000000 c137550c 00000000 00000000
[  250.898730] Process ci_otg (pid: 87, stack limit = 0xca6dc210)
[  250.899502] Stack: (0xca6ddf18 to 0xca6de000)
[  250.900092] df00:                                                       0001dddd 00000000
[  250.901164] df20: ca6ddfac ca4c7080 c018b3d0 cd6f9c80 0001dddd 00000000 c13179e8 c13179e8
[  250.902237] df40: c131a1b8 c131a1b8 00000000 00000001 ca4c7080 ca4c7080 ca4c7080 ca6ddf5c
[  250.903310] df60: c12e0348 00000000 1eee0065 c13179e8 ca6de074 ca6ddf80 c01b4450 c01e0bec
[  250.904383] df80: 00000000 ca6ddf44 ca6ddf54 cd6f9c80 001e8c50 00000000 0001dddd 00000000
[  250.905453] dfa0: 00000000 ca6ddfb0 c0109288 c018b18c 00000000 00000000 00000000 00000000
[  250.906522] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  250.907591] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[  250.908647] Backtrace:
[  250.909045] [<c01e0be0>] (cpuacct_charge) from [<c01b4450>] (update_curr+0x4b8/0x5a0)
[  250.910088] [<c01b3f98>] (update_curr) from [<c01b78d0>] (enqueue_entity+0x6c/0x1a70)
[  250.911131] [<c01b7864>] (enqueue_entity) from [<c01bc31c>] (enqueue_task_fair+0x6c/0x13f4)
[  250.912214]  r9:00000000 r8:00000002 r7:00000001 r6:ca6df578 r5:c1304c04 r4:00000000
[  250.913371] [<c01bc2b0>] (enqueue_task_fair) from [<c019b9fc>] (enqueue_task+0xa8/0xb0)
[  250.914410]  r9:00000000 r8:00000002 r7:00000001 r6:ca6df578 r5:c1304c04 r4:00000000
[  250.915564] [<c019b954>] (enqueue_task) from [<c019bbc8>] (activate_task+0x70/0x78)
[  250.916580] [<c019bb58>] (activate_task) from [<c019df1c>] (ttwu_activate+0x34/0x78)
[  250.917607] [<c019dee8>] (ttwu_activate) from [<c019e320>] (ttwu_do_activate+0x60/0x78)
[  250.918666] [<c019e2c0>] (ttwu_do_activate) from [<c019f2a4>] (ttwu_queue+0xc4/0xd8)
[  250.919693] [<c019f1e0>] (ttwu_queue) from [<c019f5d4>] (try_to_wake_up+0x31c/0x350)
[  250.920723] [<c019f2b8>] (try_to_wake_up) from [<c01a2120>] (default_wake_function+0x40/0x54)
[  250.921860] [<c01a20e0>] (default_wake_function) from [<c03615a0>] (pollwake+0x74/0x80)
[  250.922924] [<c036152c>] (pollwake) from [<c01d7110>] (__wake_up_common+0x84/0xfc)
[  250.923930] [<c01d708c>] (__wake_up_common) from [<c01d7344>] (__wake_up_sync_key+0xa8/0xd0)
[  250.925052] [<c01d729c>] (__wake_up_sync_key) from [<c0a536ec>] (sock_def_readable+0x118/0x1d4)
[  250.926203] [<c0a535d4>] (sock_def_readable) from [<c0a4b710>] (sock_queue_rcv_skb+0x950/0x968)
[  250.927361] [<c0a4adc0>] (sock_queue_rcv_skb) from [<c0bf8a6c>] (raw_rcv+0x3b4/0x3d0)
[  250.928407] [<c0bf86b8>] (raw_rcv) from [<c0bf5da8>] (can_rcv_filter+0x1f4/0x6e4)
[  250.929406] [<c0bf5bb4>] (can_rcv_filter) from [<c0bf63c0>] (can_receive+0x128/0x190)
[  250.930448] [<c0bf6298>] (can_receive) from [<c0bf65d8>] (can_rcv+0x1b0/0x1d0)
[  250.931389]  r4:c015635c
[  250.931805] [<c0bf6428>] (can_rcv) from [<c0a80c44>] (__netif_receive_skb_core+0x15c8/0x1660)
[  250.932943] [<c0a7f67c>] (__netif_receive_skb_core) from [<c0a80e4c>] (__netif_receive_skb+0x170/0x184)
[  250.934189] [<c0a80cdc>] (__netif_receive_skb) from [<c0a83578>] (process_backlog+0x88/0x354)
[  250.935317] [<c0a834f0>] (process_backlog) from [<c0a845a0>] (napi_poll+0x10c/0x5c8)
[  250.936339] [<c0a84494>] (napi_poll) from [<c0a84c54>] (net_rx_action+0x1f8/0x510)
[  250.937346] [<c0a84a5c>] (net_rx_action) from [<c0155acc>] (__do_softirq+0x3f0/0x99c)
[  250.938386] [<c01556dc>] (__do_softirq) from [<c015635c>] (irq_exit+0x178/0x27c)
[  250.939350]  r4:f4a00100
[  250.939758] [<c01561e4>] (irq_exit) from [<c01f7670>] (__handle_domain_irq+0x19c/0x250)
[  250.940823] [<c01f74d4>] (__handle_domain_irq) from [<c01015e4>] (gic_handle_irq+0x50/0x74)
[  250.941926] [<c0101594>] (gic_handle_irq) from [<c0114580>] (__irq_svc+0x40/0x74)
[  250.942902] Exception stack(0xca6df578 to 0xca6df5c0)

 

///

its crash in void __rcu_read_lock(void)

because task is NULL

 

normally sock_def_readable is call by SYS_writev

but use socket(PF_CAN, SOCK_RAW, CAN_RAW) with recvmsg or read will call by irq handle as my attachment

Attachments

Outcomes