Solved

Invalid Module format error in Linux kernel 2.6.28

Posted on 2009-07-04
13
531 Views
Last Modified: 2012-05-07
I have compiled open source USB driver for Fedora 8, when I Insert  the driver module .ko file on
Fedora 9 using  insmod driver.ko  i get the error Invalid Module format error  ?
why is this coming when i am inserting/deploying on higher version i.e Fedora 9 and compiled driver.ko on Fedora 8 ?
1.) Do i need to compile the driver along with kernel source where ever driver.ko is deployed ?
2.) I there any way at least for the minor number version change the driver.ko will insert ?
3.) It is not a good solution in every machine driver source is compiled, infact some of the client  
    machines doesn't have compilers and kernel sources installed

0
Comment
Question by:tittu
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 12

Expert Comment

by:Let_Me_Be
ID: 24777236
Both Fedora 8 and Fedora 9 are old releases, you should upgrade to Fedora 11.

You are saying you were compiling open source USB driver, but that doesn't make much sense. Why would you do so? Standard kernel packages support USB for a very long time.

If you want to compile a driver, you need to compile it for the exact version of kernel, it even must be the same flavour, because distribution specific patches might make your driver incompatible.
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24777313
As stated, a module needs to match the base kernel. You can try loading with -f flag, but I'm sure this won't work between kernels of Fedora 8 vs 9, I only ever use it between minor patch level differences.

See the Kernel Loadable Module howto:

http://tldp.org/HOWTO/Module-HOWTO/basekerncompat.html#AEN507
0
 

Author Comment

by:tittu
ID: 24780032
The USB driver is a custom driver not a standard driver
It is working fine with FC8 when compiled and installed.
my question can i atleast insert this driver module even in FC8 without recompiling every time on the
deployment targets, in brief how windows drivers work like simple layman installation without compiling
compiling driver sources even for minor kernel version releases is a bad thing ?
some of the client machines even doesn't have compilers and kernel sources installed.
please give me a good solution for this instead of pointing links , i already tried all the links
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24781471
>>my question can i atleast insert this driver module even in FC8 without recompiling every time on the deployment targets,

Yes, using the -f flag as I said. Did you try that?

With major kernel versions you really should be distributing a module for each kernel. Note, it has nothing to do with FC8 vs FC9, sometimes the distribution versions use the same base kernel version.

0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 24789645
You absolutely have to compile it. It relies on addresses in the built kernel. The smallest thing can make these change.
You could integrate the driver source into the kernel source tree so it will "just build" as you generate a new kernel. You need to pick some folder where the source will go (e.g. /usr/src/linux/drivers/usb/serial) and edit the files Kconfig and Makefile there. Your driver will then be visible in "make xconfig" &c.
Once complied by whatever means, you can deploy it with that kernel to other machines without recompiling (i.e. the modules folder and the kernel image are a matched pair. If there is also an initrd, then it's part of a matched triplet).
0
 

Author Comment

by:tittu
ID: 25366436

I will try  
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:tittu
ID: 25371613
Sun VirtualBox is compiling the kernel and Integrating into the existing kernel how is it doing
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 25376282
What commands are you using to start the build? When you say "Integrating into the existing kernel", what exactly do you mean? Has a new kernel been built? Can you boot into it? Is your new module present?

I guess I'm saying I need rather more specific feedback to be able to help you further.
0
 

Author Comment

by:tittu
ID: 25400284
when Sun Virtual Box is installed using an RPM, it is integrating virtual box module into the existing
kernel. and now the virtual box is working fine with the existing new kernel is not installed and infact
compiling without kernel sources installed in the system.
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 25438126
(Back from overseas trip)
That's as may be. Perhaps the RPM had a precompiled version for your kernel. Maybe it used mod-versions. There are all kind of advanced techniques it might have used.
If you simply have source for your custom driver, none of these are available to you. You have to have kernel source and you have to be running the kernel you built from that source. It sounds like you had better include the virtual box module in that kernel.Ideally you should have the configuration file (.config) for your current kernel, otherwise you have to build absolutely everything as a module and have an initrd (which is what distributors do, but the build takes ages). Or you might get away with working back from  an lsmod to know what you actually need. Without an initrd, you need to ensure that your kernel has built in support for your boot media - that's what I always do.
It's a bit of an undertaking if you haven't done this sort of thing before, but once you get the hang of it the next one will be much easier.
0
 

Author Comment

by:tittu
ID: 25513939
I need some clarification , why do i need always kernel sources when ever iam going to install drivers or .ko files , windows OS is intelligent in this case.
0
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 500 total points
ID: 25520318
It is possible to make LKMs that are revision-tolerant to an extent, I think it needs the kernel to be built a special way too. (for other experts - I'm thinking of the system whereby you could build revision information into modules - I never used it myself).
However the Linux kernel evolves fairly rapidly so sometimes you just have to rebuild stuff.
0
 

Author Closing Comment

by:tittu
ID: 31599780
not complete solution
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now