Я использую generi c netlink для отправки строк из пользовательского пространства в ядро. Для этого у меня есть следующий атрибут:
struct nla_policy const l_policy[ATTR_COUNT] = {
[STATE_NAME] = {.type = NLA_STRING},
[MAX_ALLOC] = {.type = NLA_U64},
[EXEC_CODE] = {.type = NLA_STRING},
};
, где EXEC_CODE
- это атрибут, с которым я столкнулся с проблемами. Потому что, когда я хочу отправить, скажем, строку размером 659 байтов, я могу сделать это хорошо, но когда я отправляю строку со строкой 2875 байтов, я получаю панику ядра со следующим сообщением:
[ 1420.762822] BUG: kernel NULL pointer dereference, address: 0000000000000004
[ 1420.762825] #PF: supervisor read access in kernel mode
[ 1420.762826] #PF: error_code(0x0000) - not-present page
[ 1420.762828] PGD 0 P4D 0
[ 1420.762830] Oops: 0000 [#1] SMP PTI
[ 1420.762833] CPU: 2 PID: 2461 Comm: lua5.3 Tainted: G OE 5.3.0-59-generic #53~18.04.1-Ubuntu
[ 1420.762834] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[ 1420.762840] RIP: 0010:execute_lua_code+0x35/0x90 [lunatik]
[ 1420.762842] Code: 53 48 8b 46 20 48 89 f3 48 8b 78 08 4c 8b 60 18 48 83 c7 04 e8 8c f9 ff ff 48 85 c0 75 0a b8 ff ff ff ff 5b 41 5c 5d c3 31 d2 <41> 80 7c 24 04 00 49 8d 44 24 05 74 0d 48 83 c0 01 83 c2 01 80 78
[ 1420.762843] RSP: 0018:ffffae4a81aa7a38 EFLAGS: 00010246
[ 1420.762845] RAX: ffff9337cc6cb280 RBX: ffffae4a81aa7aa8 RCX: 0000000000000000
[ 1420.762846] RDX: 0000000000000000 RSI: ffff9337661b5818 RDI: ffff9337cc6cb2b0
[ 1420.762847] RBP: ffffae4a81aa7a48 R08: 0000000000000000 R09: 0000000000000000
[ 1420.762848] R10: ffffae4a81aa7b68 R11: ffffae4a81aa7b68 R12: 0000000000000000
[ 1420.762850] R13: ffff9337661b5814 R14: ffff93376d772b00 R15: ffffffff973dcc00
[ 1420.762851] FS: 00007feb88d68280(0000) GS:ffff9337d5b00000(0000) knlGS:0000000000000000
[ 1420.762853] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1420.762854] CR2: 0000000000000004 CR3: 00000000a62a8003 CR4: 00000000000606e0
[ 1420.762862] Call Trace:
[ 1420.762867] genl_family_rcv_msg+0x21c/0x490
[ 1420.762870] ? __netlink_sendskb+0x53/0x70
[ 1420.762873] genl_rcv_msg+0x4c/0x90
[ 1420.762875] ? genl_family_rcv_msg+0x490/0x490
[ 1420.762878] netlink_rcv_skb+0x51/0x120
[ 1420.762880] genl_rcv+0x28/0x40
[ 1420.762882] netlink_unicast+0x1a4/0x250
[ 1420.762885] netlink_sendmsg+0x2eb/0x3f0
[ 1420.762888] sock_sendmsg+0x63/0x70
[ 1420.762890] ____sys_sendmsg+0x200/0x280
[ 1420.762893] ___sys_sendmsg+0x88/0xd0
[ 1420.762895] ? ___sys_recvmsg+0xa2/0xe0
[ 1420.762899] __sys_sendmsg+0x63/0xa0
[ 1420.762901] ? __sys_sendmsg+0x63/0xa0
[ 1420.762904] __x64_sys_sendmsg+0x1f/0x30
[ 1420.762907] do_syscall_64+0x5a/0x130
[ 1420.762910] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 1420.762912] RIP: 0033:0x7feb880b5574
[ 1420.762914] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b5 0f 1f 80 00 00 00 00 48 8d 05 89 b1 2c 00 8b 00 85 c0 75 13 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 41 89 d4 55 48 89 f5 53
[ 1420.762915] RSP: 002b:00007fff33b6c3c8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
[ 1420.762917] RAX: ffffffffffffffda RBX: 000055d0b80342c0 RCX: 00007feb880b5574
[ 1420.762918] RDX: 0000000000000000 RSI: 00007fff33b6c400 RDI: 0000000000000003
[ 1420.762919] RBP: 000055d0b80347a0 R08: 0000000000000014 R09: 000055d0b8036d80
[ 1420.762920] R10: 0000000000000000 R11: 0000000000000246 R12: 000055d0b80341d0
[ 1420.762921] R13: 00007fff33b6c400 R14: 00007feb88d7dc21 R15: 000055d0b8028a00
[ 1420.762923] Modules linked in: lunatik(OE) intel_rapl_msr intel_rapl_common crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64 crypto_simd cryptd glue_helper snd_intel8x0 intel_rapl_perf snd_ac97_codec joydev ac97_bus snd_pcm snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq snd_seq_device snd_timer input_leds snd soundcore mac_hid serio_raw vboxguest(OE) sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables autofs4 hid_generic usbhid hid psmouse vboxvideo(OE) ttm ahci drm_kms_helper i2c_piix4 libahci syscopyarea sysfillrect sysimgblt fb_sys_fops drm e1000 pata_acpi video
[ 1420.762948] CR2: 0000000000000004
[ 1420.762950] ---[ end trace edaad5d1932bfc8d ]---
[ 1420.762955] RIP: 0010:execute_lua_code+0x35/0x90 [lunatik]
[ 1420.762957] Code: 53 48 8b 46 20 48 89 f3 48 8b 78 08 4c 8b 60 18 48 83 c7 04 e8 8c f9 ff ff 48 85 c0 75 0a b8 ff ff ff ff 5b 41 5c 5d c3 31 d2 <41> 80 7c 24 04 00 49 8d 44 24 05 74 0d 48 83 c0 01 83 c2 01 80 78
[ 1420.762958] RSP: 0018:ffffae4a81aa7a38 EFLAGS: 00010246
[ 1420.762959] RAX: ffff9337cc6cb280 RBX: ffffae4a81aa7aa8 RCX: 0000000000000000
[ 1420.762960] RDX: 0000000000000000 RSI: ffff9337661b5818 RDI: ffff9337cc6cb2b0
[ 1420.762961] RBP: ffffae4a81aa7a48 R08: 0000000000000000 R09: 0000000000000000
[ 1420.762962] R10: ffffae4a81aa7b68 R11: ffffae4a81aa7b68 R12: 0000000000000000
[ 1420.762964] R13: ffff9337661b5814 R14: ffff93376d772b00 R15: ffffffff973dcc00
[ 1420.762965] FS: 00007feb88d68280(0000) GS:ffff9337d5b00000(0000) knlGS:0000000000000000
[ 1420.762966] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1420.762967] CR2: 0000000000000004 CR3: 00000000a62a8003 CR4: 00000000000606e0
Есть ли ограничение в типе NLA_STRING
? Если есть, то какой это предел? А как отправить большие строки с помощью generi c netlink?