首页
社区
课程
招聘
[求助]内核KeSetEvent导致蓝屏
发表于: 2015-2-10 17:39 13587

[求助]内核KeSetEvent导致蓝屏

2015-2-10 17:39
13587
各位大家好。
写了一个驱动程序,里面使用KeSetEvent进行线程中的通信,导致了IRQL_NOT_LESS_OR_EQUAL蓝屏。说是访问了分页数据。

源代码:

    24:         KeSetEvent(&gWorkerEvent,IO_NO_INCREMENT,FALSE);
    25:         if (spinLock) {
    26:                 KeReleaseSpinLock(&eventLock,OldIrql);
    27:         }
    28:         return ret;

//gWorkerEvent是一个全局变量,这段代码运行在dispatch_level下。

具体的分析结果为:
An attempt was made to access a pageable (or completely invalid) address at an
interrupt request level (IRQL) that is too high.  This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000016, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, bitfield :
        bit 0 : value 0 = read operation, 1 = write operation
        bit 3 : value 0 = not an execute operation, 1 = execute operation (only on chips which support this level of status)
Arg4: 844805f1, address which referenced memory

.......

STACK_TEXT:  
aea4262c 844805f1 badb0d00 00000000 00000000 nt!KiTrap0E+0x1b3
aea426ac 844bfb7d 84573d20 00000001 a656a518 nt!KiSignalNotificationObject+0x13
aea426d4 a6567d2a a656a500 00000000 00000000 nt!KeSetEvent+0x98

已经查了很多资料了,但是还是没有找到解决方法,而且是很罕见的蓝屏。
求各位帮看一下

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
免费 0
支持
分享
最新回复 (22)
雪    币: 33
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
各位大家好。
写了一个驱动程序,里面使用KeSetEvent进行线程中的通信,导致了IRQL_NOT_LESS_OR_EQUAL蓝屏。说是访问了分页数据。

源代码:

    24:   KeSetEvent(&gWorkerEvent,IO_NO_INCREMENT,FALSE);
    25:   if (spinLock) {
    26:     KeReleaseSpinLock(&eventLock,OldIrql);
    27:   }
    28:   return ret;

//gWorkerEvent是一个全局变量,这段代码运行在dispatch_level下。

具体的分析结果为:
An attempt was made to access a pageable (or completely invalid) address at an
interrupt request level (IRQL) that is too high.  This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000016, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, bitfield :
  bit 0 : value 0 = read operation, 1 = write operation
  bit 3 : value 0 = not an execute operation, 1 = execute operation (only on chips which support this level of status)
Arg4: 844805f1, address which referenced memory

.......

STACK_TEXT:  
aea4262c 844805f1 badb0d00 00000000 00000000 nt!KiTrap0E+0x1b3
aea426ac 844bfb7d 84573d20 00000001 a656a518 nt!KiSignalNotificationObject+0x13
aea426d4 a6567d2a a656a500 00000000 00000000 nt!KeSetEvent+0x98

已经查了很多资料了,但是还是没有找到解决方法,而且是很罕见的蓝屏。
求各位帮看一下
2015-2-10 17:42
0
雪    币: 155
活跃值: (20)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
gWorkerEvent这个事件的WaitListHead被破坏了,list entry里有成员指向0。
2015-2-10 17:56
0
雪    币: 33
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
麻烦能够再确切一些吗?非常感谢。
2015-2-10 17:59
0
雪    币: 1711
活跃值: (516)
能力值: ( LV12,RANK:200 )
在线值:
发帖
回帖
粉丝
5
gWorkerEvent怎么分配的?
2015-2-10 18:11
0
雪    币: 33
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
是一个全局变量:
KEVENT gWorkerEvent;

在DriverEntry初始化:
   KeInitializeEvent(
      &gWorkerEvent,
      NotificationEvent,
      FALSE
      );

因为是主线程dispatch_level上,没法打印数据,我开了一个工作线程。

每次有数据了,我就调用KeSetEvent(&gWorkerEvent,IO_NO_INCREMENT,FALSE);

在工作线程:

KeWaitForSingleObject(
                        &gWorkerEvent,
                        Executive,
                        KernelMode,
                        FALSE,
                        NULL);
KeClearEvent(&gWorkerEvent);

想问一个问题,KeSetEvent和KeClearEvent内部自带同步吗? 会不会是我同时进行这两个操作造成错误了。
2015-2-10 18:18
0
雪    币: 155
活跃值: (20)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
保存个kernel dump 传来看看吧。你就提供这点信息怎么确切。

把你出问题的sys文件也传个看看
2015-2-10 18:26
0
雪    币: 33
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
这是dump文件的分析结果。麻烦帮看一下。

IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address at an
interrupt request level (IRQL) that is too high.  This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000016, memory referenced
Arg2: 00000002, IRQL
Arg3: 00000000, bitfield :
        bit 0 : value 0 = read operation, 1 = write operation
        bit 3 : value 0 = not an execute operation, 1 = execute operation (only on chips which support this level of status)
Arg4: 844805f1, address which referenced memory

Debugging Details:
------------------

READ_ADDRESS: GetPointerFromAddress: unable to read from 845b284c
Unable to read MiSystemVaType memory at 84591f00
00000016

CURRENT_IRQL:  2

FAULTING_IP:
nt!KiSignalNotificationObject+13
844805f1 807f1601        cmp     byte ptr [edi+16h],1

CUSTOMER_CRASH_COUNT:  1

DEFAULT_BUCKET_ID:  WIN7_DRIVER_FAULT

BUGCHECK_STR:  0xA

PROCESS_NAME:  svchost.exe

TRAP_FRAME:  aea4262c -- (.trap 0xffffffffaea4262c)
ErrCode = 00000000
eax=a656a500 ebx=00000000 ecx=a656a402 edx=00000000 esi=a656a508 edi=00000000
eip=844805f1 esp=aea426a0 ebp=aea426ac iopl=0         nv up ei pl nz ac po cy
cs=0008  ss=0010  ds=0023  es=0023  fs=0030  gs=0000             efl=00010213
nt!KiSignalNotificationObject+0x13:
844805f1 807f1601        cmp     byte ptr [edi+16h],1       ds:0023:00000016=??
Resetting default scope

LAST_CONTROL_TRANSFER:  from 844805f1 to 84489b7f

STACK_TEXT:  
aea4262c 844805f1 badb0d00 00000000 00000000 nt!KiTrap0E+0x1b3
aea426ac 844bfb7d 84573d20 00000001 a656a518 nt!KiSignalNotificationObject+0x13
aea426d4 a6567d2a a656a500 00000000 00000000 nt!KeSetEvent+0x98
aea426f4 a65678ab aea4271c 89df89d0 00000000 inspect!SetNetInfo+0x4a [f:\Ô´´úÂë\win7\filter\printer.c @ 26]
aea4275c 8ddcbef6 aea42bc0 aea42c38 87d47dd0 inspect!TLInspectALEConnectClassify+0x18b [f:\Ô´´úÂë\win7\filter\callback.c @ 312]
aea42780 8ddb5f12 00000000 a6567720 aea42bc0 NETIO!ProcessNonBufferedCallout+0x23
aea427dc 8ddb6b3e 00000032 aea42bc0 aea42c38 NETIO!ProcessCallout+0x184
aea42850 8ddb521f 00000032 aea42bc0 aea42c38 NETIO!ArbitrateAndEnforce+0xae
aea42960 8e0d0bf4 00000032 aea42bc0 aea42c38 NETIO!KfdClassify+0x1c7
aea4298c 8e0dfd23 aea42bc0 aea42c38 87d47dd0 tcpip!WfpAleClassify+0x38
aea42db4 8e0b8e23 b28c0690 00000032 8e1364d0 tcpip!WfpAlepAuthorizeSend+0x970
aea42f70 8e0dd61c b28c0690 87fa0017 00000011 tcpip!WfpAleAuthorizeSend+0x1da
aea42fdc 8e0dc423 b28c0690 87fa0017 00000011 tcpip!WfpAleConnectAcceptIndicate+0x62
aea4313c 8e0bd8c5 aea432a4 00000011 87fa0017 tcpip!ProcessALEForTransportPacket+0x3a5
aea431b8 8e0cb875 aea432a4 00000011 87fa0017 tcpip!ProcessAleForNonTcpOut+0x57
aea43264 8e0bbb78 00000011 87fa0017 00002202 tcpip!WfpProcessOutTransportStackIndication+0x26c
aea432cc 8e0bc4ac 00000029 88bb0140 87fa95e8 tcpip!IppInspectLocalDatagramsOut+0x101
aea43394 8e0b9650 00000000 00000004 8e143fa8 tcpip!IppSendDatagramsCommon+0x5d5
aea433b4 8e0c1f5e 87ff4958 aea43440 00000000 tcpip!IpNlpSendDatagrams+0x4b
aea43590 8e0b9d08 00000000 00000000 b3663870 tcpip!UdpSendMessagesOnPathCreation+0x7c0
aea43590 00000000 00000000 00000000 b3663870 tcpip!UdpSendMessages+0x595

STACK_COMMAND:  kb

FOLLOWUP_IP:
inspect!SetNetInfo+4a [f:\Ô´´úÂë\win7\filter\printer.c @ 26]
a6567d2a 8a55ff          mov     dl,byte ptr [ebp-1]

