kernel output weird dmesg of my driver module

332 Views Asked by At

from my previsou question Why does module failed to load? (/dev/scull0 : no such device or address) I managed to load the module via /sbin/insmod, but after that, I have log out the dmesg:

[ 2765.707018] scull: loading out-of-tree module taints kernel.
[ 2765.707106] scull: module verification failed: signature and/or required key missing - tainting kernel
[ 2765.707929] Passed scull_init_module at 41 (debug info - successful load of init module)
[ 6027.843914] acer_wmi: Unknown function number - 8 - 1
[ 7347.683312] stack segment: 0000 [#1] SMP PTI
[ 7347.683323] CPU: 3 PID: 15280 Comm: rmmod Tainted: G           OE     4.19.0-9-amd64 #1 Debian 4.19.118-2
[ 7347.683326] Hardware name: Acer Swift SF314-52/Suntory_KL, BIOS V1.08 11/28/2017
/* start of the problem: */
[ 7347.683335] RIP: 0010:scull_trim+0x3a/0xa0 [scull]
[ 7347.683339] Code: 44 8b 77 0c 48 8b 2f 45 8d 66 ff 49 c1 e4 03 48 85 ed 75 16 eb 4b 48 8b 5d 08 48 89 ef e8 7e 38 f1 e1 48 89 dd 48 85 db 74 37 <48> 8b 7d 00 48 85 ff 74 e3 45 85 f6 7e 1a 31 db eb 04 48 83 c3 08

/*... output of all registers ...*/

[ 7347.683372] Call Trace:
[ 7347.683382]  cleanup_module+0x44/0x80 [scull]
[ 7347.683391]  __x64_sys_delete_module+0x190/0x2e0
[ 7347.683399]  do_syscall_64+0x53/0x110
[ 7347.683405]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 7347.683530] ---[ end trace c4b4a1cdb428d4b3 ]---
[ 7347.885914] RIP: 0010:scull_trim+0x3a/0xa0 [scull]
... /* again */ ...

Here I can observer, the mess is caused by the scull_trim (source below), and kernel trigger strace to resolve it (or does kernel call Call Trace: when something goes bad in kernel?).

scull_trim:

 /*main structure */
 struct scull_dev {
 struct scull_qset *data; /*quantum repre*/
 int quantum; /*in bytes*/
 int qset; /*array size*/
 unsigned long size; /*total bytes in device*/
 struct cdev cdev; /*Char device structure*/
 };

/*representation of quantum*/
struct scull_qset {
void **data;
struct scull_qset *next;
};

/*-------------------------------------------------------------------------------------*/
int scull_trim(struct scull_dev *dev) {
    struct scull_qset *next, *dptr; /* next for loop, dptr = data pointer (index in loop) */
    int qset = dev->qset; /* get size of arrat */
    int i; /*index for second loop for quantum bytes */

    for(dptr = dev->data /*struct scull_qset*/; dptr ; dptr = next){
        if (dptr->data /*array of quantum*/) {
            for(i=0; i<qset; i++){
                kfree(dptr->data[i]); /*free each byte of array data[i]*/
            }
            kfree(dptr->data); /*free array pointer itself*/
            dptr->data = NULL; /*set array pointer to null pointer to avoid garbage*/
        }
        next = dptr->next;
        kfree(dptr); /* free pointer itself */
    }
    //setting new attributes for cleared dev
    dev->size = 0;
    dev->quantum = scull_quantum;
    dev->qset = scull_qset;
    dev->data = NULL;

    return 0;
}

The function scull_trim is basically from linux device driver, 3 edition, And the function's intend is to get rid of all bytes from the device before open method is called. But why does it caused the dmesg error in that, kernel had to call strace to resolve it?

EDIT: Because it is nearly impossible to resolve the problem, I am adding source (as well as dmesg dump) from github: repo:scull device. Please visit it to resolve the issue.

0

There are 0 best solutions below