- 论坛徽章:
- 2
|
我猜是你模块的卸载函数调用了sysfs_remove_group,而第二个参数struct attribute_group的attrs成员为NULL。
裸分析的话,可以这样:
1. 75 c5 b8 44 54 75 c1 e8 c3 27 38 00 83 c4 这一串是闯祸IP附近的指令,<8b>应该就是犯事IP地址里第一个字节,把它们存为二进制文件。
- for i in 75 c5 b8 44 54 75 c1 e8 c3 27 38 00 83 c4 0c 5b 5d c3 90 90 90 90 90 90 90 90 90 90 90 90 90 55 89 e5 56 53 3e 8d 74 26 00 89 c6 8b 02 89 d3 85 c0 74 18 8d 74 26 00 8b 08 31 d2 83 c3 04 89 f0 ; do
- printf "\x$i" >> obj;
- done
复制代码 2. 反汇编之。- objdump -mx86 -bbinary -D obj
复制代码 3.对照提示的函数与反汇编代码查找问题:- 1f: 55 push %ebp
- 20: 89 e5 mov %esp,%ebp
- 22: 56 push %esi
- 23: 53 push %ebx
- 24: 3e 8d 74 26 00 lea %ds:0x0(%esi,%eiz,1),%esi
- 29: 89 c6 mov %eax,%esi
- 2b: 8b 02 mov (%edx),%eax
- 2d: 89 d3 mov %edx,%ebx
- 2f: 85 c0 test %eax,%eax
- 31: 74 18 je 0x4b
- 33: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
- 37: 8b 08 mov (%eax),%ecx
- 39: 31 d2 xor %edx,%edx
- 3b: 83 c3 04 add $0x4,%ebx
- 3e: 89 f0 mov %esi,%eax
复制代码 出错指令8b 02是mov (%edx),%eax 。即EDX为零。再看源代码:- 19static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
- 20 const struct attribute_group *grp)
- 21{
- 22 struct attribute *const* attr;
- 23 int i;
- 24
- 25 for (i = 0, attr = grp->attrs; *attr; i++, attr++)
- 26 sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
- 27}
复制代码 下面几条比较亮:
2b: 8b 02 mov (%edx),%eax
2d: 89 d3 mov %edx,%ebx
2f: 85 c0 test %eax,%eax
31: 74 18 je 0x4b
3b: 83 c3 04 add $0x4,%ebx
edx的值和[edx]值都被用到了,edx大概是grp->attrs, [edx]就是*attr,[edx]被放到eax里然后会判断eax是否为0,大概就是for中间的条件判断,ebx加4就是attr++。所以是grp->attrs为NULL导致*attr出错。
有好的调试工具的话当然更方便,如果可以用addr2line可能一下就可以指出for那一行。这样瞎掰反正也讲得通,对不对就不知道了。
|
|