Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sun, 16 Dec 2018 19:28:51 +0100
From: Adam Zabrocki <pi3@....com.pl>
To: lkrg-users@...ts.openwall.com
Subject: Re: Ubuntu 18.04 - kzalloc() can't allocate memory

We sometimes do, depends on the use case. In general, I've in plans to rewrite 
some of the *_JUMP_LABEL support logic. This will change memory handling logic 
and significantly reduce memory footprint.
Unfortunately, I didn't have time to do it yet, because there is always 
something more important to do (like research potential ideas of protecting VFS 
layer which you leverage to bypass LKRG ;-))

Thanks,
Adam

On Sun, Dec 16, 2018 at 08:16:42PM +0400, Ilya Matveychikov wrote:
> Why not to use vzalloc() (or vmalloc/memset-wrapper) instead?
> 
> > On Dec 15, 2018, at 9:27 PM, Adam Zabrocki <pi3@....com.pl> wrote:
> > 
> > Hi,
> > 
> > kzalloc() might fail if you don't have enough memory. Are you trying to run 
> > LKRG on a VM? If yes you could try to increase allocated memory.
> > 
> > Thanks,
> > Adam
> > 
> > On Fri, Dec 14, 2018 at 03:28:46PM -0300, Diego M. Vadell wrote:
> >> Hello everyone
> >> 
> >>    I compiled lkrg (tried both 0.5 and main) in an ubuntu 18.04 ( kernel 
> >> 4.15.0-42-generic #45-Ubuntu SMP, gcc version 7.3.0), without errors, but 
> >> when I insmod any the module I get killed:
> >> 
> >> $ sudo insmod output/p_lkrg.ko
> >> Killed
> >> 
> >>    And I have this dmesg output:
> >> 
> >> [ 2273.162887] insmod: page allocation failure: order:7, mode:0x108c020(G
> >> FP_ATOMIC|__GFP_COMP|__GFP_ZERO), nodemask=(null)
> >> [ 2273.162890] insmod cpuset=/ mems_allowed=0
> >> [ 2273.162897] CPU: 0 PID: 9212 Comm: insmod Tainted: P        W  OE    4
> >> .15.0-42-generic #45-Ubuntu
> >> 
> >> Dec 14 15:05:30 mordor kernel: [ 2272.156219] [p_lkrg] Loading LKRG...
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780685] WARNING: CPU: 0 PID: 9212 
> >> at /build/linux-Y38gIP/linux-4.15.0/mm/page_alloc.c:3931 
> >> __alloc_pages_slowpath+0xb73/0xe20
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780687] Modules linked in: p_lkrg(OE+) 
> >> ccm veth rfcomm ebtable_filter ebtables nf_conntrack_netlink nfnetlink 
> >> xfrm_user xfrm_algo xt_addrtype xt_conntrack br_netfilter xt_comment aufs 
> >> xt_CHECKSUM ipx p8023 iptable_mangle psnap p8022 ipt_MASQUERADE 
> >> nf_nat_masquerade_ipv4 iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 
> >> nf_nat_ipv4 nf_nat nf_conntrack libcrc32c xt_tcpudp bridge stp llc 
> >> iptable_filter overlay bnep nvidia_uvm(POE) snd_hda_codec_hdmi 
> >> intel_powerclamp coretemp kvm_intel kvm samsung_laptop irqbypass intel_cstate 
> >> arc4 ath9k ath9k_common ath9k_hw input_leds joydev nvidia(POE) ath serio_raw 
> >> intel_ips btusb btrtl btbcm btintel mac80211 uvcvideo bluetooth 
> >> videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_core videodev 
> >> media snd_hda_codec_realtek ecdh_generic snd_seq_midi snd_hda_codec_generic
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780740]  snd_seq_midi_event 
> >> snd_hda_intel snd_hda_codec snd_rawmidi snd_hda_core cfg80211 snd_hwdep 
> >> snd_pcm snd_seq drm snd_seq_device snd_timer snd soundcore shpchp lpc_ich 
> >> mac_hid sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables autofs4 
> >> crypto_simd glue_helper cryptd aes_x86_64 algif_skcipher af_alg dm_crypt 
> >> psmouse ahci libahci i2c_i801 sky2 video [last unloaded: reiserfs]
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780773] CPU: 0 PID: 9212 Comm: insmod 
> >> Tainted: P        W  OE    4.15.0-42-generic #45-Ubuntu
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780775] Hardware name: SAMSUNG 
> >> ELECTRONICS CO., LTD. 
> >> R480/R431/R481             /R480/R431/R481             , BIOS 
> >> 11SZ.M001.20100807.XW  08/07/2010
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780778] RIP: 
> >> 0010:__alloc_pages_slowpath+0xb73/0xe20
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780779] RSP: 0018:ffffaf5c837eb978 
> >> EFLAGS: 00010246
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780781] RAX: 0000000000000000 RBX: 
> >> 000000000108c020 RCX: 0000000000000000
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780782] RDX: ffffaf5c837eba80 RSI: 
> >> 0000000000000000 RDI: 0000000000000000
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780784] RBP: ffffaf5c837eba70 R08: 
> >> 0000000000000000 R09: 0000000000000787
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780785] R10: 0000000000000002 R11: 
> >> 0000000000000000 R12: 000000000000000b
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780786] R13: 0000000000000000 R14: 
> >> 000000000108c020 R15: 0000000000000000
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780788] FS:  00007ff45c4f5540(0000) 
> >> GS:ffff8ed15fc00000(0000) knlGS:0000000000000000
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780790] CS:  0010 DS: 0000 ES: 0000 CR0: 
> >> 0000000080050033
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780791] CR2: 000055ff77089e38 CR3: 
> >> 0000000054986001 CR4: 00000000000206f0
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780793] Call Trace:
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780801]  
> >> __alloc_pages_nodemask+0x263/0x280
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780807]  alloc_pages_current+0x6a/0xe0
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780812]  kmalloc_order+0x18/0x40
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780814]  kmalloc_order_trace+0x24/0xb0
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780817]  __kmalloc+0x209/0x220
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780828]  ? 
> >> p_list_from_module_list+0x21f/0x4c0 [p_lkrg]
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780835]  
> >> p_list_from_module_list+0x1ff/0x4c0 [p_lkrg]
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780837]  ? __kmalloc+0x1b0/0x220
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780843]  p_kmod_hash+0x2f6/0x5a0 
> >> [p_lkrg]
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780850]  p_create_database+0x1e5/0x420 
> >> [p_lkrg]
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780853]  ? 0xffffffffc16a2000
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780860]  p_lkrg_register+0xec/0x1000 
> >> [p_lkrg]
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780865]  do_one_initcall+0x52/0x19f
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780868]  ? _cond_resched+0x19/0x40
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780870]  ? 
> >> kmem_cache_alloc_trace+0x14e/0x1b0
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780874]  ? do_init_module+0x27/0x209
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780876]  do_init_module+0x5f/0x209
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780878]  load_module+0x191e/0x1f10
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780883]  ? ima_post_read_file+0x96/0xa0
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780886]  SYSC_finit_module+0xfc/0x120
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780888]  ? SYSC_finit_module+0xfc/0x120
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780891]  SyS_finit_module+0xe/0x10
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780894]  do_syscall_64+0x73/0x130
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780897]  
> >> entry_SYSCALL_64_after_hwframe+0x3d/0xa2
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780899] RIP: 0033:0x7ff45c027839
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780900] RSP: 002b:00007ffe1e88fb98 
> >> EFLAGS: 00000246 ORIG_RAX: 0000000000000139
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780902] RAX: ffffffffffffffda RBX: 
> >> 000055ff77086780 RCX: 00007ff45c027839
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780904] RDX: 0000000000000000 RSI: 
> >> 000055ff75049d2e RDI: 0000000000000003
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780905] RBP: 000055ff75049d2e R08: 
> >> 0000000000000000 R09: 00007ff45c2fa000
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780906] R10: 0000000000000003 R11: 
> >> 0000000000000246 R12: 0000000000000000
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780907] R13: 000055ff77088e30 R14: 
> >> 0000000000000000 R15: 0000000000000000
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780909] Code: 85 c0 0f 85 fc fd ff ff e9 
> >> 1e fd ff ff 0f 0b 89 f8 c7 85 20 ff ff ff 00 00 00 00 25 ff ff f7 ff 89 85 68 
> >> ff ff ff e9 12 f5 ff ff <0f> 0b e9 c1 f4 ff ff 8b 5d 88 44 8b b5 68 ff ff ff 
> >> 4c 8d 4d 94
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780946] ---[ end trace 
> >> ccd206a6fa856626 ]---
> >> 
> >> And then a lot of lines like this:
> >> 
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780948] [p_lkrg] KMOD HASH kzalloc() 
> >> error! Can't allocate memory for module list ;[
> >> Dec 14 15:05:31 mordor kernel: [ 2272.780953] [p_lkrg] KMOD HASH error! Can't 
> >> allocate memory during dumping modules from module list ;[
> >> 
> >> And then, again, insmod: page allocation failure, a Call Trace, and multiple 
> >> KMOD_HASH errors.
> >> 
> >> Does anybody knows why kzalloc() can't allocate memory?
> >> 
> >> Cheers,
> >> -- Diego.
> >> 
> >> 
> >> 
> >> 
> > 
> > -- 
> > pi3 (pi3ki31ny) - pi3 (at) itsec pl
> > http://pi3.com.pl
> 

-- 
pi3 (pi3ki31ny) - pi3 (at) itsec pl
http://pi3.com.pl

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.