Linux - Distributions This forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on...
Note: An (*) indicates there is no official participation from that distribution here at LQ. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-07-2022, 12:23 AM
|
#1
|
LQ Newbie
Registered: Jun 2022
Posts: 4
Rep:
|
Compile Linux Kernel Module - Cannot build simple kernel module
I'm trying to compile a kernel module driver but I get the following errors: (the operation generate some files, but not a ".ko" file)
Code:
make -C /lib/modules/5.16.0-kali7-amd64/build M=/home/z3r0/Scrivania/kernel_modules/start_stop modules
make[1]: ingresso nella directory «/usr/src/linux-headers-5.16.0-kali7-amd64»
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
make[1]: *** [/usr/src/linux-headers-5.16.0-kali7-common/Makefile:751: include/config/auto.conf] Errore 1
make[1]: uscita dalla directory «/usr/src/linux-headers-5.16.0-kali7-amd64»
make: *** [Makefile:3: all] Errore 2
When I try to execute "make oldconfig && make prepare" (in the directory /usr/src/linux-headers-5.16.0-kali7-amd64) I get the following error:
Code:
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
GEN Makefile
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
/usr/src/linux-headers-5.16.0-kali7-common/scripts/Makefile.build:44: /usr/src/linux-headers-5.16.0-kali7-common/scripts/basic/Makefile: File o directory non esistente
make[1]: *** Nessuna regola per generare l'obiettivo «/usr/src/linux-headers-5.16.0-kali7-common/scripts/basic/Makefile». Arresto.
make: *** [/usr/src/linux-headers-5.16.0-kali7-common/Makefile:566: scripts_basic] Errore 2
If I try in my computer and not in the Virtual Machine I get the following error (but it generate some files, but not the .ko file):
Code:
make -C /lib/modules/5.16.0-kali7-amd64/build M=/home/z3r0/Scrivania/All/Programming/C++/Exercises_Linux/kernel_modules/hello_world modules
make[1]: ingresso nella directory «/usr/src/linux-headers-5.16.0-kali7-amd64»
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc-11 (Debian 11.2.0-19) 11.2.0
You are using: gcc-11 (Debian 11.3.0-3) 11.3.0
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
CC [M] /home/z3r0/Scrivania/All/Programming/C++/Exercises_Linux/kernel_modules/hello_world/hello_world.o
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
MODPOST /home/z3r0/Scrivania/All/Programming/C++/Exercises_Linux/kernel_modules/hello_world/Module.symvers
ERROR: modpost: missing MODULE_LICENSE() in /home/z3r0/Scrivania/All/Programming/C++/Exercises_Linux/kernel_modules/hello_world/hello_world.o
make[2]: *** [/usr/src/linux-headers-5.16.0-kali7-common/scripts/Makefile.modpost:134: /home/z3r0/Scrivania/All/Programming/C++/Exercises_Linux/kernel_modules/hello_world/Module.symvers] Errore 1
make[2]: *** Eliminazione del file «/home/z3r0/Scrivania/All/Programming/C++/Exercises_Linux/kernel_modules/hello_world/Module.symvers»
make[1]: *** [/usr/src/linux-headers-5.16.0-kali7-common/Makefile:1785: modules] Errore 2
make[1]: uscita dalla directory «/usr/src/linux-headers-5.16.0-kali7-amd64»
make: *** [Makefile:3: all] Errore 2
The file is really simple (hello_world.c):
Code:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}
module_init(hello_start);
module_exit(hello_end);
makefile:
Code:
obj-m = foo.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
Can someone explain where is the error? Thank you
Last edited by z3r0_1993; 06-07-2022 at 12:30 AM.
|
|
|
06-07-2022, 01:17 AM
|
#2
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,655
|
probably:
Code:
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
|
|
|
06-07-2022, 03:01 AM
|
#3
|
LQ Newbie
Registered: Jun 2022
Posts: 4
Original Poster
Rep:
|
Already Tryed
Quote:
Originally Posted by pan64
probably:
Code:
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
|
Hello, Thank you for ur answer
but as I said in my request I already tryed these commands and I get the error I wrote on the question above :/
Code:
When I try to execute "make oldconfig && make prepare" (in the directory /usr/src/linux-headers-5.16.0-kali7-amd64) I get the following error:
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
GEN Makefile
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
/usr/src/linux-headers-5.16.0-kali7-common/scripts/Makefile.build:44: /usr/src/linux-headers-5.16.0-kali7-common/scripts/basic/Makefile: File o directory non esistente
make[1]: *** Nessuna regola per generare l'obiettivo «/usr/src/linux-headers-5.16.0-kali7-common/scripts/basic/Makefile». Arresto.
make: *** [/usr/src/linux-headers-5.16.0-kali7-common/Makefile:566: scripts_basic] Errore 2
Last edited by z3r0_1993; 06-07-2022 at 03:09 AM.
|
|
|
06-07-2022, 03:24 AM
|
#4
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,655
|
So make oldconfig failed. I guess your kernel source tree is either incomplete or corrupted.
How did you create it?
|
|
1 members found this post helpful.
|
06-07-2022, 03:33 AM
|
#5
|
LQ Newbie
Registered: Jun 2022
Posts: 4
Original Poster
Rep:
|
Quote:
Originally Posted by pan64
So make oldconfig failed. I guess your kernel source tree is either incomplete or corrupted.
How did you create it?
|
Mh sorry created what? xD
|
|
|
06-07-2022, 03:46 AM
|
#6
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,655
|
So you use kali, which is recommended only for advanced users
you want to build a kernel module, which is again not really suggested for beginners.
and finally I guess you have a guide or a set of instructions to explain how do you need to prepare your environment (if you want to build kernel modules).
I guess you missed a step or just failed something during that preparation.
What is in /usr/src/linux-headers-5.16.0-kali7-common ? And how was this directory created?
|
|
|
06-07-2022, 04:02 AM
|
#7
|
LQ Newbie
Registered: Jun 2022
Posts: 4
Original Poster
Rep:
|
Quote:
Originally Posted by pan64
So you use kali, which is recommended only for advanced users
you want to build a kernel module, which is again not really suggested for beginners.
and finally I guess you have a guide or a set of instructions to explain how do you need to prepare your environment (if you want to build kernel modules).
I guess you missed a step or just failed something during that preparation.
What is in /usr/src/linux-headers-5.16.0-kali7-common ? And how was this directory created?
|
Mh in the guide I was following I didn't see any instructions to set up the environment. I will search for it, thanks.
I though the environment was already set xD
Anyway but is normal that the commands "sudo make oldconfig && sudo make prepare" don't work? I though it wasn't,
Later I'll try on my Ubuntu machine to see if I get the same error.
I think everyone can do anything if they apply intensively, so despite being raccomended for advaced users I'll learn it (:
Obviously I'm not good as you are, but I will learn 
I want to learn to hook syscalls and I want to analyze (disassembly and debugging) the program that hook the syscalls.
"linux-headers-5.16.0-kali7-common" I think it's about linux headers, it contains some tools and some scripts and also headers for different kind of processor.
It was already installed, I didn't need to get the linux-header package or upgrade it ^^
|
|
|
06-07-2022, 05:15 AM
|
#8
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,655
|
Quote:
Originally Posted by z3r0_1993
I think everyone can do anything if they apply intensively, so despite being raccomended for advaced users I'll learn it (:
|
I don't think so. As it was mentioned several times: learn to walk first, then run.
Quote:
Originally Posted by z3r0_1993
Obviously I'm not good as you are, but I will learn 
|
I am not good at everything but what I have learned already.
Quote:
Originally Posted by z3r0_1993
I want to learn to hook syscalls and I want to analyze (disassembly and debugging) the program that hook the syscalls.
|
That is great, but first you need to be able to compile simple programs and debug them, not the kernel itself (or kernel modules).
|
|
|
06-07-2022, 10:07 AM
|
#9
|
Senior Member
Registered: Oct 2003
Location: Elgin,IL,USA
Distribution: KDE Neon
Posts: 1,244
|
Kali is heavily customized and not intended for doing development work, you will have better results and learn more/faster using a normal disto.
Using a distro specialized at penetration testing to learn disassembly and debugging is like using a PlayStation to learn Excel.
|
|
|
All times are GMT -5. The time now is 12:09 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|