title: PAX: overwritten function pointer or return address, bans portage!
---
In short, what happened is, the main worker/maintainer/installer, the kind and loving lassie at the heart of of Gentoo FOSS GNU Linux, the Portage, got banned by PAX. Have a look:
- Code: Select all
Jan 23 09:29:02 g0n kernel: [573011.427220] ------------[ cut here ]------------
Jan 23 09:29:02 g0n kernel: [573011.427262] kernel BUG at mm/memory.c:1660!
Jan 23 09:29:02 g0n kernel: [573011.427292] PAX: overwritten function pointer or return address detected: 0000 [#1] PREEMPT SMP
Jan 23 09:29:02 g0n kernel: [573011.427351] Modules linked in:
Jan 23 09:29:02 g0n kernel: [573011.427375] CPU: 0 PID: 3239 Comm: x86_64-pc-linux Not tainted 4.8.17-hardened-r1-170115_11 #1
Jan 23 09:29:02 g0n kernel: [573011.427429] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./970 Extreme4, BIOS P2.60 11/11/2013
Jan 23 09:29:02 g0n kernel: [573011.427490] task: ffff8803c828dc40 task.stack: ffffc90005fd0000
Jan 23 09:29:02 g0n kernel: [573011.427528] RIP: 0010:[<ffffffff81170ffb>] [<ffffffff81170ffb>] vm_insert_pfn_prot+0x44/0xbc
Jan 23 09:29:02 g0n kernel: [573011.427586] RSP: 0000:ffffc90005fd3cf8 EFLAGS: 00010246
Jan 23 09:29:02 g0n kernel: [573011.427620] RAX: 0000000004044431 RBX: ffff8803c8cca000 RCX: 8000000000000025
Jan 23 09:29:02 g0n kernel: [573011.427664] RDX: 0000000000000020 RSI: 000003a12adfc000 RDI: ffff8803c8cca000
Jan 23 09:29:02 g0n kernel: [573011.427708] RBP: ffffc90005fd3d18 R08: 0000000000000000 R09: ffff8803c828e5d8
Jan 23 09:29:02 g0n kernel: [573011.427752] R10: ffffc90005fd3eb0 R11: 000003a12a312650 R12: 00000000000024c5
Jan 23 09:29:02 g0n kernel: [573011.427796] R13: 000003a12adfc000 R14: 0000000000000000 R15: 0000000000000000
Jan 23 09:29:02 g0n kernel: [573011.427868] FS: 000003a12adc1740(0000) GS:ffff88041fc00000(0000) knlGS:0000000000000000
Jan 23 09:29:02 g0n kernel: [573011.427918] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Jan 23 09:29:02 g0n kernel: [573011.427954] CR2: 000003a12adfc080 CR3: 000000000219d000 CR4: 00000000000006f0
Jan 23 09:29:02 g0n kernel: [573011.427998] Stack:
Jan 23 09:29:02 g0n kernel: [573011.428012] 8000000000000025 ffff8803c8cca000 ffffc90005fd3d98 ffffc90005fd3e28
Jan 23 09:29:02 g0n kernel: [573011.428064] ffffc90005fd3d40 ffffffff8117109f ffff8803c8cca000 000003a12adfc000
Jan 23 09:29:02 g0n kernel: [573011.428116] 00000000000024c5 ffffc90005fd3d60 ffffffff81001895 ffffc90005fd3d98
Jan 23 09:29:02 g0n kernel: [573011.428168] Call Trace:
Jan 23 09:29:02 g0n kernel: [573011.428188] [<ffffffff8117109f>] vm_insert_pfn+0x2c/0x3c
Jan 23 09:29:02 g0n kernel: [573011.428227] [<ffffffff81001895>] vvar_fault+0x5f/0x84
Jan 23 09:29:02 g0n kernel: [573011.428264] [<ffffffff811747da>] special_mapping_fault+0x4b/0xae
Jan 23 09:29:02 g0n kernel: [573011.428307] [<ffffffff8116da62>] __do_fault+0x93/0xe5
Jan 23 09:29:02 g0n kernel: [573011.428344] [<ffffffff81171949>] handle_mm_fault+0x434/0x944
Jan 23 09:29:02 g0n kernel: [573011.428385] [<ffffffff81081e88>] __do_page_fault+0x202/0x3ea
Jan 23 09:29:02 g0n kernel: [573011.428426] [<ffffffff81081e88>] ? __do_page_fault+0x202/0x3ea
Jan 23 09:29:02 g0n kernel: [573011.428467] [<ffffffff810820bf>] do_page_fault+0x20/0x30
Jan 23 09:29:02 g0n kernel: [573011.428506] [<ffffffff81ba9722>] page_fault+0x22/0x30
Jan 23 09:29:02 g0n kernel: [573011.428542] Code: 8b 03 48 89 c2 81 e2 00 04 00 10 75 02 0f 0b 48 81 fa 00 04 00 10 75 02 0f 0b f6 c4 04 74 0e 48 89 c2 83 e2 28 48 83 fa 20 75 02 <0f> 0b a9 00 00 00 10 74 0e 4c 89 e7 e8 1e bf ff ff 85 c0 74 02
Jan 23 09:29:02 g0n kernel: [573011.428785] RIP [<ffffffff81170ffb>] vm_insert_pfn_prot+0x44/0xbc
Jan 23 09:29:02 g0n kernel: [573011.428830] RSP <ffffc90005fd3cf8>
Jan 23 09:29:02 g0n kernel: [573011.435006] ---[ end trace 1f4c0a12fd251556 ]---
Jan 23 09:29:02 g0n kernel: [573011.435009] grsec: banning user with uid 250 until system restart for suspicious kernel crash
The "user with uid 250" is Miss Portage Herself! (And you bet grsec held its promise to ban Her!) See:
- Code: Select all
# cat /etc/passwd | grep 250
portage:x:250:250:portage:/var/tmp/portage:/bin/false
#
Looking at during what task it happened, and remembering that I tried to updated that machine (test-update only, the real updated is in the Air-Gapped, from which other clone-system are derived), I see:
- Code: Select all
# ls -ltr /mnt/170123_g0n-r/root/ | grep emerge
-rw-r--r-- 1 root root 2439 2017-01-18 02:57 emerge_noscript_1484704583
-rw-r--r-- 1 root root 708 2017-01-23 08:39 emerge-tuDN_world_1485157127
-rw-r--r-- 1 root root 33237 2017-01-23 08:50 emerge-tuDN_world_1485157653
-rw-r--r-- 1 root root 10489406 2017-01-23 09:29 emerge-tuDN_libixion_1485157907
-rw-r--r-- 1 root root 3218 2017-01-23 09:29 emerge-r_1485160173
-rw-r--r-- 1 root root 3742 2017-01-23 09:34 emerge-tuDN_libixion_1485160283
-rw-r--r-- 1 root root 2126 2017-01-23 09:46 emerge-tuDN_libixion_1485160852
-rw-r--r-- 1 root root 2134 2017-01-23 09:47 emerge-tuDN_libixion_1485161210
-rw-r--r-- 1 root root 2125 2017-01-23 09:50 emerge-tuDN_libixion_1485161367
-rw-r--r-- 1 root root 2127 2017-01-23 09:51 emerge-tuDN_libixion_1485161437
#
So, I'll try and show you what it was...
But first, to make it more understandable, it was about failing to update texlive, as there is a thread on gentoo-user mailing list, where I (this is from the same system log):
- Code: Select all
Jan 23 17:34:19 g0n postfix/smtp[9992]: A9AC92A3: to=<[email protected]>, relay=xxx.xxx.xxx.xxx[xxx.xxx.xxx.xxx]:587, delay=0.28, delays=0.07/0.02/0.18/0.01, dsn=2.0.0, status=sent (250 OK id=1cVhZA-0005vs-Nh)
Jan 23 17:34:19 g0n postfix/smtp[9992]: name_mask: resource
Jan 23 17:34:19 g0n postfix/smtp[9992]: name_mask: software
Jan 23 17:34:19 g0n postfix/smtp[9992]: disposing SASL state information
Jan 23 17:34:19 g0n postfix/qmgr[4007]: A9AC92A3: removed
sent this email:
trouble updating texlive
https://lists.gt.net/gentoo/user/322062#322062at that time (CET).
This one:
- Code: Select all
-rw-r--r-- 1 root root 10489406 2017-01-23 09:29 emerge-tuDN_libixion_1485157907
contains (just excerpts of it I'll be pasting in):
- Code: Select all
...
>>> Emerging (21 of 34) app-arch/tar-1.29-r3::gentoo
* tar-1.29.tar.bz2 SHA256 SHA512 WHIRLPOOL size ;-) ... [ ok ]
>>> Unpacking source...
>>> Unpacking tar-1.29.tar.bz2 to /var/tmp/portage/app-arch/tar-1.29-r3/work
>>> Source unpacked in /var/tmp/portage/app-arch/tar-1.29-r3/work
>>> Preparing source in /var/tmp/portage/app-arch/tar-1.29-r3/work/tar-1.29 ...
* Applying tar-1.29-extract-pathname-bypass-upstream.patch ...
[ ok ]
* Applying tar-1.29-add-files.patch ...
[ ok ]
>>> Source prepared.
...
- Code: Select all
...
checking for getcwd... yes
checking for readlink... yes
checking for realpath... * The ebuild phase 'configure' has been killed by signal 9.
>>> Failed to emerge app-arch/tar-1.29-r3, Log file:
>>> '/var/log/portage/app-arch:tar-1.29-r3:20170123-082847.log'
These are the packages that would be merged, in reverse order:
Calculating dependencies *** Resuming merge...
... done!
[ebuild R ] app-office/libreoffice-5.2.4.2::gentoo USE="branding cups gstreamer gtk (-aqua) -bluetooth -coinmp -collada -dbus -debug -eds (-firebird) -gltf -gnome -googledrive -gtk3 -java -jemalloc -kde -libressl -mysql -odk -pdfimport -postgres -quickstarter (-telepathy) {-test} -vlc" LIBREOFFICE_EXTENSIONS="-nlpsolver -scripting-beanshell -scripting-javascript -wiki-publisher" PYTHON_SINGLE_TARGET="python3_4 -python2_7 -python3_5" PYTHON_TARGETS="python2_7 python3_4 -python3_5" 0 KiB
...
- Code: Select all
...
[blocks B ] media-gfx/graphicsmagick[imagemagick] ("media-gfx/graphicsmagick[imagemagick]" is blocking media-gfx/imagemagick-6.9.7.4)
Total: 78 packages (69 upgrades, 4 new, 2 in new slots, 3 reinstalls), Size of downloads: 437,368 KiB
Conflict: 4 blocks (4 unsatisfied)
!!! Multiple package instances within a single package slot have been pulled
!!! into the dependency graph, resulting in a slot conflict:
...
And the recalculating the dependencies led here to, strangely 78 packages needing to upgrade (and failing for the texlive reason as in the gentoo-user MK thread linked), while there were already 20 apparently correctly merged packages out of 34 at the onset of the portage's work. Ummh!
The point, however is that the Call Trace happened at the time of that portage's incompleted session, compare:
- Code: Select all
-rw-r--r-- 1 root root 10489406 2017-01-23 09:29 emerge-tuDN_libixion_1485157907
to:
- Code: Select all
Jan 23 09:29:02 g0n kernel: [573011.427220] ------------[ cut here ]------------
Jan 23 09:29:02 g0n kernel: [573011.427262] kernel BUG at mm/memory.c:1660!
And I did try more of emerging, for twenty more minutes:
- Code: Select all
-rw-r--r-- 1 root root 3742 2017-01-23 09:34 emerge-tuDN_libixion_1485160283
-rw-r--r-- 1 root root 2126 2017-01-23 09:46 emerge-tuDN_libixion_1485160852
-rw-r--r-- 1 root root 2134 2017-01-23 09:47 emerge-tuDN_libixion_1485161210
-rw-r--r-- 1 root root 2125 2017-01-23 09:50 emerge-tuDN_libixion_1485161367
-rw-r--r-- 1 root root 2127 2017-01-23 09:51 emerge-tuDN_libixion_1485161437
...But it would always fail, excerpts only pasting, from emerge-tuDN_libixion_1485160283:
- Code: Select all
These are the packages that would be merged, in reverse order:
Calculating dependencies ..... done!
[nomerge ] x11-libs/gtk+-2.24.31-r1:2::gentoo USE="vim-syntax (-aqua) -cups -examples -introspection {-test} -xinerama" ABI_X86="32 (64) (-x32)"
...
[ebuild U ] app-eselect/eselect-mesa-0.0.10-r1::gentoo [0.0.10::gentoo] 0 KiB
Total: 4 packages (4 upgrades), Size of downloads: 0 KiB
Would you like to merge these packages? [Yes/No]
>>> Verifying ebuild manifests
>>> Running pre-merge checks for sys-devel/llvm-3.9.1-r1
* Checking for at least 1100 MiB disk space at "/var/tmp/portage/sys-devel/llvm-3.9.1-r1/temp" ...
[ ok ]
>>> Emerging (1 of 4) app-eselect/eselect-mesa-0.0.10-r1::gentoo
* eselect-mesa-0.0.10.tar.gz SHA256 SHA512 WHIRLPOOL size ;-) ... [ ok ]
* The ebuild phase 'unpack' has been killed by signal 9.
...
These are the packages that would be merged, in reverse order:
Calculating dependencies *** Resuming merge...
... done!
[nomerge ] x11-libs/gtk+-2.24.31-r1:2::gentoo USE="vim-syntax (-aqua) -cups -examples -introspection {-test} -xinerama" ABI_X86="32 (64) (-x32)"
...
>>> Emerging (1 of 3) sys-devel/llvm-3.9.1-r1::gentoo
* llvm-3.9.1.src.tar.xz SHA256 SHA512 WHIRLPOOL size ;-) ... [ ok ]
* llvm-3.9.0_rc3-manpages.tar.bz2 SHA256 SHA512 WHIRLPOOL size ;-) ... [ ok ]
* Checking for at least 1100 MiB disk space at "/var/tmp/portage/sys-devel/llvm-3.9.1-r1/temp" ...
[ ok ]
* The ebuild phase 'unpack' has been killed by signal 9.
Likewise also the:
- Code: Select all
emerge-tuDN_libixion_1485160852
emerge-tuDN_libixion_1485161210
emerge-tuDN_libixion_1485161367
emerge-tuDN_libixion_1485161437
Well, after that, I didn't connect much to the internet (and of course, I wasn't, I never am, online while I set portage to work), I only sent a two or three emails, so just minutes online after that fine work (probably fine, as it usually is such) by grsecurity/PAX.
But I didn't notice any serious other malfunctioning, and I can also tell that I compared the shutdown with normal shutdowns logged previously, which I perform as GRADM-enabled user shutdown, and noticed minimal, or no, misbehavior... So not sure why the system appear corrupted... Maybe I didn't wait longer, but pressed the the reset button on the hardware? I don't remember at this time (but I think that I didn't).
Be it as it may, I did the search for the apparent carrier used by the culprit functionality:
- Code: Select all
# grep -r vm_insert_pfn_prot /usr/include/
#
( nothing found )
And:
- Code: Select all
# grep -r vm_insert_pfn_prot /mnt/170123_g0n-r/usr/
...
finds some.
However, I decided I'd devide those that it finds per kernel, because this
search:
- Code: Select all
# grep -r vm_insert_pfn_prot /mnt/170123_g0n-r/usr/ | grep -v '\/usr\/src'
#
is empty.
So I grep'd like this:
- Code: Select all
# for i in $(ls -1d /mnt/170123_g0n-r/usr/src/linux-4.*) ; do j=$(echo $i | sed 's$/mnt/170123_g0n-r/usr/src/$$'|sed 's/://'); echo $j ; grep -r vm_insert_pfn_prot $i >> /some/where/Gen_170123_compromise_2.txt_ADD_${j} ; done ;
And I got founds in these files:
- Code: Select all
# ls -l /some/where/Gen_170123_compromise_2.txt_ADD_linux*
-rw-r--r-- 1 root root 0 2017-01-26 18:10 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.4.8-hardened-r1
-rw-r--r-- 1 root root 1396 2017-01-26 18:11 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.8.12
-rw-r--r-- 1 root root 1813 2017-01-26 18:11 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.8.12-hardened-r1
-rw-r--r-- 1 root root 1759 2017-01-26 18:12 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.8.14-hardened
-rw-r--r-- 1 root root 1759 2017-01-26 18:12 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.8.15-hardened
-rw-r--r-- 1 root root 1813 2017-01-26 18:12 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.8.15-hardened-r1
-rw-r--r-- 1 root root 1813 2017-01-26 18:13 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.8.15-hardened-r2
-rw-r--r-- 1 root root 1759 2017-01-26 18:13 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.8.16-hardened
-rw-r--r-- 1 root root 2578 2017-01-26 18:14 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.8.17-hardened-r1
-rw-r--r-- 1 root root 1380 2017-01-26 18:15 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.9.0
-rw-r--r-- 1 root root 1380 2017-01-26 18:15 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.9.1
-rw-r--r-- 1 root root 1380 2017-01-26 18:15 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.9.3
-rw-r--r-- 1 root root 2067 2017-01-26 18:17 /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.9.4
#
And here's just the probably relevant one (the kernel that was active at the
time):
# cat /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.8.17-hardened-r1 :
- Code: Select all
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/arch/x86/boot/compressed/vmlinux.bin matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/.tmp_vmlinux1 matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/mm/built-in.o matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/mm/memory.o matches
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/mm/memory.c: return vm_insert_pfn_prot(vma, addr, pfn, vma->vm_page_prot);
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/mm/memory.c: * vm_insert_pfn_prot - insert single pfn into user vma with specified pgprot
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/mm/memory.c: * vm_insert_pfn_prot should only be used if using multiple VMAs is
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/mm/memory.c:int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/mm/memory.c:EXPORT_SYMBOL(vm_insert_pfn_prot);
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/vmlinux matches
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/Module.symvers:0xb74c5f0d vm_insert_pfn_prot vmlinux EXPORT_SYMBOL
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/System.map:000000002c400060 A __rap_hash_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/System.map:ffffffff81170fb7 T vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/System.map:ffffffff821f7610 R __ksymtab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/System.map:ffffffff82213160 r __kcrctab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/System.map:ffffffff82222f48 r __kstrtab_vm_insert_pfn_prot
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/vmlinux.o matches
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/include/linux/mm.h:int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/.tmp_vmlinux2 matches
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/.tmp_System.map:000000002c400060 A __rap_hash_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/.tmp_System.map:ffffffff81170fb7 T vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/.tmp_System.map:ffffffff821f7610 R __ksymtab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/.tmp_System.map:ffffffff82213160 r __kcrctab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.17-hardened-r1/.tmp_System.map:ffffffff82222f48 r __kstrtab_vm_insert_pfn_prot
And maybe just two or three more, for completeness:
# cat /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.8.16-hardened :
- Code: Select all
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/arch/x86/boot/compressed/vmlinux.bin matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/.tmp_vmlinux1 matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/mm/built-in.o matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/mm/memory.o matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/vmlinux matches
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/Module.symvers:0xb74c5f0d vm_insert_pfn_prot vmlinux EXPORT_SYMBOL
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/System.map:000000002c400060 A __rap_hash_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/System.map:ffffffff81170e4a T vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/System.map:ffffffff821f55a0 R __ksymtab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/System.map:ffffffff822110f0 r __kcrctab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/System.map:ffffffff82220ed8 r __kstrtab_vm_insert_pfn_prot
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/vmlinux.o matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/.tmp_vmlinux2 matches
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/.tmp_System.map:000000002c400060 A __rap_hash_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/.tmp_System.map:ffffffff81170e4a T vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/.tmp_System.map:ffffffff821f55a0 R __ksymtab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/.tmp_System.map:ffffffff822110f0 r __kcrctab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.8.16-hardened/.tmp_System.map:ffffffff82220ed8 r __kstrtab_vm_insert_pfn_prot
# cat /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.9.3 :
- Code: Select all
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.3/arch/x86/boot/compressed/vmlinux.bin matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.3/.tmp_vmlinux1 matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.3/mm/built-in.o matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.3/mm/memory.o matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.3/vmlinux matches
/mnt/170123_g0n-r/usr/src/linux-4.9.3/Module.symvers:0x5715c3b8 vm_insert_pfn_prot vmlinux EXPORT_SYMBOL
/mnt/170123_g0n-r/usr/src/linux-4.9.3/System.map:ffffffff8112a81a T vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.3/System.map:ffffffff81e59f30 r __ksymtab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.3/System.map:ffffffff81e75c40 r __kcrctab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.3/System.map:ffffffff81e85977 r __kstrtab_vm_insert_pfn_prot
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.3/vmlinux.o matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.3/.tmp_vmlinux2 matches
/mnt/170123_g0n-r/usr/src/linux-4.9.3/.tmp_System.map:ffffffff8112a81a T vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.3/.tmp_System.map:ffffffff81e59f30 r __ksymtab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.3/.tmp_System.map:ffffffff81e75c40 r __kcrctab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.3/.tmp_System.map:ffffffff81e85977 r __kstrtab_vm_insert_pfn_prot
# cat /some/where/Gen_170123_compromise_2.txt_ADD_linux-4.9.4 :
- Code: Select all
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.4/arch/x86/boot/compressed/vmlinux.bin matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.4/.tmp_vmlinux1 matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.4/mm/built-in.o matches
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.4/mm/memory.o matches
/mnt/170123_g0n-r/usr/src/linux-4.9.4/mm/memory.c: return vm_insert_pfn_prot(vma, addr, pfn, vma->vm_page_prot);
/mnt/170123_g0n-r/usr/src/linux-4.9.4/mm/memory.c: * vm_insert_pfn_prot - insert single pfn into user vma with specified pgprot
/mnt/170123_g0n-r/usr/src/linux-4.9.4/mm/memory.c: * vm_insert_pfn_prot should only be used if using multiple VMAs is
/mnt/170123_g0n-r/usr/src/linux-4.9.4/mm/memory.c:int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
/mnt/170123_g0n-r/usr/src/linux-4.9.4/mm/memory.c:EXPORT_SYMBOL(vm_insert_pfn_prot);
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.4/vmlinux matches
/mnt/170123_g0n-r/usr/src/linux-4.9.4/Module.symvers:0x5715c3b8 vm_insert_pfn_prot vmlinux EXPORT_SYMBOL
/mnt/170123_g0n-r/usr/src/linux-4.9.4/System.map:ffffffff8112a81a T vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.4/System.map:ffffffff81e59f20 r __ksymtab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.4/System.map:ffffffff81e75c30 r __kcrctab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.4/System.map:ffffffff81e85967 r __kstrtab_vm_insert_pfn_prot
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.4/vmlinux.o matches
/mnt/170123_g0n-r/usr/src/linux-4.9.4/include/linux/mm.h:int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
Binary file /mnt/170123_g0n-r/usr/src/linux-4.9.4/.tmp_vmlinux2 matches
/mnt/170123_g0n-r/usr/src/linux-4.9.4/.tmp_System.map:ffffffff8112a81a T vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.4/.tmp_System.map:ffffffff81e59f20 r __ksymtab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.4/.tmp_System.map:ffffffff81e75c30 r __kcrctab_vm_insert_pfn_prot
/mnt/170123_g0n-r/usr/src/linux-4.9.4/.tmp_System.map:ffffffff81e85967 r __kstrtab_vm_insert_pfn_prot
I vaguely understand (not precisely because I'm still at the basics of C) that:
- Code: Select all
... kernel BUG at mm/memory.c:1660!
... PAX: overwritten function pointer or return address detected
is a serious issue. The mm/memory.c is pretty central. And the issue is about some corruption/intrusion or some such...
And I have much more to learn before I understand what exactly that function and its associates do... (likely vm is for [v]irtual [m]achine, but the rest...). And return address is about the PAX_RAP [1] (which in non-paid-for-support grsecurity --my case-- is only at demo protection, due to licensing issues with the gcc plugins that it deploys). But how all of this happened is too complex for me at this time.
And being my installation at the demo protection level in regardt to PAX_RAP, the question is also what else the attacking functionality could have used, which defenceless other structure --or whatever to call them-- of my machine...
OTOH, I feel that this issue shows I've been using grsecurity hardening correctly, and that Gentoo is delivering it correctly. The attacking functionality could apparently only use weaknesses that could not be covered, for the above mentioned licensing issues, in the grsecurity hardening deployment.
Little comfort though... How do I protect my system in those weaknesses that are left exposed? No finances here, I'm poor as a church mouse... And also I love FOSS, and dream --very little more than only dream-- of contributing to FOSS, in return for all that I get from FOSS...
And how did it happened that those functions were used for the overwriting of pointer(s)/address(es)?
My fault, of course, is that, I think, I forgot to run "make clean" or "make mrproper" in those kernel sources... Won't be happening any more, not that easily after this.
Also, the compromise is not from the Gentoo distribution, well not directly at least. Because, at that same time I was doing the same kind of emerge'ing, delayed at first, to see how the test-emerging would fare, in the Air-Gapped, and there wasn't any kind of errors whatsoever. However, the Air-Gapped does not see any internet and anything that I bring from the internet comes to my cloned machines first, and into it only after careful inspection, hash comparison and things...
Of course, I ended up finishing the update on the Air-Gapped only, and in this cloned machine there is no trace of anything related to the "kernel BUG at mm/memory.c" as my method dd overwrites the entire system partitions (the one showed, and the /boot).
Anybody can tell what this was?
The dd dump of the system partitions will be available for more analysis for a few weeks longer from now.
Regards,
Miroslav Rovis
Zagreb, Croatia
http://www.CroatiaFidelis.hrTry refute:
rootkit hooks in kernel,
linux capabilities for intrusion? (Linus?)
---
[1] the PAX_RAP from my kernel in this cloned machine:
- Code: Select all
.config - Linux/x86 4.8.17-hardened-r2 Kernel Configuration
→ Security options → Grsecurity → Customize Configuration → PaX → Miscellaneous hardening features → Search (PAX_RAP)
┌────────────────────────────────────── Search Results ───────────────────────────────────────┐
│ Symbol: PAX_RAP [=y] │
│ Type : boolean │
│ Prompt: Prevent code reuse attacks │
│ Location: │
│ -> Security options │
│ -> Grsecurity │
│ -> Grsecurity (GRKERNSEC [=y]) │
│ -> Customize Configuration │
│ -> PaX │
│ (1) -> Miscellaneous hardening features │
│ Defined at security/Kconfig:1049 │
│ Depends on: GRKERNSEC [=y] && X86_64 [=y] && GCC_PLUGINS [=y] │
│ │
│ │
- Code: Select all
│ CONFIG_PAX_RAP: │
│ │
│ By saying Y here the kernel will check indirect control transfers │
│ in order to detect and prevent attacks that try to hijack control │
│ flow by overwriting code pointers. │
│ │
│ If you have an amd64 processor that does not support SMEP then you │
│ must also enable a KERNEXEC code pointer instrumentation method │
│ (see PAX_KERNEXEC_PLUGIN). │
│ │
│ Note that binary modules cannot be instrumented by this approach. │
│ │
│ Note that the implementation requires a gcc with plugin support, │
│ i.e., gcc 4.5 or newer. You may need to install the supporting │
│ headers explicitly in addition to the normal gcc package. │
│ │
│ Symbol: PAX_RAP [=y] │
│ Type : boolean │
│ Prompt: Prevent code reuse attacks │
│ Location: │
│ -> Security options │
│ -> Grsecurity │
│ -> Grsecurity (GRKERNSEC [=y]) │
│ -> Customize Configuration │
│ -> PaX │
│ -> Miscellaneous hardening features │
│ Defined at security/Kconfig:1049 │
│ Depends on: GRKERNSEC [=y] && X86_64 [=y] && GCC_PLUGINS [=y] │
│ │
│ │
│ │