I have program that crashes from time to time with a following message in syslog.
Is this possible to modify it in a way, so instead of addresses there would be a readable message about function/line where did it crash?
I have access to program sources, and can lookup for a function via addr2line. However, what interests me is that I want to make it resolve pointers to functions live, so it would be seen in syslog.
Please, share your thoughts on how to implement this
UPD: I saw that it is possible to do by registering a signal handler and executing backtrace() function. Is this a way to do this without modification of a program? Or is it possible to do some generic modification, so every program would execute backtrace upon crashing?
[ 1775.374665] virt-manager[870]: unhandled level 3 translation fault (11) at 0x00000000, esr 0x92000007
[ 1775.383904] pgd = fffffe03dcee0000
[ 1775.387302] [00000000] *pgd=0000004018ea0003, *pud=0000004018ea0003, *pmd=0000004018ea0003, *pte=0000000000000000
[ 1775.397616]
[ 1775.399119] CPU: 2 PID: 870 Comm: virt-manager Tainted: G W 4.0.0-0.rc5.git4.1.fc22.aarch64 #1
[ 1775.408843] Hardware name: AppliedMicro Mustang/Mustang, BIOS 1.1.0-rh-0.15 Feb 20 2015
[ 1775.416836] task: fffffe03dc44da80 ti: fffffe03dc3d4000 task.ti: fffffe03dc3d4000
[ 1775.424320] PC is at 0x3ffad37ae5c
[ 1775.427715] LR is at 0x3ffad37ae5c
[ 1775.431128] pc : [<000003ffad37ae5c>] lr : [<000003ffad37ae5c>] pstate: 60000000
[ 1775.438493] sp : 000003ffe89cd3d0
[ 1775.441820] x29: 000003ffe89cd3d0 x28: 000000003ceb0620
[ 1775.447146] x27: 000000003c9600a0 x26: 0000000000000000
[ 1775.452490] x25: 000003ffb03b0000 x24: 000000003cdf10a0
[ 1775.457804] x23: 000003ffb03af000 x22: 000000003cab57a0
[ 1775.463156] x21: 0000000000000000 x20: 0000000000000001
[ 1775.468477] x19: 000000003cece200 x18: 000003ffb01e2460
[ 1775.473819] x17: 000003ffb715b790 x16: 000003ffb03305b0
[ 1775.479140] x15: 0000000000000020 x14: 0000000000000050
[ 1775.484479] x13: 000000003ceeca18 x12: 000000003ca86110
[ 1775.489799] x11: 000000003ceec9e0 x10: 000000003ceeb270
[ 1775.495142] x9 : 000003ffb7202560 x8 : 0000000000000062
[ 1775.500464] x7 : 0000000000000199 x6 : 0000000000000199
[ 1775.505805] x5 : 000000003ca9f280 x4 : 0000000000000000
[ 1775.511145] x3 : 0000000000000000 x2 : b5107af573d8a600
[ 1775.516458] x1 : 0000000000000000 x0 : 000000003cacbc20
[ 1775.521797]
Related
I'm trying to inject a new submit bio function to the blkdev, from in-tree kernel module.
I'm using
Linux raspberrypi 5.10.76-v7l+
with LSM support
I was able to do it in lower version with no problem, but with the change of the make_request_fn I'm having a problem with the inject.
this is the code :
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10)
queue = bdev_get_queue(bdev);
if (queue) {
vm_hold.blkdev_orig.make_request_fn = queue->make_request_fn;
queue->make_request_fn = test_injected_blkdev_make_request_fn;
}
#else
fops = bdev_get_fops(bdev);
if (fops) {
vm_hold.blkdev_orig.submit_bio = fops->submit_bio;
fops->submit_bio = test_injected_blkdev_make_request_fn;
//blk_mq_submit_bio(fops->submit_bio);
}
#endif // LINUX_VERSION_CODE < KERNEL_VERSION(5,10,44)
the test function is just a sample:
blk_qc_t test_injected_blkdev_make_request_fn(struct bio *bio)
{
pr_emerg("my test submit bio function\n");
return vm_hold.blkdev_orig.submit_bio(bio);
}
when i'm calling my module to perform the injection i'm getting a crash that lock like that:
--- cut here ---
[ 130.295126] Unable to handle kernel paging request at virtual address c0c6551c
[ 130.295141] pgd = 226518d8
[ 130.295152] [c0c6551c] *pgd=80000000007003, *pmd=440000000c0079d(bad)
[ 130.295194] Internal error: Oops: a0e [#1] SMP ARM
[ 130.295200] Modules linked in: rfcomm cmac fuse bnep hci_uart btbcm bluetooth ecdh_generic ecc 8021q garp stp llc brcmfmac brcmutil cfg80211 rfkill raspberrypi_hwmon bcm2835_codec(C) bcm2835_isp(C) bcm2835_v4l2(C) v4l2_mem2mem bcm2835_mmal_vchiq(C) videobuf2_dma_contig videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 snd_bcm2835(C) videobuf2_common snd_pcm snd_timer snd videodev vc_sm_cma(C) mc uio_pdrv_genirq uio i2c_dev ip_tables x_tables ipv6
[ 130.356973] CPU: 3 PID: 1161 Comm: host Tainted: G C 5.10.76-v7l+ #58
[ 130.356977] Hardware name: BCM2835
[ 130.356993] PC is at test_inject_blkdev+0xf4/0x114
[ 130.357008] LR is at __irq_work_queue_local+0x3c/0x70
[ 130.378604] pc : [<c06e2614>] lr : [<c0351bcc>] psr: 60000013
[ 130.378608] sp : ca589e68 ip : ca589d78 fp : ca589e7c
[ 130.378613] r10: 00000003 r9 : 00000000 r8 : beba2644
[ 130.378618] r7 : ca471a80 r6 : c1205048 r5 : c0c6551c r4 : c2574240
[ 130.378627] r3 : c06e0294 r2 : f0fbb462 r1 : 00000d62 r0 : 00004670
[ 130.408779] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 130.408785] Control: 30c5383d Table: 02eeb680 DAC: bb5b2507
[ 130.408792] Process host (pid: 1161, stack limit = 0xa9b229bd)
[ 130.408798] Stack: (0xca589e68 to 0xca58a000)
[ 130.408807] 9e60: c13fd79c c13fd684 ca589e94 ca589e80 c06e26dc c06e252c
[ 130.440451] 9e80: 00004000 c13fd79c ca589ecc ca589e98 c06e3d5c c06e26bc ca589eb4 ca589ea8
[ 130.440458] 9ea0: c0ba4f7c f0fbb462 c1205048 c1205048 beba2644 ca471a80 00005391 00000000
[ 130.440464] 9ec0: ca589f0c ca589ed0 c06e5a40 c06e3cec 00000032 c020bf60 c833c354 00000000
[ 130.465317] 9ee0: 00f3b150 f0fbb462 00000005 c1205048 ca471a80 00005391 ca471a80 beba2644
[ 130.465324] 9f00: ca589fa4 ca589f10 c04574d8 c06e56a4 00000000 00000000 00000000 00000000
[ 130.465330] 9f20: 00000000 00000000 c020bf88 beba2644 c020d244 ca5133c0 c1205048 ca5133c0
[ 130.465336] 9f40: 00000032 00f3b150 ca588000 00000004 ca589f94 ca589f60 c04419b0 c04413c8
[ 130.465342] 9f60: 00000000 00000000 00000000 f0fbb462 ca588000 f0fbb462 00f3b150 00000000
[ 130.465350] 9f80: 00000000 00f3b590 00000036 c0200204 ca588000 00000036 00000000 ca589fa8
[ 130.515053] 9fa0: c0200040 c045737c 00000000 00000000 00000003 00005391 beba2644 00000000
[ 130.515059] 9fc0: 00000000 00000000 00f3b590 00000036 00000000 00000000 b6fdf000 00000000
[ 130.515065] 9fe0: 0002fcac beba2634 0001c214 b6f0651c 80000010 00000003 00000000 00000000
[ 130.539914] Backtrace:
[ 130.539926] [<c06e2520>] (test_inject_blkdev) from [<c06e26dc>] (nanolock_inject+0x2c/0x4c)
[ 130.539932] r5:c13fd684 r4:c13fd79c
[ 130.554836] [<c06e26b0>] (perform_test_inject) from [<c06e3d5c>] (nanolock_end_load_otpm+0x7c/0x2a8)
[ 130.554839] r4:c13fd79c r3:00004000
[ 130.554851] [<c06e3ce0>] (test_inject_blkdev_call) from [<c06e5a40>] (nanolock_ioctl+0x3a8/0x700)
[ 130.576265] r9:00000000 r8:00005391 r7:ca471a80 r6:beba2644 r5:c1205048 r4:c1205048
[ 130.576274] [<c06e5698>] (my_module_ioctl) from [<c04574d8>] (sys_ioctl+0x168/0x8fc)
[ 130.576281] r8:beba2644 r7:ca471a80 r6:00005391 r5:ca471a80 r4:c1205048
[ 130.576288] [<c0457370>] (sys_ioctl) from [<c0200040>] (ret_fast_syscall+0x0/0x28)
[ 130.576293] Exception stack(0xca589fa8 to 0xca589ff0)
[ 130.611458] 9fa0: 00000000 00000000 00000003 00005391 beba2644 00000000
[ 130.611464] 9fc0: 00000000 00000000 00f3b590 00000036 00000000 00000000 b6fdf000 00000000
[ 130.611470] 9fe0: 0002fcac beba2634 0001c214 b6f0651c
[ 130.633154] r10:00000036 r9:ca588000 r8:c0200204 r7:00000036 r6:00f3b590 r5:00000000
[ 130.633156] r4:00000000
[ 130.633163] Code: e3003294 e3040670 e34c306e e3001d62 (e5853000)
[ 130.633212] ---[ end trace 2588a376c135822c ]---
At the older kernel version the code works perfectly. but with the new bio I'm straggling
any reference to the new bio system will help (i used google but i didn't find how to inject the new code properly).
I'm a newbie in Linux driver Field.Now, I has just done with writing Linux driver and I'm testing the accuracy of the function of this driver. The goal of my driver is using FPGA card with CPU ARMv7 through PCIe communication and doing both encryption and decryption in this card. When I test my kernel module, I see this kernel panic. In my test case, I send multiple packets continuously to FPGA card to implement encryption/decryption. However, after doing several packets well, Linux kernel was crash. At first, I think that this kernel crash bug is related to allocating kernel memory and freeing this memory (kzalloc function and kfree function). May be memory allocated for some pointer does not be freed immediately. Can anyone suggests the cause and the solution for this kernel panic?
[ 532.593938] Unable to handle kernel NULL pointer dereference at virtual address 00000001
[ 532.602069] pgd = ecb8c000
[ 532.604780] [00000001] *pgd=2ca83831, *pte=00000000, *ppte=00000000
[532.611066] Internal error: Oops: 17 [#1] SMP ARM
[ 532.615777] Modules linked in: testcrypto(+) huy_crypto xdma ath9k ath9k_common pppoe ppp_async ath9k_hw ath10k_pci ath10k_core ath pppox ppp_generic nf_conntrack_ipv6 mac80211 iptable_nat ipt_REJECT ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_tcpmss xt_statistic xt_state xt_recent xt_policy xt_nat xt_multiport xt_mark xt_mac xt_limit xt_length xt_hl xt_helper xt_esp xt_ecn xt_dscp xt_conntrack xt_connmark xt_connlimit xt_connbytes xt_comment xt_TCPMSS xt_REDIRECT xt_LOG xt_HL xt_FLOWOFFLOAD xt_DSCP xt_CT xt_CLASSIFY slhc nf_reject_ipv4 nf_nat_redirect nf_nat_masquerade_ipv4 nf_conntrack_ipv4 nf_nat_ipv4 nf_nat nf_log_ipv4 nf_flow_table_hw nf_flow_table nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache iptable_raw iptable_mangle iptable_filter ipt_ah ipt_ECN ip_tables crc_ccitt compat sch_cake
[ 532.686456] act_connmark nf_conntrack sch_tbf sch_ingress sch_htb sch_hfsc em_u32 cls_u32 cls_tcindex cls_route cls_matchall cls_fw cls_flow cls_basic act_skbedit act_mirred cryptodev nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 ifb ip6_vti ip_vti xfrm6_mode_tunnel xfrm6_mode_transport xfrm6_mode_beet ipcomp6 xfrm6_tunnel esp6 ah6 xfrm4_tunnel xfrm4_mode_tunnel xfrm4_mode_transport xfrm4_mode_beet ipcomp esp4 ah4 ip6_tunnel tunnel6 tunnel4 ip_tunnel mpls_iptunnel mpls_router mpls_gso xfrm_user xfrm_ipcomp af_key xfrm_algo algif_skcipher algif_hash af_alg sha512_generic md5 echainiv cbc authenc gpio_button_hotplug [last unloaded: testcrypto]
[ 532.748684] CPU: 0 PID: 5563 Comm: insmod Not tainted 4.14.176 #0
[ 532.754789] Hardware name: Marvell Armada 380/385 (Device Tree)
[ 532.760721] task: ef3bde00 task.stack: ef182000
[ 532.765263] PC is at __kmalloc_track_caller+0x100/0x144
[ 532.770499] LR is at 0x89a5
[ 532.773297] pc : [<c01ee8b4>] lr : [<000089a5>] psr: 20000013
[ 532.779576] sp : ef183d98 ip : a0000013 fp : ffffee4b
[ 532.784811] r10: 00000009 r9 : 00008124 r8 : 00000002
[ 532.790046] r7 : 00000001 r6 : ecfe2a40 r5 : 014000c0 r4 : ef001e40
[ 532.796586] r3 : 00000000 r2 : ef7d6a34 r1 : 2ee8d000 r0 : 000089a6
[ 532.803128] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
[ 532.810278] Control: 10c5387d Table: 2cb8c04a DAC: 00000051
[ 532.816035] Process insmod (pid: 5563, stack limit = 0xef182210)
[ 532.822054] Stack: (0xef183d98 to 0xef184000)
[ 532.826419] 3d80: 00000008 c024eb40
[ 532.834616] 3da0: ecfe24c0 00000124 00000002 c01c73b8 ec94b540 ef0181c0 ec94b540 c024eb40
[ 532.842812] 3dc0: 00000000 00000124 bf6780c8 ec94b540 c07088c8 ec94b540 00000124 bf6780c8
[ 532.851008] 3de0: 00000000 c024fcc8 00000000 c07088c8 ec94b540 c025173c 00000000 edfed95c
[ 532.859204] 3e00: ec94b540 c025207c 00001000 00000000 c07088c8 edfed95c 00000000 00000000
[ 532.867401] 3e20: edfed800 edfeda58 ec94b540 c0252a5c 00000000 00000000 c07e21ec c07e21d8
[ 532.875597] 3e40: 00000008 ef183f40 edfed800 edfeda34 edfeda70 0000002c 014000c0 bf678080
[ 532.883793] 3e60: c0a03c48 c0193a30 bf67808c 00007fff bf678080 c0191330 c0a5dce8 bf6780c8
[ 532.891990] 3e80: c0190a50 bf67808c c0702ce4 bf678170 c082dfd8 c07da244 c07da3a0 c0a03c48
[ 532.900186] 3ea0: c07da250 f1523fff ffe00000 ef0e8600 fffff000 c0a5dcc0 014002c0 00000011
[ 532.908382] 3ec0: 00000000 00000000 00000000 00000000 00000000 00000000 6e72656b 00006c65
[ 532.916578] 3ee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 532.924774] 3f00: 00000000 00000000 00000000 00000000 00000000 c9929c40 00000080 00000fe4
[ 532.932970] 3f20: 00000000 00642ff4 f1523fe4 ffffe000 b6f74230 00000051 00000000 c0194110
[ 532.941166] 3f40: f1515bcc f1513000 00010fe4 f1523904 f1523748 f151f760 00004000 00004080
[ 532.949362] 3f60: 00000000 00000000 00000000 000036d0 00000029 0000002a 00000017 00000000
[ 532.957558] 3f80: 00000012 00000000 00000000 00000000 00000003 00000080 c01077a4 ef182000
[ 532.965755] 3fa0: 00000080 c01075a0 00000000 00000000 00632010 00010fe4 b6f74230 00000700
[ 532.973951] 3fc0: 00000000 00000000 00000003 00000080 00010fe4 00000000 00000020 00000000
[ 532.982148] 3fe0: beca6d1c beca6d00 00011d50 b6f2abac 60000010 00632010 00000000 00000000
[ 532.990350] [<c01ee8b4>] (__kmalloc_track_caller) from [<c01c73b8>] (kstrdup+0x30/0x54)
[ 532.998378] [<c01c73b8>] (kstrdup) from [<c024eb40>] (__kernfs_new_node+0x28/0x130)
[ 533.006055] [<c024eb40>] (__kernfs_new_node) from [<c024fcc8>] (kernfs_new_node+0x1c/0x38)
[ 533.014340] [<c024fcc8>] (kernfs_new_node) from [<c025173c>] (__kernfs_create_file+0x18/0xa4)
[ 533.022885] [<c025173c>] (__kernfs_create_file) from [<c025207c>] (sysfs_add_file_mode_ns+0x13c/0x194)
[ 533.032213] [<c025207c>] (sysfs_add_file_mode_ns) from [<c0252a5c>] (internal_create_group+0x194/0x2e8)
[ 533.041630] [<c0252a5c>] (internal_create_group) from [<c0193a30>] (load_module+0x1b74/0x2118)
[ 533.050262] [<c0193a30>] (load_module) from [<c0194110>] (SyS_init_module+0x13c/0x174)
[ 533.058201] [<c0194110>] (SyS_init_module) from [<c01075a0>] (ret_fast_syscall+0x0/0x54)
[ 533.066312] Code: ea00000f e121f00c eaffffd2 e5943014 (e7973003)
[ 533.072445] ---[ end trace bb93ca4b64a48f93 ]---
[ 533.079218] Kernel panic - not syncing: Fatal exception
[ 533.084457] CPU1: stopping
[ 533.087173] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G D 4.14.176 #0
[ 533.094497] Hardware name: Marvell Armada 380/385 (Device Tree)
[ 533.100436] [<c010ecf8>] (unwind_backtrace) from [<c010a9b0>] (show_stack+0x10/0x14)
[ 533.108202] [<c010a9b0>] (show_stack) from [<c0636974>] (dump_stack+0x94/0xa8)
[ 533.115442] [<c0636974>] (dump_stack) from [<c010db38>] (handle_IPI+0xe4/0x190)
[ 533.122769] [<c010db38>] (handle_IPI) from [<c0101494>] (gic_handle_irq+0x8c/0x90)
[ 533.130357] [<c0101494>] (gic_handle_irq) from [<c010b64c>] (__irq_svc+0x6c/0x90)
[ 533.137855] Exception stack(0xef067f80 to 0xef067fc8)
[ 533.142919] 7f80: 00000001 00000000 00000000 c01145a0 ffffe000 c0a03cb8 c0a03c6c 00000000
[ 533.151115] 7fa0: 00000000 414fc091 00000000 00000000 ef067fc8 ef067fd0 c0107f68 c0107f6c
[ 533.159309] 7fc0: 60000013 ffffffff
[ 533.162807] [<c010b64c>] (__irq_svc) from [<c0107f6c>] (arch_cpu_idle+0x34/0x38)
[ 533.170224] [<c0107f6c>] (arch_cpu_idle) from [<c015f6d4>] (do_idle+0xdc/0x19c)
[ 533.177551] [<c015f6d4>] (do_idle) from [<c015f9f0>] (cpu_startup_entry+0x18/0x1c)
[ 533.185139] [<c015f9f0>] (cpu_startup_entry) from [<0010182c>] (0x10182c)
[ 533.193813] Rebooting in 3 seconds..
(Updated)
Moreover, the kernel has been crashed after several packets processed. In the log, I see some bug information related to Insmod function. Here is my code in the Init function module: ( In my Init function, I implement encryption/decryption with one packet request many times by using a loop for and module_param value. )
static int __init test_init(void)
{
for (i = 0; i < req_num; i ++)
{
if (cipher_choice == 3)
{
test_esp_rfc4106(test_choice,endec);
mdelay(1000);
pr_err("--------------------------%d-------------------:
%s - PID:%d\n",__LINE__ , __func__ , current->pid);
pr_err("------------------------Number of req-----------
--------: %d\n",i);
}
}
return 0;
}
You can tell from the log that this happened right at soon as the module was loaded (well, during loading) because insmod is still running. It was creating an entry in '/sys'. This gives you some idea what may have been happening before the crash.
Since the crash is inside kstrdup/kmalloc and not directly related to your code, the most likely cause is either a double free or a buffer overflow in your module's code. Since it was soon after loading the module, probably the problem is in your module's init. No one is going to be able to tell you exactly what went wrong because you didn't post any code.
I'm need to create a loadable kernel module which sends data to another remote computer.
I'm writing to 4.10 kernel.
I tried the netpoll API but all I got was errors and I can't find any new and up-do-date information about socket programming inside the kernel.
can anyone give my an example (or any directions) to it?
int init_netpoll(void)
{
np_t.name = "LRNG";
strlcpy(np_t.dev_name, "enp3s0", IFNAMSIZ);
np_t.local_ip.ip = htonl((unsigned long int)0xc6a80121);
np_t.local_ip.in.s_addr = htonl((unsigned long int)0xc6a80121);
np_t.remote_ip.ip = htonl((unsigned long int)0xc6a80114);
np_t.remote_ip.in.s_addr = htonl((unsigned long int)0xc6a80114);
np_t.ipv6 = 0;//no IPv6
np_t.local_port = 6666;
np_t.remote_port = 80;
///////////////
///////////////
memset(np_t.remote_mac, 0xff, ETH_ALEN);
netpoll_print_options(&np_t);
if(!netpoll_setup(&np_t)) {
return 1;
}
np = &np_t;
return 0;
}
void clean_netpoll(void)
{
//nothing
}
void sendUdp(const char* buf)
{
printk("********** SEND UDP **********");
netpoll_send_udp(np,buf,strlen(buf));
}
The log:
[ 278.702352] ********** SEND UDP **********
[ 278.702353] ------------[ cut here ]------------
[ 278.702358] WARNING: CPU: 2 PID: 2153 at /build/linux-nhaT8l/linux-4.10.0/net/core/netpoll.c:394 netpoll_send_udp+0x443/0x450
[ 278.702359] Modules linked in: netCharDev(OE+) rfcomm bnep btusb btrtl btbcm btintel bluetooth uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_core videodev media wl(POE) intel_rapl x86_pkg_temp_thermal intel_powerclamp snd_hda_codec_hdmi coretemp kvm irqbypass binfmt_misc crct10dif_pclmul snd_hda_codec_realtek snd_hda_codec_generic crc32_pclmul ghash_clmulni_intel cryptd intel_cstate intel_rapl_perf snd_hda_intel snd_hda_codec snd_hda_core snd_hwdep snd_pcm joydev input_leds serio_raw snd_seq_midi snd_seq_midi_event snd_rawmidi thinkpad_acpi nvram snd_seq snd_seq_device cfg80211 snd_timer lpc_ich snd shpchp mei_me mei soundcore mac_hid parport_pc ppdev lp parport ip_tables x_tables autofs4 uas usb_storage i915 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops
[ 278.702393] psmouse ahci drm r8169 libahci mii wmi fjes video
[ 278.702399] CPU: 2 PID: 2153 Comm: insmod Tainted: P OE 4.10.0-33-generic #37-Ubuntu
[ 278.702400] Hardware name: LENOVO 62742BG/62742BG, BIOS H1ET69WW (1.12 ) 11/15/2012
[ 278.702400] Call Trace:
[ 278.702404] dump_stack+0x63/0x81
[ 278.702406] __warn+0xcb/0xf0
[ 278.702409] warn_slowpath_null+0x1d/0x20
[ 278.702411] netpoll_send_udp+0x443/0x450
[ 278.702413] ? netpoll_setup+0x166/0x2d0
[ 278.702416] sendUdp+0x32/0x35 [netCharDev]
[ 278.702417] ? 0xffffffffc025d000
[ 278.702420] netCharDev_init+0x26/0x1000 [netCharDev]
[ 278.702421] ? 0xffffffffc025d000
[ 278.702423] do_one_initcall+0x52/0x1b0
[ 278.702426] ? kmem_cache_alloc_trace+0x142/0x190
[ 278.702428] do_init_module+0x5f/0x200
[ 278.702432] load_module+0x190b/0x1c70
[ 278.702433] ? __symbol_put+0x60/0x60
[ 278.702436] ? ima_post_read_file+0x7e/0xa0
[ 278.702438] ? security_kernel_post_read_file+0x6b/0x80
[ 278.702440] SYSC_finit_module+0xdf/0x110
[ 278.702443] SyS_finit_module+0xe/0x10
[ 278.702445] entry_SYSCALL_64_fastpath+0x1e/0xad
[ 278.702447] RIP: 0033:0x7feb867b39f9
[ 278.702448] RSP: 002b:00007ffd0e884438 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
[ 278.702449] RAX: ffffffffffffffda RBX: 0000563b09907a70 RCX: 00007feb867b39f9
[ 278.702450] RDX: 0000000000000000 RSI: 0000563b091e7f8b RDI: 0000000000000003
[ 278.702451] RBP: 00007feb86a72b00 R08: 0000000000000000 R09: 00007feb86a74ea0
[ 278.702452] R10: 0000000000000003 R11: 0000000000000246 R12: 00007feb86a72b58
[ 278.702453] R13: 00007feb86a72b58 R14: 000000000000270f R15: 0000000000001010
[ 278.702455] ---[ end trace ca1c43e67bc5a307 ]---
[ 278.702460] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040
[ 278.702507] IP: netpoll_send_udp+0x30/0x450
[ 278.702528] PGD 0
[ 278.702550] Oops: 0000 [#1] SMP
[ 278.702567] Modules linked in: netCharDev(OE+) rfcomm bnep btusb btrtl btbcm btintel bluetooth uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_core videodev media wl(POE) intel_rapl x86_pkg_temp_thermal intel_powerclamp snd_hda_codec_hdmi coretemp kvm irqbypass binfmt_misc crct10dif_pclmul snd_hda_codec_realtek snd_hda_codec_generic crc32_pclmul ghash_clmulni_intel cryptd intel_cstate intel_rapl_perf snd_hda_intel snd_hda_codec snd_hda_core snd_hwdep snd_pcm joydev input_leds serio_raw snd_seq_midi snd_seq_midi_event snd_rawmidi thinkpad_acpi nvram snd_seq snd_seq_device cfg80211 snd_timer lpc_ich snd shpchp mei_me mei soundcore mac_hid parport_pc ppdev lp parport ip_tables x_tables autofs4 uas usb_storage i915 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops
[ 278.705010] psmouse ahci drm r8169 libahci mii wmi fjes video
[ 278.705917] CPU: 2 PID: 2153 Comm: insmod Tainted: P W OE 4.10.0-33-generic #37-Ubuntu
[ 278.706956] Hardware name: LENOVO 62742BG/62742BG, BIOS H1ET69WW (1.12 ) 11/15/2012
[ 278.707781] task: ffff95ea2cc78000 task.stack: ffffa707c2318000
[ 278.708618] RIP: 0010:netpoll_send_udp+0x30/0x450
[ 278.709876] RSP: 0018:ffffa707c231bc30 EFLAGS: 00010286
[ 278.711806] RAX: 0000000000000024 RBX: ffffffffc07e33fa RCX: 0000000000000006
[ 278.713766] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000009
[ 278.715709] RBP: ffffa707c231bc70 R08: 0000000000000001 R09: 000000000000035c
[ 278.716998] R10: ffffffffafe06a40 R11: 0000000000000000 R12: 0000000000000000
[ 278.719051] R13: 0000000000000004 R14: ffff95ea0b9b7240 R15: ffff95ea0b9b7288
[ 278.721031] FS: 00007feb86c7c700(0000) GS:ffff95ea9e280000(0000) knlGS:0000000000000000
[ 278.723056] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 278.725069] CR2: 0000000000000040 CR3: 000000008bb50000 CR4: 00000000001406e0
[ 278.727111] Call Trace:
[ 278.729143] ? netpoll_setup+0x166/0x2d0
[ 278.731205] sendUdp+0x32/0x35 [netCharDev]
[ 278.733273] ? 0xffffffffc025d000
[ 278.735303] netCharDev_init+0x26/0x1000 [netCharDev]
[ 278.737356] ? 0xffffffffc025d000
[ 278.739401] do_one_initcall+0x52/0x1b0
[ 278.741440] ? kmem_cache_alloc_trace+0x142/0x190
[ 278.743465] do_init_module+0x5f/0x200
[ 278.745506] load_module+0x190b/0x1c70
[ 278.747510] ? __symbol_put+0x60/0x60
[ 278.749517] ? ima_post_read_file+0x7e/0xa0
[ 278.751477] ? security_kernel_post_read_file+0x6b/0x80
[ 278.753435] SYSC_finit_module+0xdf/0x110
[ 278.755327] SyS_finit_module+0xe/0x10
[ 278.757264] entry_SYSCALL_64_fastpath+0x1e/0xad
[ 278.759180] RIP: 0033:0x7feb867b39f9
[ 278.761256] RSP: 002b:00007ffd0e884438 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
[ 278.761260] RAX: ffffffffffffffda RBX: 0000563b09907a70 RCX: 00007feb867b39f9
[ 278.761261] RDX: 0000000000000000 RSI: 0000563b091e7f8b RDI: 0000000000000003
[ 278.761263] RBP: 00007feb86a72b00 R08: 0000000000000000 R09: 00007feb86a74ea0
[ 278.761265] R10: 0000000000000003 R11: 0000000000000246 R12: 00007feb86a72b58
[ 278.761266] R13: 00007feb86a72b58 R14: 000000000000270f R15: 0000000000001010
[ 278.761269] Code: 55 48 89 e5 41 57 41 56 41 55 41 54 49 89 fc 53 41 89 d5 48 83 ec 18 48 89 34 24 9c 58 0f 1f 44 00 00 f6 c4 02 0f 85 ee 03 00 00 <41> 80 7c 24 40 00 41 8d 45 08 41 8d 55 1c bb 0a 00 00 00 41 bf
[ 278.761336] RIP: netpoll_send_udp+0x30/0x450 RSP: ffffa707c231bc30
[ 278.761337] CR2: 0000000000000040
[ 278.772275] ---[ end trace ca1c43e67bc5a308 ]---
Is there anyway I can debug a kernel code to see maybe the error is somewhere inside the net poll API?
P.S.
for those who will say I should to this in the userspace, I did my thinking and I really need to this inside the kernel space.
I've also rad the following question and it was no help for me:
Sending UDP packets from the Linux Kernel
Sending UDP packets from the Linux Kernel (different question)
As I tried to find the solution by using netpoll, I found that using socket might be more useful.
I found this link of a github repository that have exactly the example of echo client server in the linux kernel.
Hope it will help everyone who searched for it too.
Im getting a "Unable to handle kernel paging request" kernel oops (see error message below) and I can't see why. As far as I know, this error message occurs, when I'm accessing memory that I shouldn't access.But in this case the error message seems to trigger in/directly after the allocation.
So my question is: is there another reason for this oops to occur?
Here's the error message:
[ 68.229185] Unable to handle kernel paging request at virtual address 5761308c
[ 68.236398] pgd = c0004000
[ 68.239094] [5761308c] *pgd=00000000
[ 68.242670] Internal error: Oops: 5 [#1] SMP ARM
[ 68.247266] Modules linked in: riddler(O)
[ 68.251285] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W O 4.1.0 #14
[ 68.258388] Hardware name: Altera SOCFPGA
[ 68.262380] task: c07cffa8 ti: c07ca000 task.ti: c07ca000
[ 68.267763] PC is at kmem_cache_alloc_trace+0x60/0x184
[ 68.272883] LR is at riddler_nf_queue_handler+0x164/0x6d4 [riddler]
[ 68.279122] pc : [<c0118ea0>] lr : [<bf000630>] psr: 200f0113
[ 68.279122] sp : c07cbb80 ip : c07cbbc0 fp : c07cbbbc
[ 68.290546] r10: 00000000 r9 : ed66d800 r8 : 0000000c
[ 68.295746] r7 : edc01f00 r6 : bf000630 r5 : 00008020 r4 : 5761308c
[ 68.302243] r3 : 00000000 r2 : c07cbb80 r1 : c07cbce0 r0 : 2da0f000
[ 68.308741] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
[ 68.316015] Control: 10c5387d Table: 2cd3004a DAC: 00000015
[ 68.321734] Process swapper/0 (pid: 0, stack limit = 0xc07ca218)
[ 68.327713] Stack: (0xc07cbb80 to 0xc07cc000)
[ 68.332054] bb80: 000005dc c0448cdc c07cc404 00004058 2d66e000 ed5c99d0 bf001cfc ed5a8800
[ 68.340196] bba0: bf001cfc 000005c0 ed66d800 00000000 c07cbc14 c07cbbc0 bf000630 c0118e4c
[ 68.348338] bbc0: c07cbc9c 00000044 c07cbc14 c07cbbd8 00000000 00000000 00000001 00484c68
[ 68.356479] bbe0: 000005c0 0000001c 00000044 ed5a8800 c05b83f0 00000044 bf001984 edfebe40
[ 68.364621] bc00: bf001940 00000000 c07cbc64 c07cbc18 c0484e3c bf0004d8 c07cbc3c 00000000
[ 68.372762] bc20: 80000000 c04bbc02 ede3f000 00000000 00000000 c0489f30 c0483d08 c07cbc9c
[ 68.380903] bc40: edfebe40 c07cbc6c c07cdae8 00000003 ede3f000 c07cd524 c07cbc94 c07cbc68
[ 68.389045] bc60: c0483da8 c0484d00 edc817c0 bf001940 c07c9340 00000050 ecc91340 edfebe40
[ 68.397186] bc80: ede3f000 00000008 c07cbcd4 c07cbc98 c048a880 c0483d54 c07cbccc 00000000
[ 68.405327] bca0: 80000000 c04bbc02 ede3f000 00000000 00000000 c0489f30 edfebe40 c07ce898
[ 68.413468] bcc0: c048a4c4 ede3f000 c07cbd24 c07cbcd8 c0457b00 c048a4d0 00000000 ede3f000
[ 68.421610] bce0: edfebe40 ede3f580 00000020 edfebe40 00000000 ede3f05c c07cbd14 c07cd514
[ 68.429752] bd00: edfebe40 ede3f580 00000020 00000100 00000000 00000001 c07cbd3c c07cbd28
[ 68.437893] bd20: c045a34c c0457440 c07cd514 edfebe40 c07cbd6c c07cbd40 c045a400 c045a320
[ 68.446034] bd40: 2690390a 14562ba2 edfebe40 ede3f580 00000020 00000100 00000003 edfebe40
[ 68.454175] bd60: c07cbd8c c07cbd70 c045ada8 c045a3b4 ede3f580 edfebe40 000005ea 00000020
[ 68.462316] bd80: c07cbdec c07cbd90 c03a50c8 c045acec 00000000 e2d32d80 0000000f ee1d5400
[ 68.470456] bda0: 00000001 ede3f4c0 c07cbde4 c07cbdb8 c07d153c 00000100 00000040 00000002
[ 68.478597] bdc0: ffffffff ede3f580 00000001 00000040 0000012c ee1d8b80 c07cc100 c07cbe18
[ 68.486738] bde0: c07cbe54 c07cbdf0 c045be80 c03a4e04 ffffa577 c06b2a60 c07cd514 c07cd514
[ 68.494880] be00: c082ce31 ee1d8b80 c082f608 2da0f000 c07c9b80 ffffa579 c07cbe18 c07cbe18
[ 68.503021] be20: c07cbe20 c07cbe20 00000001 c07cc08c 00000003 00000000 00000100 c07ca000
[ 68.511163] be40: 00000008 c082cf0c c07cbebc c07cbe58 c002a684 c045bc68 00000011 edd41180
[ 68.519304] be60: edd411e0 00200000 c07cc100 ffffa578 c05769b4 0000000a c08302c0 c07c52c8
[ 68.527445] be80: c07cc080 c07cbe58 0000000c 00000004 00000000 c07c7c2c 00000024 00000000
[ 68.535587] bea0: 00000000 edc10800 c07cc450 c05769a8 c07cbed4 c07cbec0 c002ab68 c002a5a0
[ 68.543728] bec0: c07c7c2c 00000024 c07cbefc c07cbed8 c006738c c002aaec fee0010c c07cce2c
[ 68.551870] bee0: c07cbf20 fee00100 c082d4c0 c07cc450 c07cbf1c c07cbf00 c0009470 c0067328
[ 68.560011] bf00: c0010648 600f0013 ffffffff c07cbf54 c07cbf74 c07cbf20 c0014680 c0009448
[ 68.568153] bf20: 00000000 00000000 000198a0 c0021be0 00000000 c07ca000 c07cc49c ffffffff
[ 68.576295] bf40: c082d4c0 c07cc450 c05769a8 c07cbf74 c07cbf78 c07cbf68 c0010644 c0010648
[ 68.584437] bf60: 600f0013 ffffffff c07cbf9c c07cbf78 c005db84 c001060c 00000000 c082cc99
[ 68.592578] bf80: c07c5304 c07cbf78 c0570680 ffffffff c07cbfac c07cbfa0 c056be78 c005d9f4
[ 68.600719] bfa0: c07cbff4 c07cbfb0 c0763cc0 c056bdfc ffffffff ffffffff c07636d8 00000000
[ 68.608861] bfc0: 00000000 c07a98c8 00000000 c082fc14 c07cc440 c07a98c4 c07d1218 0000406a
[ 68.617002] bfe0: 413fc090 00000000 00000000 c07cbff8 0000807c c0763978 00000000 00000000
[ 68.625154] [<c0118ea0>] (kmem_cache_alloc_trace) from [<bf000630>] (riddler_nf_queue_handler+0x164/0x6d4 [riddler])
[ 68.635638] [<bf000630>] (riddler_nf_queue_handler [riddler]) from [<c0484e3c>] (nf_queue+0x148/0x17c)
[ 68.644907] [<c0484e3c>] (nf_queue) from [<c0483da8>] (nf_hook_slow+0x60/0xfc)
[ 68.652104] [<c0483da8>] (nf_hook_slow) from [<c048a880>] (ip_rcv+0x3bc/0x4c4)
[ 68.659308] [<c048a880>] (ip_rcv) from [<c0457b00>] (__netif_receive_skb_core+0x6cc/0x874)
[ 68.667542] [<c0457b00>] (__netif_receive_skb_core) from [<c045a34c>] (__netif_receive_skb+0x38/0x94)
[ 68.676724] [<c045a34c>] (__netif_receive_skb) from [<c045a400>] (netif_receive_skb_internal+0x58/0xcc)
[ 68.686077] [<c045a400>] (netif_receive_skb_internal) from [<c045ada8>] (napi_gro_receive+0xc8/0xf4)
[ 68.695176] [<c045ada8>] (napi_gro_receive) from [<c03a50c8>] (stmmac_poll+0x2d0/0x644)
[ 68.703148] [<c03a50c8>] (stmmac_poll) from [<c045be80>] (net_rx_action+0x224/0x354)
[ 68.710864] [<c045be80>] (net_rx_action) from [<c002a684>] (__do_softirq+0xf0/0x304)
[ 68.718577] [<c002a684>] (__do_softirq) from [<c002ab68>] (irq_exit+0x88/0xc0)
[ 68.725774] [<c002ab68>] (irq_exit) from [<c006738c>] (__handle_domain_irq+0x70/0xc4)
[ 68.733575] [<c006738c>] (__handle_domain_irq) from [<c0009470>] (gic_handle_irq+0x34/0x6c)
[ 68.741893] [<c0009470>] (gic_handle_irq) from [<c0014680>] (__irq_svc+0x40/0x54)
[ 68.749340] Exception stack(0xc07cbf20 to 0xc07cbf68)
[ 68.754371] bf20: 00000000 00000000 000198a0 c0021be0 00000000 c07ca000 c07cc49c ffffffff
[ 68.762512] bf40: c082d4c0 c07cc450 c05769a8 c07cbf74 c07cbf78 c07cbf68 c0010644 c0010648
[ 68.770650] bf60: 600f0013 ffffffff
[ 68.774133] [<c0014680>] (__irq_svc) from [<c0010648>] (arch_cpu_idle+0x48/0x4c)
[ 68.781508] [<c0010648>] (arch_cpu_idle) from [<c005db84>] (cpu_startup_entry+0x19c/0x264)
[ 68.789743] [<c005db84>] (cpu_startup_entry) from [<c056be78>] (rest_init+0x88/0x8c)
[ 68.797465] [<c056be78>] (rest_init) from [<c0763cc0>] (start_kernel+0x354/0x360)
[ 68.804917] Code: e7914000 e3540000 0a000038 e5973014 (e7949003)
[ 68.811024] ---[ end trace 11b433a852b633dc ]---
And here's the code segment that's causing it (I think, I used gdb "list *(riddler_nf_queue_handler)+0x164" to find it):
new = (struct fpga_kfifo_entry *) kzalloc(sizeof(struct fpga_kfifo_entry), GFP_ATOMIC);
new->entry = entry;
new->dma_buffer = dma_buffer; //+0x164 is here
new->dma_buffer_size = data_length_pad;
if(!(kfifo_put(&irq_fifo, new))) {
// FIFO was full
#ifdef DEBUG
pr_info("IRQ Fifo is full, couldn't add new entry!\n");
#endif
kfree(dma_buffer);
kfree(new);
nf_reinject(entry, NF_DROP);
return 0;
}
dma_buffer is allocated in the same function, but earlier:
data_length_pad = round_to_word_size(data_length + 1);
dma_buffer = (unsigned char *) kzalloc(data_length_pad, GFP_ATOMIC);
if (!dma_buffer) {
kfree(dma_buffer);
nf_reinject(entry, NF_DROP);
return 0;
} else {
// Only continue when allocation was successful
dma_buffer[data_length_pad - 1] = (unsigned char) data_length_pad - data_length;
}
Thanks in advance!
I have wrote this simple module to handle a device and call some of its power management methods such as .suspend and .resume. At its initialization, the module simple lookup for a particular device and try to call its methods.
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/pci.h>
static int __init mfps_driver_init(void){
struct pci_dev *dev = NULL;
struct pci_driver *driver = NULL;
struct device *device = NULL;
dev = pci_get_device(0x8086, 0x15a2, NULL);
if((dev == NULL) || (dev == 0)){
printk(KERN_INFO "LEONZO: NOTHING FOUND SIZE %ld\n", sizeof(dev));
} else {
driver = dev->driver;
printk(KERN_INFO "LEONZO: I FOUND THE DEVICE OF THE SIZE %ld\n", sizeof(dev));
printk(KERN_INFO "LEONZO: HERE IS ITS DRIVER NAME %s\n", driver->name);
printk(KERN_INFO "LEONZO: CALLING IT SUSPEND METHOD\n");
*device = dev->dev;
device_lock(device);
device_unlock(device);
}
return 0;
}
static void __exit mfps_driver_exit(void){
}
module_init(mfps_driver_init);
module_exit(mfps_driver_exit);
The code compile successfully. But the I get a kernel bug when I load the module:
sudo insmod MyFirstPowerState.ko
And the dmesg show the following output
[ 59.545180] MyFirstPowerState: module license 'unspecified' taints kernel.
[ 59.545183] Disabling lock debugging due to kernel taint
[ 59.546010] LEONZO: I FOUND THE DEVICE OF THE SIZE 8
[ 59.546012] LEONZO: HERE IS ITS DRIVER NAME e1000e
[ 59.546013] LEONZO: CALLING IT SUSPEND METHOD
[ 59.546021] BUG: unable to handle kernel NULL pointer dereference at (null)
[ 59.546051] IP: [<ffffffffc011907e>] mfps_driver_init+0x7e/0x1000 [MyFirstPowerState]
[ 59.546077] PGD 0
[ 59.546085] Oops: 0002 [#1] SMP
[ 59.546097] Modules linked in: MyFirstPowerState(POE+) xt_CHECKSUM arc4 iwlmvm mac80211 snd_hda_codec_hdmi snd_hda_codec_realtek iwlwifi snd_hda_codec_generic rtsx_pci_ms memstick cfg80211 nf_conntrack_netbios_ns nf_conntrack_broadcast ipt_MASQUERADE nf_nat_masquerade_ipv4 xt_tcpudp ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 xt_conntrack ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw iptable_filter ip_tables x_tables dm_crypt hp_wmi sparse_keymap intel_rapl iosf_mbi x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm crct10dif_pclmul dm_multipath crc32_pclmul scsi_dh aesni_intel aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd joydev serio_raw lpc_ich uvcvideo snd_seq_midi snd_seq_midi_event snd_rawmidi snd_hda_intel snd_hda_controller snd_hda_codec videobuf2_vmalloc snd_hwdep shpchp snd_pcm videobuf2_memops videobuf2_core v4l2_common snd_seq e1000e(OE) i915_bpo ptp mei_me pps_core mei videodev media snd_seq_device intel_ips snd_timer drm_kms_helper drm btusb snd i2c_algo_bit soundcore 8250_fintek hp_accel lis3lv02d input_polldev tpm_infineon hp_wireless mac_hid parport_pc ppdev lp parport rfcomm bnep bluetooth binfmt_misc btrfs xor raid6_pq dm_mirror dm_region_hash dm_log uas usb_storage hid_generic usbhid hid rtsx_pci_sdmmc ahci psmouse libahci rtsx_pci wmi video
[ 59.546577] CPU: 1 PID: 4180 Comm: insmod Tainted: P OE 3.19.0-51-generic #58~14.04.1-Ubuntu
[ 59.546613] Hardware name: Hewlett-Packard HP EliteBook 840 G2/2216, BIOS M71 Ver. 01.05 03/26/2015
[ 59.546648] task: ffff880241a7b110 ti: ffff880242f68000 task.ti: ffff880242f68000
[ 59.546678] RIP: 0010:[<ffffffffc011907e>] [<ffffffffc011907e>] mfps_driver_init+0x7e/0x1000 [MyFirstPowerState]
[ 59.546720] RSP: 0018:ffff880242f6bd18 EFLAGS: 00010246
[ 59.546741] RAX: 0000000000000000 RBX: ffff880245b4d000 RCX: 00000000000000ae
[ 59.546772] RDX: 0000000000000000 RSI: ffff880245b4d098 RDI: 0000000000000000
[ 59.546807] RBP: ffff880242f6bd28 R08: 000000000000000a R09: 0000000000000000
[ 59.546839] R10: 0000000000000d53 R11: ffff880242f6b9de R12: ffffffffc06a8000
[ 59.546868] R13: 0000000000000000 R14: ffffffffc0119000 R15: ffff880242f6bef8
[ 59.546900] FS: 00007f8787aa6740(0000) GS:ffff88024f440000(0000) knlGS:0000000000000000
[ 59.546921] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 59.546936] CR2: 0000000000000000 CR3: 0000000244393000 CR4: 00000000003407e0
[ 59.546955] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 59.546978] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 59.547006] Stack:
[ 59.547014] ffffffff81c1d060 ffff880204cd3280 ffff880242f6bda8 ffffffff81002144
[ 59.547046] 0000000000000001 0000000000000002 ffff8801f8ddc4c0 0000000000000001
[ 59.547079] ffff880242f6bd88 ffffffff811cef19 ffffffff810f7aac 0000000000000018
[ 59.547114] Call Trace:
[ 59.547131] [<ffffffff81002144>] do_one_initcall+0xd4/0x210
[ 59.547162] [<ffffffff811cef19>] ? kmem_cache_alloc_trace+0x199/0x220
[ 59.547194] [<ffffffff810f7aac>] ? load_module+0x164c/0x1cc0
[ 59.547222] [<ffffffff810f7ae5>] load_module+0x1685/0x1cc0
[ 59.547247] [<ffffffff810f3380>] ? store_uevent+0x40/0x40
[ 59.547274] [<ffffffff810f8296>] SyS_finit_module+0x86/0xb0
[ 59.547298] [<ffffffff817b788d>] system_call_fastpath+0x16/0x1b
[ 59.547314] Code: c7 80 c0 4b c0 31 c0 e8 19 14 69 c1 48 c7 c7 a8 c0 4b c0 31 c0 e8 0b 14 69 c1 31 c0 48 8d b3 98 00 00 00 b9 ae 00 00 00 48 89 c7 <f3> a5 bf 60 00 00 00 e8 26 c7 69 c1 bf 60 00 00 00 e8 ac c5 69
[ 59.547393] RIP [<ffffffffc011907e>] mfps_driver_init+0x7e/0x1000 [MyFirstPowerState]
[ 59.547416] RSP <ffff880242f6bd18>
[ 59.547425] CR2: 0000000000000000
[ 59.554577] ---[ end trace 42e3b1c73677cdfa ]---
I also notice that it is therefore impossible to remove the module:
sudo rmmod MyFirstPowerState.ko
rmmod: ERROR: Module MyFirstPowerState is in use
Any idea of what this code mean and how to correct the error ?
I will be attempting to explain the massive wall of text that is dmesg bellow. As a note the values in brackets to the left are times I forget with what exactly they are in relation to but for you they don't really matter.
[ 59.545180] MyFirstPowerState: module license 'unspecified' taints kernel.
[ 59.545183] Disabling lock debugging due to kernel taint
This is because you did not declare a module license. Usually you will see people put something like this in their code in the same section as the module_init.
MODULE_LICENSE("GPL");
[ 59.546010] LEONZO: I FOUND THE DEVICE OF THE SIZE 8
[ 59.546012] LEONZO: HERE IS ITS DRIVER NAME e1000e
[ 59.546013] LEONZO: CALLING IT SUSPEND METHOD
These are your printk messages nothing really special here.
[ 59.546021] BUG: unable to handle kernel NULL pointer dereference at (null)
Here is where the cause for your crash actually lives. The kernel tried to dereference a NULL pointer which causes a seg fault. For more details on what exactly that means see here. As Ian noted in the comments earlier it looks like the cause of your crash is you put *device=dev->dev instead of device=dev->dev. In the code you have you attempted to assign the value device points to to dev->dev however since device=NULL currently you attempted to dereference NULL causing a crash.
[ 59.546051] IP: [] mfps_driver_init+0x7e/0x1000 [MyFirstPowerState]
[ 59.546648] task: ffff880241a7b110 ti: ffff880242f68000 task.ti: ffff880242f68000
The chunk of errors contained within those above do not have much valuable to you currently and are more for people who have deployed something and some specific user has a problem. It is listing things like the hardware installed, the module that caused the crash, and modules that is also calling all things that in your case are very well known.
[ 59.546678] RIP: 0010:[] [] mfps_driver_init+0x7e/0x1000 [MyFirstPowerState][ 59.547079] ffff880242f6bd88 ffffffff811cef19 ffffffff810f7aac 0000000000000018
Everything in this section is assembly information which if you have no assembly experience means nothing to you although I would suggest knowing the basics it does help in these cases. The top half is registers and their current values and the bottom half is the current stack frame.
> [ 59.547114] Call Trace:
[ 59.547131] [<ffffffff81002144>] do_one_initcall+0xd4/0x210
[ 59.547162] [<ffffffff811cef19>] ? kmem_cache_alloc_trace+0x199/0x220
[ 59.547194] [<ffffffff810f7aac>] ? load_module+0x164c/0x1cc0
Everything within the call trace can be exceptionally helpful especially when the module becomes long and difficult to debug with things like interrupts. Basically it is listing out every single function call (or otherwise) the system has made to lead to this crash. In your case since you went from the load module straight to the crash the trace really only has your load_module along with some wrappers and some deep system calls. However, if say your load module called another function and that caused the crash you could see this call path here.
The last little bit appears to be more registers.
Hopefully that explained the wall of text that you get from dmesg when you cause a kernel issue (not sure if this is a panic someone please correct me). If there is anything that is still vague I'll try to explain although I am by no means an expert on this.