Kernel Module Loading Error: disagrees about version of symbol module_layout - linux-device-driver

Have anyone encountered this problem while loading a kernel module with:
insmod foo.ko
Kernel Module Loading Error: disagrees about version of symbol module_layout
I compiled the kernel module on a my local VM and load it on the remote VM of customer. You might be wondering why didn't I compile and run the kernel module on the same remote VM to avoid headache of kernel version incompatibility. Problem is, I'm not allowed to reveal the source code and compile on the remote VM since the code is not my own property. I can only ship to the the remote VM the pre-build kernel module.
Big headache is that the kernel version of remote VM must match the kernel version of local VM, even the patch number needs to be matched. This is very inconvenient, since I need to prepare the kernel version of my local VM to match kernel version of remote VM. Every time remote VM updates its kernel version to whatever version, I need to also upgrade my local VM to match the customer's version accordingly and build the customer the kernel module again...
Could it be possible to build a kernel module that will be compatible with all kernel version release? Thank you a lot for reading this far :).

Related

how to make a solaris system environment same as another

I have a real host and an vm. they are both solaris system
sjcux-c7build01# uname -a
SunOS sjcux-c7build01 5.8 Generic_Virtual sun4v sparc sun4v
The real host has been used for years.The vm is new created.For maintenance,we want to use vm instead of real host in future.I need to install all the packages and let the vm can do gnu make like the old host.
How to list all the packages the real host has installed?
pkginfo just shows what's bundled with Solaris.
I noticed that directory /usr/local/lib in vm is empty,And In real host ,it has many .so file in it.
There must be many other difference. How to find out them? How to list the packages I need to install?
For example.on the vm ,I can't use git.
ldd git
libiconv.so.2 => /tools/sw/opt/SunOS/5.8/git/git-2.23.0/lib/libz.so/lib/libiconv.so.2 - Not a directory
libintl.so.8 => /tools/sw/opt/SunOS/5.8/git/git-2.23.0/lib/libz.so/lib/libintl.so.8 - Not a directory
So libiconv need to be installed.
I want to make the vm same as the real host, what need I to do? Who can give me some guide~
It is unrealistic to find one by one according to the .so files.
One possible way is to create flash archive of your old machine and install from this archive:
create repository where to store the archive
create flash archive of the system
check the archive
export via NFS the flash archive store
on new machine boot from CD, choose installation media select NFS
For more detailed instruction you can check this article in my blog
After creation of new machine you should take care of changing IP address or unconfigure and configure it from scratch (in sense of network and authentication services) it because two machines will have the same IP.

qemu-sparc vs qemu-system-sparc

I installed CentOS 7.6 then installed all things QEMU on my machine. I have a SPARC image I need to bringing up in a VM. I've been using qemu-system-sparc.
$ qemu-system-sparc -m 256 -hda solaris_v2-qemu_v2.2.0.disk -nographic -bios ./openbios-sparc32
This is on a box on which I have Fedora-30 installed.
Can I use qemu-sparc to bring up my Solaris image: solaris_v2-qemu_v2.2.0.disk ?
If so, how?
BTW, qemu-sparc come with (on CentOS 7.6):
$ sudo yum install qemu*
PS> I've tried to install qemu-system-sparc on my CentOS box but ended up in a never-ending whack-a-mole game of dependencies.
After a great deal of web searches, I found this:
QEMU as an userspace emulator
QEMU usually comes in two flavors: qemu-system-* are system emulators
(able to run entire operating systems as seen in the previous
section), while qemu-* are userspace emulators (only able to run
userspace applications).
QEMU as an userspace emulator is thus able to directly execute a SPARC
application, by emulating the syscalls that the application requests.
Among the greatest features of this approach are:
The output of application is directly displayed in the terminal,
Arguments to applications are directly given through the command line,
QEMU returns the return code of applications, etc. QEMU really just
acts as a wrapper around the application, as time or nice do.
The only complicated thing you have to do in this approach is to
compile a cross-toolchain for SPARC, so SPARC programs can be compiled
on the host computer. Such a cross-toolchain can be generated by using
the fabulous crosstool-ng.
So the answer appears to be: no, you CANNOT use qemu-sparc to run your image in a VM.
You need the qemu-system-sparc, wich will "emulate" a sparc system.
qemu-sparc will only emulate the CPU and syscalls, thus a SPARC compiled program (that you can extract from your disk image if needed) will run on non-sparc hosts, while most syscalls be "translated" by qemu into your host syscalls, thus a SPARC program can run on said host. file io, kernel stuff, it mostly get translated and run on your host. Handy for debugging or reverse engineering.
Try:
yum install qemu-kvm
The dependencies are required ofcourse. Not very usefull in your case but you could also compile qemu yourself, maybe the dependencies overlap:
git glib2-devel libfdt-devel pixman-devel zlib-devel

How can I copy a new version of libc?

