从我的previsou问题为什么模块无法加载?(/dev/scull0:没有这样的设备或地址)我设法通过加载模块/sbin/insmod
,但在那之后,我已经注销了 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 */ ...
在这里我可以观察到,混乱是由scull_trim
(下面的源代码)引起的,内核触发strace
来解决它(或者当内核Call Trace:
出现问题时内核调用?)。
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;
}
该函数scull_trim
基本上来自linux device driver, 3 edition,并且该函数的目的是在调用方法之前从设备中删除所有字节open
。但是为什么它会导致dmesg
错误,内核必须调用 strace 来解决它?
编辑:因为几乎不可能解决问题,所以我从 github 添加源(以及 dmesg 转储): repo:scull device。请访问它以解决问题。