首页
社区
课程
招聘
[求助]如何有效检测用户态空间的无效地址?
发表于: 2009-10-11 14:42 9538

[求助]如何有效检测用户态空间的无效地址?

2009-10-11 14:42
9538
在内核态通过KeStackAttachProcess函数来读取用户态地址空间,当使用ProbeForRead函数好像对于用户态的无效地址不能返回异常,如何才能有效检测用户态地址空间是否有效?

[注意]看雪招聘,专注安全领域的专业人才平台!

收藏
免费
支持
分享
最新回复 (6)
雪    币: 203
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
大概我的方法如下:
KeStackAttachProcess();
__try
{
        ProbeForRead();
        memcpy();//拷贝用户态内存到内核态中,此处用户态地址可能无效
}
__except(EXCEPTION_EXECUTE_HANDLER)
{

}
2009-10-11 14:45
0
雪    币: 203
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
WINDBG捕获的错误如下,貌似是CR3出了问题

*** Fatal System Error: 0x0000007f
                       (0x0000000D,0x00000000,0x00000000,0x00000000)

Break instruction exception - code 80000003 (first chance)

A fatal system error has occurred.
Debugger entered on first try; Bugcheck callbacks have not been invoked.

A fatal system error has occurred.

Connected to Windows XP 2600 x86 compatible target at (Sun Oct 11 14:23:49.485 2009 (GMT+8)), ptr64 FALSE
Loading Kernel Symbols
....................................WARNING: Process directory table base 079E02C0 doesn't match CR3 079E02E0
WARNING: Process directory table base 079E02C0 doesn't match CR3 079E02E0
...........................
............................................................
Loading User Symbols
PEB is paged out (Peb.Ldr = 7ffdd00c).  Type ".hh dbgerr001" for details
Loading unloaded module list
.........
*******************************************************************************
*                                                                             *
*                        Bugcheck Analysis                                    *
*                                                                             *
*******************************************************************************

Use !analyze -v to get detailed debugging information.

BugCheck 7F, {d, 0, 0, 0}

PEB is paged out (Peb.Ldr = 7ffdd00c).  Type ".hh dbgerr001" for details
PEB is paged out (Peb.Ldr = 7ffdd00c).  Type ".hh dbgerr001" for details
Probably caused by : abc.sys ( abc!GetProcessImage+63 )

Followup: MachineOwner
---------

nt!RtlpBreakWithStatusInstruction:
80527fe8 cc              int     3
2009-10-11 14:51
0
雪    币: 201
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
probeforread当然是可以的,你的问题明显不是访问了无效内存,而是堆栈溢出.
2009-10-11 18:05
0
雪    币: 203
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
我看了一下,错误应该在KeStackAttachProcess中:

b2295234 804f89f7 00000003 b2295590 00000000 nt!RtlpBreakWithStatusInstruction
b2295280 804f95e4 00000003 80541edf 82147060 nt!KiBugCheckDebugBreak+0x19
b2295660 8054120f 0000007f 0000000d 00000000 nt!KeBugCheck2+0x574
b2295660 80541edf 0000007f 0000000d 00000000 nt!KiSystemFatalException+0xf
b22956f0 804f86b0 82147020 82050600 82147020 nt!KiSwapProcess+0x53
b229570c 804f889d 820e7518 82147020 82147000 nt!KiAttachProcess+0x8e
b229572c b228c213 82147000 b229574c 0000a60c nt!KeStackAttachProcess+0x7b
2009-10-11 21:35
0
雪    币: 203
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
你是如何发现是栈溢出的?这个问题我已解决,不是栈溢出
2009-10-16 17:52
0
雪    币: 635
活跃值: (101)
能力值: ( LV12,RANK:420 )
在线值:
发帖
回帖
粉丝
7
double fault最常见的情况就是栈溢出,你这个是切换进程中发生的,比较特殊。
2009-10-16 18:04
0
游客
登录 | 注册 方可回帖
返回

账号登录
验证码登录

忘记密码?
没有账号?立即免费注册