FAULTING_SOURCE_LINE:  f:\Ô´´úÂë\win7\filter\printer.c

FAULTING_SOURCE_FILE:  f:\Ô´´úÂë\win7\filter\printer.c

FAULTING_SOURCE_LINE_NUMBER:  26

FAULTING_SOURCE_CODE:  
    22:         spinLock = TRUE;
    23:         ret = InsertHeadNetInfoList(pinfo);
    24:         KeSetEvent(&gWorkerEvent,IO_NO_INCREMENT,FALSE);
    25:         if (spinLock) {
>   26:                 KeReleaseSpinLock(&eventLock,OldIrql);
    27:         }
    28:         return ret;
    29: }
    30:
    31: NTSTATUS GetNetInfo(PNET_INFO pData) {

SYMBOL_STACK_INDEX:  3

SYMBOL_NAME:  inspect!SetNetInfo+4a

FOLLOWUP_NAME:  MachineOwner

MODULE_NAME: inspect

IMAGE_NAME:  inspect.sys

DEBUG_FLR_IMAGE_TIMESTAMP:  53bdf73b

FAILURE_BUCKET_ID:  0xA_inspect!SetNetInfo+4a

BUCKET_ID:  0xA_inspect!SetNetInfo+4a
2015-2-10 18:31
0
雪    币: 1392
活跃值: (4892)
能力值: ( LV13,RANK:240 )
在线值:
发帖
回帖
粉丝
9
WFP还真是不好处理,很多时候都是在dispatchlevel上面
2015-2-10 19:27
0
雪    币: 219
活跃值: (738)
能力值: (RANK:290 )
在线值:
发帖
回帖
粉丝
10
用 原子锁
2015-2-10 20:56
0
雪    币: 1711
活跃值: (516)
能力值: ( LV12,RANK:200 )
在线值:
发帖
回帖
粉丝
11
dump file明显可以看出,是高IRQL访问了pageable的memory。因此怀疑是你某个变量的声明/分配方法不当。

似乎是错在这里:
KeReleaseSpinLock(&eventLock,OldIrql);

eventLock又是怎么分配的,OldIrlq又是哪里的?

你在dump file里看一下几个变量的地址,哪个地址是16.以及汇编看看具体在执行哪句,确定出错在哪里。

这种变量不要简单声明成全局的,要在AddDevice里放在自定义的device context里,用的时候再到context里去取。

2015-2-10 21:52
0
雪    币: 155
活跃值: (20)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
12
他这不是变量pageable得问题,是空指针了,具体是在拆event的wait list head的时候,没dump没法进一步看
说让楼主提供dump文件和sys还不提供,光贴个自动分析结果还分析个毛啊,楼主自己解决吧
2015-2-11 06:53
0
雪    币: 23
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
13
访问分页时必须提高irql到dispatch级,你看下wdk手册有详细说明
2015-2-11 08:43
0
雪    币: 33
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
14
非常感谢啊,你的回答给我指了一个比较好的方向,我再自己查一下吧。sys不敢往上贴,请见谅。祝好
2015-2-11 08:48
0
雪    币: 33
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
15
eventLock是全局的,OldIrql是局部变量。
我查了一下,eventLock默认的全局变量是在NonPageable的区域,OldIrql栈数据也是在NonPageable区域。
所以估计是KeSetEvent的问题,这个错误网上也基本是跟KeSetEvent对上,但是没有解决方案。
2015-2-11 09:05
0
雪    币: 3110
活跃值: (1254)
能力值: ( LV8,RANK:120 )
在线值:
发帖
回帖
粉丝
16
这话说的,,,不要太坑人
2015-2-11 11:53
0
雪    币: 52
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
17
edi=00000000,应该是指针为null了,跟一下就应该知道了。
2015-2-11 12:13
0
雪    币: 52
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
18
edi=00000000,说明不是变量定义的问题,是有指针为NULL了。 建议跟一下KeSetEvent.
2015-2-11 12:46
0
雪    币: 33
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
19
很感谢,你的建议跟 @kman 的很接近。我查一下代码。就是问题是罕见出现,跟起来比较费劲。
2015-2-11 12:52
0
雪    币: 23
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
20
访问分页时必须提高irql到dispatch级以下,少打两字,没注意,因为分页可能产生缺页,缺页直接蓝精,

差点坑着人,,自己看手册去,明确记 着了
2015-2-12 05:53
0
雪    币: 155
活跃值: (20)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
21
提高。。。到以下。。。

语文是美术老师教的吗
2015-2-12 08:03
0
雪    币: 6
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
22
学习一下.!!
2015-2-14 21:39
0
雪    币: 1
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
23
请问你最后解决了么,我也碰到相似的问题
2017-12-19 20:37
0
游客
登录 | 注册 方可回帖
返回
//