Tag Archives: linux kernel

[Solved] linux kernel load driver Error: module verification failed: signature and/or required key missing – tainting kernel

#insmod xx. ko

The following error reports

Cause of problem:

Since the 3.7 kernel, there has been a kernel signature mechanism.

When compiling the kernel, The options related to kernel signature in .config are as follows:

CONFIG_MODULE_SIG=y
CONFIG_MODULE_SIG_ALL=y

1. There is a method to sign Ko

/usr/src/linux-4.9.61/scripts/sign-file sha512 /usr/src/linux-4.9.61/certs/signing_key.pem /usr/src/linux-4.9.61/certs/signing_key.x509 hello.ko

 

2. The second method is to disable signing

Add it to your Makefile:

CONFIG_MODULE_SIG=n

ioctl,unlocked_ ioctl,compat_ The difference between IOCTL

Personal blog guide home page – click here

Original text:

Follows an explanation of the patch that introduced unlocked_ioctl and compat_ioctl into 2.6.11.
The removal of the ioctl field happened a lot later, in 2.6.36.

Explanation: When ioctl was executed, it took the Big Kernel Lock (BKL), so nothing else could
execute at the same time. This is very bad on a multiprocessor machine, so there was a big effort
to get rid of the BKL. First, unlocked_ioctl was introduced. It lets each driver writer choose
what lock to use instead. This can be difficult, so there was a period of transition during which
old drivers still worked (using ioctl) but new drivers could use the improved interface (unlocked_ioctl).
Eventually all drivers were converted and ioctl could be removed.

compat_ioctl is actually unrelated, even though it was added at the same time.
Its purpose is to allow 32-bit userland programs to make ioctl calls on a 64-bit kernel.
The meaning of the last argument to ioctl depends on the driver, so there is no way to
do a driver-independent conversion

Explanation:

IOCTL: (after 2.6.36, the field is removed). The application enters the kernel and holds a giant lock/big lock/kernel lock. At the same time, only one application enters the kernel spaceunlocked_ IOCTL: 64 is a non giant lock called by the application_ IOCTL: 32 is a non giant lock called by the application

Reference:
giant lock: giant lock – big kernel lock (BKL)
fine graded locking: non giant lock – fine graded locking
what is the difference between IOCTL unlocked IOCTL and compat IOCTL

error: a label can only be part of a statement and a declaration is not a statement (How to Fix)

The reason is an error caused by my declaration of variables after the case
Analysis of this problem:
Due to switch a few case statement in the same scope (because a case statement is label, but they belong to a switch beyond constant-like block), so if in some case the following statement variables, the scope of the object is between two curly braces, that is, the entire switch statement, other case statement can also see that such things can lead to errors. We can do this by adding curly braces to the statements that follow the case. The reason for the braces is to specify the scope of the variables we are declaring, just in this case. In fact, to write the switch-case statement more formally, we should add curly braces after the case statement.
Source code is as follows:

#include <stdio.h>

int main(int argc, char *argv[])
{
    int zt_num1 = 1, zt_num2 = 2;

    if (argc < 2) {
        printf("please input again\n");
        return -1;
    }

    if (!argv[1]) {
        printf("please input again\n");
        return -1;
    }

    switch(*argv[1])
    {
    case '+':
        zt_num1 = zt_num1 + zt_num2;
        break;
    case '$':
        zt_num1 = zt_num1 - zt_num2;
        break;
    case '#':
        int num = 3;
        zt_num1 = zt_num1 + zt_num2 + num;
        break;
    default:
        printf("please input again\n");
        break;
    }
    printf("%d\n", zt_num1);

    return 0;
}

The compilation results are as follows:

The modified code is as follows:

#include <stdio.h>

int main(int argc, char *argv[])
{
    int zt_num1 = 1, zt_num2 = 2;

    if (argc < 2) {
        printf("please input again\n");
        return -1;
    }

    if (!argv[1]) {
        printf("please input again\n");
        return -1;
    }

    switch(*argv[1])
    {
    case '+':
        zt_num1 = zt_num1 + zt_num2;
        break;
    case '$':
        zt_num1 = zt_num1 - zt_num2;
        break;
    case '#':
    {
        int num = 3;
        zt_num1 = zt_num1 + zt_num2 + num;
        break;
    }
    default:
        printf("please input again\n");
        break;
    }
    printf("%d\n", zt_num1);

    return 0;
}

The compilation and operation results are:

Virtualbox failed to attach usb, VERR_PDM_NO_USB_PORTS problem solved

The problem described
Error:VERR_PDM_NO_USB_PORTS
my machine environment:
host kali Linux virtualbox version 5.0.x
Question why
Usb Settings should use USB 3.0, as if because VirtualBox doesn’t support anything else
Problem solving
Settings Go to USB Settings and select USB 3.0 but Invalid Settings Detected appears. Tip need to install the Extension pack. And go to the website to download the Extension pack, then warrant 5.1.1 version seems finally to version, so the final solution is to update the virtualbox.
but here are a few need to be aware of, update need completely remove clean before virtualbox virtualbox

apt-get remove virtualbox
apt-get remove virtualbox-dkms

After that, I used the official downloaded.deb file for the installation

dpkg -i virtualbox-5.1_5.1.6-110634~Debian~jessie_amd64.deb

Prompt lack of libvpx1 and libssl1.0.0
apt-get found that these two can not directly down,libvpx is related to libvpx3 and libvpx4, it seems that must be libvpx1 can, so there is no way, can only search libvpx1 and libssl1.0.0, here is my search to download the address
libssl1.0.0 download address
libssl1.0.0 download address
libvpx1 download address
and then respectively through DPKG After the -i installation, install Virtualbox-5.1 and open Discover USB is now available. The default is 3.0