Giter Site home page Giter Site logo

bkeyes93 / lkm_fixscript Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 39 KB

Some useful utilities for purely cosmetic changes in Linux Kernel Modules (LKM`s) so that they can be used on nearby kernel versions

License: The Unlicense

Shell 92.26% Makefile 4.48% C 3.26%

lkm_fixscript's Introduction

lkm_fixscript

Some useful utilities for purely cosmetic changes in Linux Kernel Modules (LKM`s) so that they can be used on nearby kernel versions.

Abstract

lkm_fixscript changes kernel version number tag in binary LKM (vermagic) to match the version of the currently running kernel. It also renames any symbol that the current kernel can't resolve into their equivalent resolvable symbols.

The script is written in bash and to perform its magic requires:

  • objcopy (version 2.9.5 or later, binutils package)
  • awk (gawk package or other)
  • cut (usually, coreutils package)
  • sed (sed package)
  • tr (usually, coreutils package)

Original scripts [1] has two versions - v1.9 (for earlier kernels) and v1.10 (supports the newer vermagic kernel versioning system used by most of the latest kernels).

WARNING!!! The use of version-matched binaries whenever possible is strongly advised! Changes made by the script may crash your kernel due to inconsistencies in data structures between the kernel as it stands and the headers used to originally compile the LKM being fixed (symbol name changes do not modify structure definitions). So extreme care must be taken to ensure the common structures between the kernel and non-matching LKM`s are the same. No guarantees are given or implied under any circumstances.

Tips and Tricks for Precompiled Modules with different Kernel Ver­sions [2]

A lot of Linux drivers are only available as precompiled, binary kernel modules. Generally, modules/binaries transparently function only with the kernel against which they were co-compiled. Therefore, getting such precompiled driver to work with your particular kernel could be a challenge.

Since the Linux kernel is a dynamically changing beast, it is very unfortunate that many vendors have not yet chosen to release source-code versions of their drivers, which would ensure ability to modify these drivers appropriately as kernel source code evolves. Some of the binary modules have been coaxed to function under some later kernel versions using various tricks; however, even though a module may be rendered functional, it is advisable to use them minimally. Quoting an email from Mark Spieth, "A driver can never work properly if there are unresolved symbols, as it means something is not going to work. Furthermore, it means that that something that would have been called will call something else in the kernel and this could be anything. This is very bad."

Therefore, you should be careful in using binary modules with a kernel of a different version; proceed at your own risk. If you require above all that your driver function, consider downgrading your kernel to match the module - this is by no means a ridiculous prospect. Despite these warnings, however, many others have used mismatched binary modules and kernels with only minor annoyances (such as the occasional kernel panic) using tricks and tools such as the following.

Mark Spieth has contributed a progressively improved series of "fixscripts" for editing a binary module so that version mismatch warnings are eliminated. Insertion of the "fixed" module then proceeds without the forcing flag, i.e. simply insmod module_name. Later versions also rename module symbols to match those exported by the kernel, so that "Unresolved symbols" errors are not returned by the test depmod -e. It must be emphasized that this change is almost entirely cosmetic - it is still recommended that the module be used minimally.

Usage:

1. generate a "fixed" LKM from original LKM	-	./lkm_fixscript old_lkm.ko new_lkm.ko
2. insert "fixed" LKM simply, non-forced	-	insmod new_lkm.ko

References:

lkm_fixscript's People

Contributors

kanner avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.