I have a computer which is not to be connected to the internet for security reasons. It is running Linux. On a separate computer, I have code and a cross compiler for linux. When I move the program over to the offline Linux computer, I cannot execute it, due to an error " version `GLIBC_2.17' not found "
After checking /lib, I see that I do indeed only have version 2.13 of libc. On my development computer, I have all the relevant files for the 2.22 version which is being used to compile the program. I would like to somehow copy this version of libc on my development computer over to my offline computer so that I can run my program.
The problem is, I cannot seem to copy the files. Attempting to do so gives an error:
mv: error writing ‘./libc.so.6’: No space left on device
or something similar. I know this is not actually due to there not being space left on the device, because I don't have much of anything ON the device, and I can copy the files to other places in the filesystem, just not to the /lib directory. How can I migrate my newer version of libc over to the offline computer?
I would like to somehow copy this version of libc on my development computer over to my offline computer so that I can run my program.
Incorrectly updating libc on your "offline" computer is a very easy way to render it unbootable. You should not attempt this unless you understand what you are doing (which you clearly do not), and unless you know how to restore "offline" computer in case of failure.
The best approach is to use the package manager on the "offline" computer to install libc package correctly (details vary on what package manager is being used).
If the package manager approach doesn't work, you can copy individual files. Hoever note that system ld-linux.so and libc.so.6 must match at all times, or every dynamically linked program (your shell, cp, mv etc.) will break.
Since you need to update two files simultaneously, how could this be done? You need a statically-linked copy of cp. It is best to have a statically-linked copy of $SHELL and ln as well (in case you make a mistake).

Swift on Ubuntu - No such file or directory

Trying to install swift on my Ubuntu 14.04.3 server. Followed the guide on Swift.org.
download the install package
fetched the gpg keys
verified the .sig file
extracted the file and added the usr/bin subdir to my PATH
However when I try running swift I get "No such file or directory"
Swift seems to be found:
icanzilb#underplot:~/public$ which swift
/home/icanzilb/swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a-ubuntu14.04/usr/bin/swift
Path is correct:
icanzilb#underplot:~/swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a-ubuntu14.04/usr/bin$ echo $PATH
/home/icanzilb/swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a-ubuntu14.04/usr/bin:...
But can't run it:
icanzilb#underplot:~/swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a-ubuntu14.04/usr/bin$ swift
-bash: /home/icanzilb/swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a-ubuntu14.04/usr/bin/swift: No such file or directory
=====
Update 1: I tried the development and stable builds of Swift from swift.org and the .sig checks out but still getting the same error.
Both the swift executable and my Ubuntu are 64 bit.
It really looks like this is a problem of an architecture mismatch, as indicated by one of the commenters, or a corrupted download. The swift executable is in the path and is picked up by which. Judging from the name of the directory where it is located, it is indeed for Ubuntu 14.04. I would try the following:
file `which swift`
This should tell you it is an ELF 64-bit executable, dynamically linked, etc. If that is not the case, you have a corrupted binary somehow.
Then do
uname -a
which should identify your system as Ubuntu 14, x86_64 among other things. If that is the case, you probably have a corrupted binary. Unpack the downloaded package again and retry. If your system is not x86_64, then you are on a wrong architecture.
Update 2/4/2016:
Based on the additional info you provided about the binary and the architecture, I tend to believe this is a platform mismatch. The output of uname doesn't show it is an Ubuntu box. Besides, the Linux kernel is 4.4.0, and the binary is for 2.6.24. I can successfully run the same binary on an Ubuntu 14.04 installation with a 3.19.0 kernel. The kernel version difference is not necessarily a problem in itself, but an indicator that the platform may not be a standard Ubuntu 14.04 install.
As another check, could you please do cat /etc/os-release and cat /etc/lsb-release? Those files should indicate if the platform is indeed Ubuntu. If it is, then I'm wondering how you ended up with this late kernel version. It is possible some other components of the OS are also too recent and incompatible with the Swift binary. This may be some strange custom Linode image... If you have a machine you can use, virtual or physical, try downloading and installing a standard Ubuntu 14.04.

In Debian Linux can I build a single driver to become permanently part of my kernel image and part of my vmlinux file (for debugging)

I've got a custom kernel that I've built locally with gdb and kgdb enabled and installed. I have the vmlinux file for it that I use for source level kgdb. Each time I make a change I've been rebuilding the entire kernel. But I want to become more efficient than rebuilding whole kernels for every code change.
So I made a mod to my ata driver. Then I did a
make M=drivers/ata
It succeeded. Now how do I replace my previous ata driver with this ata driver and get this updated info into my vmlinux file for source debugging this new driver.
I'm not considering doing an insmod. I want to permanently modify my kernel image to replace the previous ata driver with this ata driver.
I think that is not possible to replace a driver in the Linux binary with a new version. You must use insmod, or recompile the entire kernel. I do not see any problem to recompile the whole kernel. If you already compiled it before, it takes few seconds