I am Nate Brune, bio is wip.
natebrune / fmem Goto Github PK
View Code? Open in Web Editor NEWLinux Kernel Module designed to help analyze volatile memory in the linux kernel
License: GNU General Public License v2.0
Linux Kernel Module designed to help analyze volatile memory in the linux kernel
License: GNU General Public License v2.0
Hi, get a problem when i use fmem.
My machine info:
zhanged@dcu:~/code/kmd/fmem$ cat /proc/version
Linux version 5.0.0-23-generic (buildd@lgw01-amd64-030) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019
zhanged@dcu:~/code/kmd/fmem$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
zhanged@dcu:~/code/kmd/fmem$
The dmesg output:
[272256.188917] fmem init_module 463: init
[272256.188918] fmem find_symbols 453: set guess_page_is_ram: 00000000e03dff47
[272256.188927] sysfs: cannot create duplicate filename '/devices/virtual/fmem'
[272256.188929] CPU: 1 PID: 4609 Comm: insmod Tainted: G OE 5.0.0-23-generic #24~18.04.1-Ubuntu
[272256.188929] Hardware name: System manufacturer System Product Name/PRIME Z390-A, BIOS 1401 11/26/2019
[272256.188930] Call Trace:
[272256.188934] dump_stack+0x63/0x85
[272256.188935] sysfs_warn_dup+0x5b/0x70
[272256.188936] sysfs_create_dir_ns+0xbe/0xd0
[272256.188937] kobject_add_internal+0xac/0x2b0
[272256.188939] ? kfree_const+0x22/0x30
[272256.188940] kobject_add+0x71/0xd0
[272256.188942] ? _cond_resched+0x19/0x40
[272256.188943] ? kmem_cache_alloc_trace+0x1a6/0x1c0
[272256.188946] get_device_parent.isra.29+0x1ad/0x1d0
[272256.188946] device_add+0xed/0x6b0
[272256.188947] device_create_groups_vargs+0xe4/0xf0
[272256.188949] ? 0xffffffffc0b93000
[272256.188950] device_create+0x49/0x60
[272256.188951] ? __class_create+0x54/0x80
[272256.188952] ? 0xffffffffc0b93000
[272256.188953] init_module+0xc2/0x1000 [fmem]
[272256.188955] do_one_initcall+0x4a/0x1c9
[272256.188956] ? _cond_resched+0x19/0x40
[272256.188957] ? kmem_cache_alloc_trace+0x42/0x1c0
[272256.188958] do_init_module+0x5f/0x216
[272256.188959] load_module+0x19f6/0x20a0
[272256.188961] __do_sys_finit_module+0xfc/0x120
[272256.188962] ? __do_sys_finit_module+0xfc/0x120
[272256.188963] __x64_sys_finit_module+0x1a/0x20
[272256.188964] do_syscall_64+0x5a/0x120
[272256.188965] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[272256.188966] RIP: 0033:0x7f051602d959
[272256.188967] Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d ff f4 2c 00 f7 d8 64 89 01 48
[272256.188968] RSP: 002b:00007fff7eb7ac08 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
[272256.188969] RAX: ffffffffffffffda RBX: 000055a62e142780 RCX: 00007f051602d959
[272256.188969] RDX: 0000000000000000 RSI: 000055a62e142260 RDI: 0000000000000003
[272256.188969] RBP: 000055a62e142260 R08: 0000000000000000 R09: 0000000000000000
[272256.188970] R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000
[272256.188970] R13: 000055a62e1423a0 R14: 0000000000000000 R15: 000055a62e142260
[272256.188971] kobject_add_internal failed for fmem with -EEXIST, don't try to register things with the same name in the same directory.
On an ARM 64 system with kernel 5.3.18-24.52, make runs into this issue (sorry for the missing newlines - I did not find out how I get newlines in code block working yet):
ccuser01@aarch64-arm-cc-niap:~/mem/fmem-master> make rm -f *.o *.ko *.mod.c Module.symvers Module.markers modules.order \.*.o.cmd \.*.ko.cmd \.*.o.d rm -rf \.tmp_versions make -C /lib/modules/
uname -r/build KBUILD_EXTMOD=
pwdmodules make[1]: Entering directory '/usr/src/linux-5.3.18-24.52-obj/arm64/default' CC [M] /home/ccuser01/mem/fmem-master/lkm.o /home/ccuser01/mem/fmem-master/lkm.c: In function ‘my_xlate_dev_mem_ptr’: /home/ccuser01/mem/fmem-master/lkm.c:99:25: **error: implicit declaration of function ‘ioremap_cache’**; did you mean ‘node_add_cache’? [-Werror=implicit-function-declaration] addr = (void __force *)ioremap_cache(start, PAGE_SIZE); ^~~~~~~~~~~~~ node_add_cache /home/ccuser01/mem/fmem-master/lkm.c:99:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] addr = (void __force *)ioremap_cache(start, PAGE_SIZE); ^ /home/ccuser01/mem/fmem-master/lkm.c: In function ‘my_unxlate_dev_mem_ptr’: /home/ccuser01/mem/fmem-master/lkm.c:124:2: error: implicit declaration of function ‘iounmap’; did you mean ‘kunmap’? [-Werror=implicit-function-declaration] iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK)); ^~~~~~~ kunmap cc1: some warnings being treated as errors make[3]: *** [/usr/src/linux-5.3.18-24.52/scripts/Makefile.build:282: /home/ccuser01/mem/fmem-master/lkm.o] Error 1 make[2]: *** [/usr/src/linux-5.3.18-24.52/Makefile:1650: _module_/home/ccuser01/mem/fmem-master] Error 2 make[1]: *** [../../../linux-5.3.18-24.52/Makefile:179: sub-make] Error 2 make[1]: Leaving directory '/usr/src/linux-5.3.18-24.52-obj/arm64/default' make: *** [Makefile:12: fmem] Error 2 ccuser01@aarch64-arm-cc-niap:~/mem/fmem-master> uname -a Linux aarch64-arm-cc-niap 5.3.18-24.52-default #1 SMP Tue Mar 2 13:15:25 UTC 2021 (c35b124) aarch64 aarch64 aarch64 GNU/Linux ccuser01@aarch64-arm-cc-niap:~/mem/fmem-master>
And just the error from above:
/home/ccuser01/mem/fmem-master/lkm.c:99:25: error: implicit declaration of function ‘ioremap_cache’; did you mean ‘node_add_cache’? [-Werror=implicit-function-declaration]
addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
^~~~~~~~~~~~~
node_add_cache
Hi Team,
I am getting an error as mentioned below, on running the make command as it is unable to compile
make: Cannot find a rule to create target = from dependencies.
Looking forward to your answer
Cheers,
FYI, I'm unable to compile fmem on Ubuntu 16.04 with kernel 4.13 :
$ make
rm -f *.o *.ko *.mod.c Module.symvers Module.markers modules.order \.*.o.cmd \.*.ko.cmd \.*.o.d
rm -rf \.tmp_versions
make -C /lib/modules/`uname -r`/build SUBDIRS=`pwd` modules
make[1]: Entering directory '/usr/src/linux-headers-4.13.0-36-generic'
CC [M] /home/christophetd/fmem-master/lkm.o
/home/christophetd/fmem-master/lkm.c: In function ‘memory_lseek’:
/home/christophetd/fmem-master/lkm.c:289:42: error: ‘struct inode’ has no member named ‘i_mutex’
mutex_lock(&file->f_path.dentry->d_inode->i_mutex);
^
/home/christophetd/fmem-master/lkm.c:310:44: error: ‘struct inode’ has no member named ‘i_mutex’
mutex_unlock(&file->f_path.dentry->d_inode->i_mutex);
^
scripts/Makefile.build:308: recipe for target '/home/christophetd/fmem-master/lkm.o' failed
make[2]: *** [/home/christophetd/fmem-master/lkm.o] Error 1
Makefile:1550: recipe for target '_module_/home/christophetd/fmem-master' failed
make[1]: *** [_module_/home/christophetd/fmem-master] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.13.0-36-generic'
Makefile:12: recipe for target 'fmem' failed
make: *** [fmem] Error 2
Can't install fmem on Centos 6.3 any assistance would be greatly appreciated
Make Output:
rm -f .o .ko .mod.c Module.symvers Module.markers modules.order ..o.cmd ..ko.cmd ..o.d
rm -rf .tmp_versions
make -C /lib/modules/uname -r
/build KBUILD_EXTMOD=pwd
modules
make[1]: Entering directory /usr/src/kernels/2.6.32-279.el6.x86_64' CC [M] /root/Documents/fmem/lkm.o Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) COLLECT_GCC_OPTIONS='-nostdinc' '-isystem' '/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include' '-Iinclude' '-I/usr/src/kernels/2.6.32-279.el6.x86_64/arch/x86/include' '-include' 'include/linux/autoconf.h' '-D__KERNEL__' '-Wall' '-Wundef' '-Wstrict-prototypes' '-Wno-trigraphs' '-fno-strict-aliasing' '-fno-common' '-Werror-implicit-function-declaration' '-Wno-format-security' '-fno-delete-null-pointer-checks' '-O2' '-m64' '-mtune=generic' '-mno-red-zone' '-mcmodel=kernel' '-funit-at-a-time' '-maccumulate-outgoing-args' '-fstack-protector' '-DCONFIG_AS_CFI=1' '-DCONFIG_AS_CFI_SIGNAL_FRAME=1' '-pipe' '-Wno-sign-compare' '-fno-asynchronous-unwind-tables' '-mno-sse' '-mno-mmx' '-mno-sse2' '-mno-3dnow' '-Wframe-larger-than=2048' '-Wno-unused-but-set-variable' '-fno-omit-frame-pointer' '-fno-optimize-sibling-calls' '-g' '-pg' '-Wdeclaration-after-statement' '-Wno-pointer-sign' '-fno-strict-overflow' '-fno-dwarf2-cfi-asm' '-fconserve-stack' '-v' '-DMODULE' '-DKBUILD_STR(s)=#s' '-DKBUILD_BASENAME=KBUILD_STR(lkm)' '-DKBUILD_MODNAME=KBUILD_STR(fmem)' '-DDEBUG_HASH=50' '-DDEBUG_HASH2=5' '-c' '-o' '/root/Documents/fmem/.tmp_lkm.o' /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1 -quiet -nostdinc -v -Iinclude -I/usr/src/kernels/2.6.32-279.el6.x86_64/arch/x86/include -D__KERNEL__ -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DMODULE -DKBUILD_STR(s)=#s -DKBUILD_BASENAME=KBUILD_STR(lkm) -DKBUILD_MODNAME=KBUILD_STR(fmem) -DDEBUG_HASH=50 -DDEBUG_HASH2=5 -isystem /usr/lib/gcc/x86_64-redhat-linux/4.4.7/include -include include/linux/autoconf.h -MD /root/Documents/fmem/.lkm.o.d /root/Documents/fmem/lkm.c -quiet -dumpbase lkm.c -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -maccumulate-outgoing-args -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -auxbase-strip /root/Documents/fmem/.tmp_lkm.o -g -O2 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -Werror-implicit-function-declaration -Wno-format-security -Wno-sign-compare -Wframe-larger-than=2048 -Wno-unused-but-set-variable -Wdeclaration-after-statement -Wno-pointer-sign -version -p -fno-strict-aliasing -fno-common -fno-delete-null-pointer-checks -funit-at-a-time -fstack-protector -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-overflow -fno-dwarf2-cfi-asm -fconserve-stack -o - | as -V -Qy --64 -o /root/Documents/fmem/.tmp_lkm.o - #include "..." search starts here: #include <...> search starts here: include /usr/src/kernels/2.6.32-279.el6.x86_64/arch/x86/include /usr/lib/gcc/x86_64-redhat-linux/4.4.7/include End of search list. GNU C (GCC) version 4.4.7 20120313 (Red Hat 4.4.7-23) (x86_64-redhat-linux) compiled by GNU C version 4.4.7 20120313 (Red Hat 4.4.7-23), GMP version 4.3.1, MPFR version 2.4.1. GNU assembler version 2.20.51.0.2 (x86_64-redhat-linux) using BFD version version 2.20.51.0.2-5.48.el6_10.1 20100205 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: f1e04b41791fd0c9eea88d5989031e7d COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/:/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/ LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-nostdinc' '-isystem' '/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include' '-Iinclude' '-I/usr/src/kernels/2.6.32-279.el6.x86_64/arch/x86/include' '-include' 'include/linux/autoconf.h' '-D__KERNEL__' '-Wall' '-Wundef' '-Wstrict-prototypes' '-Wno-trigraphs' '-fno-strict-aliasing' '-fno-common' '-Werror-implicit-function-declaration' '-Wno-format-security' '-fno-delete-null-pointer-checks' '-O2' '-m64' '-mtune=generic' '-mno-red-zone' '-mcmodel=kernel' '-funit-at-a-time' '-maccumulate-outgoing-args' '-fstack-protector' '-DCONFIG_AS_CFI=1' '-DCONFIG_AS_CFI_SIGNAL_FRAME=1' '-pipe' '-Wno-sign-compare' '-fno-asynchronous-unwind-tables' '-mno-sse' '-mno-mmx' '-mno-sse2' '-mno-3dnow' '-Wframe-larger-than=2048' '-Wno-unused-but-set-variable' '-fno-omit-frame-pointer' '-fno-optimize-sibling-calls' '-g' '-pg' '-Wdeclaration-after-statement' '-Wno-pointer-sign' '-fno-strict-overflow' '-fno-dwarf2-cfi-asm' '-fconserve-stack' '-v' '-DMODULE' '-DKBUILD_STR(s)=#s' '-DKBUILD_BASENAME=KBUILD_STR(lkm)' '-DKBUILD_MODNAME=KBUILD_STR(fmem)' '-DDEBUG_HASH=50' '-DDEBUG_HASH2=5' '-c' '-o' '/root/Documents/fmem/.tmp_lkm.o' LD [M] /root/Documents/fmem/fmem.o Building modules, stage 2. MODPOST 1 modules CC /root/Documents/fmem/fmem.mod.o Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) COLLECT_GCC_OPTIONS='-nostdinc' '-isystem' '/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include' '-Iinclude' '-I/usr/src/kernels/2.6.32-279.el6.x86_64/arch/x86/include' '-include' 'include/linux/autoconf.h' '-D__KERNEL__' '-Wall' '-Wundef' '-Wstrict-prototypes' '-Wno-trigraphs' '-fno-strict-aliasing' '-fno-common' '-Werror-implicit-function-declaration' '-Wno-format-security' '-fno-delete-null-pointer-checks' '-O2' '-m64' '-mtune=generic' '-mno-red-zone' '-mcmodel=kernel' '-funit-at-a-time' '-maccumulate-outgoing-args' '-fstack-protector' '-DCONFIG_AS_CFI=1' '-DCONFIG_AS_CFI_SIGNAL_FRAME=1' '-pipe' '-Wno-sign-compare' '-fno-asynchronous-unwind-tables' '-mno-sse' '-mno-mmx' '-mno-sse2' '-mno-3dnow' '-Wframe-larger-than=2048' '-Wno-unused-but-set-variable' '-fno-omit-frame-pointer' '-fno-optimize-sibling-calls' '-g' '-pg' '-Wdeclaration-after-statement' '-Wno-pointer-sign' '-fno-strict-overflow' '-fno-dwarf2-cfi-asm' '-fconserve-stack' '-v' '-DKBUILD_STR(s)=#s' '-DKBUILD_BASENAME=KBUILD_STR(fmem.mod)' '-DKBUILD_MODNAME=KBUILD_STR(fmem)' '-DDEBUG_HASH=50' '-DDEBUG_HASH2=5' '-DMODULE' '-c' '-o' '/root/Documents/fmem/fmem.mod.o' /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1 -quiet -nostdinc -v -Iinclude -I/usr/src/kernels/2.6.32-279.el6.x86_64/arch/x86/include -D__KERNEL__ -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DKBUILD_STR(s)=#s -DKBUILD_BASENAME=KBUILD_STR(fmem.mod) -DKBUILD_MODNAME=KBUILD_STR(fmem) -DDEBUG_HASH=50 -DDEBUG_HASH2=5 -DMODULE -isystem /usr/lib/gcc/x86_64-redhat-linux/4.4.7/include -include include/linux/autoconf.h -MD /root/Documents/fmem/.fmem.mod.o.d /root/Documents/fmem/fmem.mod.c -quiet -dumpbase fmem.mod.c -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -maccumulate-outgoing-args -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -auxbase-strip /root/Documents/fmem/fmem.mod.o -g -O2 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -Werror-implicit-function-declaration -Wno-format-security -Wno-sign-compare -Wframe-larger-than=2048 -Wno-unused-but-set-variable -Wdeclaration-after-statement -Wno-pointer-sign -version -p -fno-strict-aliasing -fno-common -fno-delete-null-pointer-checks -funit-at-a-time -fstack-protector -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-overflow -fno-dwarf2-cfi-asm -fconserve-stack -o - | as -V -Qy --64 -o /root/Documents/fmem/fmem.mod.o - #include "..." search starts here: #include <...> search starts here: include /usr/src/kernels/2.6.32-279.el6.x86_64/arch/x86/include /usr/lib/gcc/x86_64-redhat-linux/4.4.7/include End of search list. GNU C (GCC) version 4.4.7 20120313 (Red Hat 4.4.7-23) (x86_64-redhat-linux) compiled by GNU C version 4.4.7 20120313 (Red Hat 4.4.7-23), GMP version 4.3.1, MPFR version 2.4.1. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU assembler version 2.20.51.0.2 (x86_64-redhat-linux) using BFD version version 2.20.51.0.2-5.48.el6_10.1 20100205 Compiler executable checksum: f1e04b41791fd0c9eea88d5989031e7d COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/:/usr/libexec/gcc/x86_64-redhat-linux/4.4.7/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/ LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-nostdinc' '-isystem' '/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include' '-Iinclude' '-I/usr/src/kernels/2.6.32-279.el6.x86_64/arch/x86/include' '-include' 'include/linux/autoconf.h' '-D__KERNEL__' '-Wall' '-Wundef' '-Wstrict-prototypes' '-Wno-trigraphs' '-fno-strict-aliasing' '-fno-common' '-Werror-implicit-function-declaration' '-Wno-format-security' '-fno-delete-null-pointer-checks' '-O2' '-m64' '-mtune=generic' '-mno-red-zone' '-mcmodel=kernel' '-funit-at-a-time' '-maccumulate-outgoing-args' '-fstack-protector' '-DCONFIG_AS_CFI=1' '-DCONFIG_AS_CFI_SIGNAL_FRAME=1' '-pipe' '-Wno-sign-compare' '-fno-asynchronous-unwind-tables' '-mno-sse' '-mno-mmx' '-mno-sse2' '-mno-3dnow' '-Wframe-larger-than=2048' '-Wno-unused-but-set-variable' '-fno-omit-frame-pointer' '-fno-optimize-sibling-calls' '-g' '-pg' '-Wdeclaration-after-statement' '-Wno-pointer-sign' '-fno-strict-overflow' '-fno-dwarf2-cfi-asm' '-fconserve-stack' '-v' '-DKBUILD_STR(s)=#s' '-DKBUILD_BASENAME=KBUILD_STR(fmem.mod)' '-DKBUILD_MODNAME=KBUILD_STR(fmem)' '-DDEBUG_HASH=50' '-DDEBUG_HASH2=5' '-DMODULE' '-c' '-o' '/root/Documents/fmem/fmem.mod.o' LD [M] /root/Documents/fmem/fmem.ko.unsigned NO SIGN [M] /root/Documents/fmem/fmem.ko make[1]: Leaving directory
/usr/src/kernels/2.6.32-279.el6.x86_64'
Installed Packages
[root@centos-6 fmem]# yum list installed | grep kernel
abrt-addon-kerneloops.x86_64
dracut-kernel.noarch 004-283.el6 @anaconda-CentOS-201207061011.x86_64/6.3
kernel.x86_64 2.6.32-279.el6 @anaconda-CentOS-201207061011.x86_64/6.3
kernel-devel.x86_64 2.6.32-279.el6 @/kernel-devel-2.6.32-279.el6.x86_64
kernel-firmware.noarch 2.6.32-279.el6 @anaconda-CentOS-201207061011.x86_64/6.3
kernel-headers.x86_64 2.6.32-279.el6 @/kernel-headers-2.6.32-279.el6.x86_64
libreport-plugin-kerneloops.x86_64
uname
[root@centos-6 fmem]# uname -a
Linux centos-6.3 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Modules.symvers
[root@centos-6 2.6.32-279.el6.x86_64]# ls
arch drivers include kernel Makefile.common Module.symvers scripts System.map virt
block firmware init lib mm net security tools
crypto fs ipc Makefile modules.order samples sound usr
[root@test-01 fmem]# make
rm -f *.o *.ko *.mod.c Module.symvers Module.markers modules.order \.*.o.cmd \.*.ko.cmd \.*.o.d
rm -rf \.tmp_versions
make -C /lib/modules/`uname -r`/build SUBDIRS=`pwd` modules
make[1]: Entering directory `/usr/src/kernels/5.1.14-1.el7.elrepo.x86_64'
/usr/src/kernels/5.1.14-1.el7.elrepo.x86_64/Makefile:205: ================= WARNING ================
/usr/src/kernels/5.1.14-1.el7.elrepo.x86_64/Makefile:206: 'SUBDIRS' will be removed after Linux 5.3
/usr/src/kernels/5.1.14-1.el7.elrepo.x86_64/Makefile:207: Please use 'M=' or 'KBUILD_EXTMOD' instead
/usr/src/kernels/5.1.14-1.el7.elrepo.x86_64/Makefile:208: ==========================================
CC [M] /root/fmem/lkm.o
/root/fmem/lkm.c:32:27: fatal error: linux/bootmem.h: No such file or directory
#include <linux/bootmem.h>
^
compilation terminated.
make[3]: *** [/root/fmem/lkm.o] Error 1
make[2]: *** [_module_/root/fmem] Error 2
make[1]: *** [sub-make] Error 2
make[1]: Leaving directory `/usr/src/kernels/5.1.14-1.el7.elrepo.x86_64'
make: *** [fmem] Error 2
[root@test-01 fmem]# uname -a
Linux test-01 5.1.14-1.el7.elrepo.x86_64 #1 SMP Sat Jun 22 08:30:29 EDT 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@test-01 fmem]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
After running ./run.sh
I get the following output in my dmesg
log. I tried changing FMEM_MAJOR
to a different number, this solved my issue.
My kernel knowledge is insufficient to add the dynamic allocation.
[ 8337.184174] fmem init_module 450: init
[ 8337.184175] fmem find_symbols 440: set guess_page_is_ram: 0000000048c62be7
[ 8337.184176] unable to get major 241 for memory devs
[ 8337.184204] sysfs: cannot create duplicate filename '/dev/char/241:1'
[ 8337.184174] fmem init_module 450: init
[ 8337.184175] fmem find_symbols 440: set guess_page_is_ram: 0000000048c62be7
[ 8337.184176] unable to get major 241 for memory devs
[ 8337.184204] sysfs: cannot create duplicate filename '/dev/char/241:1'
8337.184205] CPU: 12 PID: 22083 Comm: insmod Tainted: P OE 4.18.0-25-generic #26-Ubuntu
[ 8337.184205] Hardware name: System76 Serval WS/Serval WS, BIOS 1.05.20 01/21/2019
[ 8337.184206] Call Trace:
[ 8337.184210] dump_stack+0x63/0x8a
[ 8337.184212] sysfs_warn_dup.cold.4+0x17/0x32
[ 8337.184214] sysfs_do_create_link_sd.isra.2+0xa8/0xc0
[ 8337.184216] sysfs_create_link+0x25/0x40
[ 8337.184219] device_add+0x5a2/0x650
[ 8337.184221] device_create_groups_vargs+0xd8/0xf0
[ 8337.184223] ? 0xffffffffc221a000
[ 8337.184224] device_create+0x49/0x60
[ 8337.184225] ? __class_create+0x51/0x90
[ 8337.184226] ? 0xffffffffc221a000
[ 8337.184227] ? kobject_uevent_env+0x114/0x7b0
[ 8337.184230] init_module+0x9a/0x1000 [fmem]
[ 8337.184233] do_one_initcall+0x4a/0x1c4
[ 8337.184236] ? free_pcp_prepare+0x4f/0xd0
[ 8337.184237] ? _cond_resched+0x19/0x30
[ 8337.184240] ? kmem_cache_alloc_trace+0x165/0x1d0
[ 8337.184241] ? do_init_module+0x27/0x220
[ 8337.184243] do_init_module+0x60/0x220
[ 8337.184244] load_module+0x14e6/0x1880
[ 8337.184246] __do_sys_finit_module+0xbd/0x120
[ 8337.184247] ? __do_sys_finit_module+0xbd/0x120
[ 8337.184248] __x64_sys_finit_module+0x1a/0x20
[ 8337.184250] do_syscall_64+0x5a/0x110
[ 8337.184251] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 8337.184252] RIP: 0033:0x7f9ff4ed6219
[ 8337.184252] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01
f0 ff ff 73 01 c3 48 8b 0d 47 fc 0c 00 f7 d8 64 89 01 48
[ 8337.184271] RSP: 002b:00007ffc08ad2a38 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
[ 8337.184272] RAX: ffffffffffffffda RBX: 00005587ce62d820 RCX: 00007f9ff4ed6219
[ 8337.184272] RDX: 0000000000000000 RSI: 00005587ce62d260 RDI: 0000000000000003
[ 8337.184273] RBP: 00005587ce62d260 R08: 0000000000000000 R09: 0000000000000000
[ 8337.184273] R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000
[ 8337.184274] R13: 00005587ce62d7e0 R14: 0000000000000000 R15: 00005587ce62d260
[ 8422.640015] fmem cleanup_module 464: destroying fmem device
[ 8422.640034] fmem cleanup_module 471: exit
[ 8456.651323] fmem init_module 455: init
[ 8456.651324] fmem find_symbols 445: set guess_page_is_ram: 0000000048c62be7
[ 8456.651325] unable to get major 241 for memory devs
[ 8456.651358] sysfs: cannot create duplicate filename '/dev/char/241:1'
[ 8456.651359] CPU: 3 PID: 22838 Comm: insmod Tainted: P OE 4.18.0-25-generic #26-Ubuntu
[ 8456.651360] Hardware name: System76 Serval WS/Serval WS, BIOS 1.05.20 01/21/2019
[ 8456.651361] Call Trace:
[ 8456.651364] dump_stack+0x63/0x8a
[ 8456.651365] sysfs_warn_dup.cold.4+0x17/0x32
[ 8456.651366] sysfs_do_create_link_sd.isra.2+0xa8/0xc0
[ 8456.651367] sysfs_create_link+0x25/0x40
[ 8456.651369] device_add+0x5a2/0x650
[ 8456.651370] device_create_groups_vargs+0xd8/0xf0
[ 8456.651371] ? 0xffffffffc221a000
[ 8456.651372] device_create+0x49/0x60
[ 8456.651373] ? __class_create+0x51/0x90
[ 8456.651373] ? 0xffffffffc221a000
[ 8456.651374] ? kobject_uevent_env+0x114/0x7b0
[ 8456.651375] init_module+0x9a/0x1000 [fmem]
[ 8456.651377] do_one_initcall+0x4a/0x1c4
[ 8456.651379] ? free_pcp_prepare+0x4f/0xd0
[ 8456.651380] ? _cond_resched+0x19/0x30
[ 8456.651381] ? kmem_cache_alloc_trace+0x165/0x1d0
[ 8456.651382] ? do_init_module+0x27/0x220
[ 8456.651383] do_init_module+0x60/0x220
[ 8456.651383] load_module+0x14e6/0x1880
[ 8456.651385] __do_sys_finit_module+0xbd/0x120
[ 8456.651385] ? __do_sys_finit_module+0xbd/0x120
[ 8456.651386] __x64_sys_finit_module+0x1a/0x20
[ 8456.651387] do_syscall_64+0x5a/0x110
[ 8456.651388] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 8456.651389] RIP: 0033:0x7f0f0a138219
[ 8456.651389] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01
f0 ff ff 73 01 c3 48 8b 0d 47 fc 0c 00 f7 d8 64 89 01 48
[ 8456.651400] RSP: 002b:00007ffe02e582d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
[ 8456.651401] RAX: ffffffffffffffda RBX: 0000556b56645820 RCX: 00007f0f0a138219
[ 8456.651401] RDX: 0000000000000000 RSI: 0000556b56645260 RDI: 0000000000000003
[ 8456.651401] RBP: 0000556b56645260 R08: 0000000000000000 R09: 0000000000000000
[ 8456.651402] R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000
[ 8456.651402] R13: 0000556b566457e0 R14: 0000000000000000 R15: 0000556b56645260
[ 8503.465302] fmem cleanup_module 469: destroying fmem device
[ 8503.465322] fmem cleanup_module 476: exit
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.