Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
800b05c4
Commit
800b05c4
authored
Jan 13, 2009
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jan 14, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Check pointers in NtAccessCheck to prevent access violation.
parent
eda4872c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
0 deletions
+100
-0
security.c
dlls/advapi32/tests/security.c
+97
-0
sec.c
dlls/ntdll/sec.c
+3
-0
No files found.
dlls/advapi32/tests/security.c
View file @
800b05c4
...
...
@@ -107,6 +107,8 @@ static BOOL (WINAPI *pSetSecurityDescriptorControl)(PSECURITY_DESCRIPTOR, SECURI
SECURITY_DESCRIPTOR_CONTROL
);
static
DWORD
(
WINAPI
*
pGetSecurityInfo
)(
HANDLE
,
SE_OBJECT_TYPE
,
SECURITY_INFORMATION
,
PSID
*
,
PSID
*
,
PACL
*
,
PACL
*
,
PSECURITY_DESCRIPTOR
*
);
static
NTSTATUS
(
WINAPI
*
pNtAccessCheck
)(
PSECURITY_DESCRIPTOR
,
HANDLE
,
ACCESS_MASK
,
PGENERIC_MAPPING
,
PPRIVILEGE_SET
,
PULONG
,
PULONG
,
NTSTATUS
*
);
static
HMODULE
hmod
;
static
int
myARGC
;
...
...
@@ -142,6 +144,7 @@ static void init(void)
hntdll
=
GetModuleHandleA
(
"ntdll.dll"
);
pNtQueryObject
=
(
void
*
)
GetProcAddress
(
hntdll
,
"NtQueryObject"
);
pNtAccessCheck
=
(
void
*
)
GetProcAddress
(
hntdll
,
"NtAccessCheck"
);
hmod
=
GetModuleHandle
(
"advapi32.dll"
);
pAddAccessAllowedAceEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"AddAccessAllowedAceEx"
);
...
...
@@ -842,6 +845,7 @@ static void test_AccessCheck(void)
HMODULE
NtDllModule
;
BOOLEAN
Enabled
;
DWORD
err
;
NTSTATUS
ntret
,
ntAccessStatus
;
NtDllModule
=
GetModuleHandle
(
"ntdll.dll"
);
if
(
!
NtDllModule
)
...
...
@@ -917,6 +921,7 @@ static void test_AccessCheck(void)
/* Generic access mask */
SetLastError
(
0xdeadbeef
);
Access
=
AccessStatus
=
0xdeadbeef
;
ret
=
AccessCheck
(
SecurityDescriptor
,
Token
,
GENERIC_READ
,
&
Mapping
,
PrivSet
,
&
PrivSetLen
,
&
Access
,
&
AccessStatus
);
err
=
GetLastError
();
...
...
@@ -925,7 +930,41 @@ static void test_AccessCheck(void)
ok
(
Access
==
0xdeadbeef
&&
AccessStatus
==
0xdeadbeef
,
"Access and/or AccessStatus were changed!
\n
"
);
/* Generic access mask - no privilegeset buffer */
SetLastError
(
0xdeadbeef
);
Access
=
AccessStatus
=
0xdeadbeef
;
ret
=
AccessCheck
(
SecurityDescriptor
,
Token
,
GENERIC_READ
,
&
Mapping
,
NULL
,
&
PrivSetLen
,
&
Access
,
&
AccessStatus
);
err
=
GetLastError
();
ok
(
!
ret
&&
err
==
ERROR_NOACCESS
,
"AccessCheck should have failed "
"with ERROR_NOACCESS, instead of %d
\n
"
,
err
);
ok
(
Access
==
0xdeadbeef
&&
AccessStatus
==
0xdeadbeef
,
"Access and/or AccessStatus were changed!
\n
"
);
/* Generic access mask - no returnlength */
SetLastError
(
0xdeadbeef
);
Access
=
AccessStatus
=
0xdeadbeef
;
ret
=
AccessCheck
(
SecurityDescriptor
,
Token
,
GENERIC_READ
,
&
Mapping
,
PrivSet
,
NULL
,
&
Access
,
&
AccessStatus
);
err
=
GetLastError
();
ok
(
!
ret
&&
err
==
ERROR_NOACCESS
,
"AccessCheck should have failed "
"with ERROR_NOACCESS, instead of %d
\n
"
,
err
);
ok
(
Access
==
0xdeadbeef
&&
AccessStatus
==
0xdeadbeef
,
"Access and/or AccessStatus were changed!
\n
"
);
/* Generic access mask - no privilegeset buffer, no returnlength */
SetLastError
(
0xdeadbeef
);
Access
=
AccessStatus
=
0xdeadbeef
;
ret
=
AccessCheck
(
SecurityDescriptor
,
Token
,
GENERIC_READ
,
&
Mapping
,
NULL
,
NULL
,
&
Access
,
&
AccessStatus
);
err
=
GetLastError
();
ok
(
!
ret
&&
err
==
ERROR_NOACCESS
,
"AccessCheck should have failed "
"with ERROR_NOACCESS, instead of %d
\n
"
,
err
);
ok
(
Access
==
0xdeadbeef
&&
AccessStatus
==
0xdeadbeef
,
"Access and/or AccessStatus were changed!
\n
"
);
/* sd with no dacl present */
Access
=
AccessStatus
=
0xdeadbeef
;
ret
=
SetSecurityDescriptorDacl
(
SecurityDescriptor
,
FALSE
,
NULL
,
FALSE
);
ok
(
ret
,
"SetSecurityDescriptorDacl failed with error %d
\n
"
,
GetLastError
());
ret
=
AccessCheck
(
SecurityDescriptor
,
Token
,
KEY_READ
,
&
Mapping
,
...
...
@@ -935,7 +974,63 @@ static void test_AccessCheck(void)
"AccessCheck failed to grant access with error %d
\n
"
,
GetLastError
());
/* sd with no dacl present - no privilegeset buffer */
SetLastError
(
0xdeadbeef
);
Access
=
AccessStatus
=
0xdeadbeef
;
ret
=
AccessCheck
(
SecurityDescriptor
,
Token
,
GENERIC_READ
,
&
Mapping
,
NULL
,
&
PrivSetLen
,
&
Access
,
&
AccessStatus
);
err
=
GetLastError
();
ok
(
!
ret
&&
err
==
ERROR_NOACCESS
,
"AccessCheck should have failed "
"with ERROR_NOACCESS, instead of %d
\n
"
,
err
);
ok
(
Access
==
0xdeadbeef
&&
AccessStatus
==
0xdeadbeef
,
"Access and/or AccessStatus were changed!
\n
"
);
if
(
pNtAccessCheck
)
{
/* Generic access mask - no privilegeset buffer */
SetLastError
(
0xdeadbeef
);
Access
=
ntAccessStatus
=
0xdeadbeef
;
ntret
=
pNtAccessCheck
(
SecurityDescriptor
,
Token
,
GENERIC_READ
,
&
Mapping
,
NULL
,
&
PrivSetLen
,
&
Access
,
&
ntAccessStatus
);
err
=
GetLastError
();
ok
(
ntret
==
STATUS_ACCESS_VIOLATION
,
"NtAccessCheck should have failed with STATUS_ACCESS_VIOLATION, got %x
\n
"
,
ntret
);
ok
(
err
==
0xdeadbeef
,
"NtAccessCheck shouldn't set last error, got %d
\n
"
,
err
);
ok
(
Access
==
0xdeadbeef
&&
ntAccessStatus
==
0xdeadbeef
,
"Access and/or AccessStatus were changed!
\n
"
);
/* Generic access mask - no returnlength */
SetLastError
(
0xdeadbeef
);
Access
=
ntAccessStatus
=
0xdeadbeef
;
ntret
=
pNtAccessCheck
(
SecurityDescriptor
,
Token
,
GENERIC_READ
,
&
Mapping
,
PrivSet
,
NULL
,
&
Access
,
&
ntAccessStatus
);
err
=
GetLastError
();
ok
(
ntret
==
STATUS_ACCESS_VIOLATION
,
"NtAccessCheck should have failed with STATUS_ACCESS_VIOLATION, got %x
\n
"
,
ntret
);
ok
(
err
==
0xdeadbeef
,
"NtAccessCheck shouldn't set last error, got %d
\n
"
,
err
);
ok
(
Access
==
0xdeadbeef
&&
ntAccessStatus
==
0xdeadbeef
,
"Access and/or AccessStatus were changed!
\n
"
);
/* Generic access mask - no privilegeset buffer, no returnlength */
SetLastError
(
0xdeadbeef
);
Access
=
ntAccessStatus
=
0xdeadbeef
;
ntret
=
pNtAccessCheck
(
SecurityDescriptor
,
Token
,
GENERIC_READ
,
&
Mapping
,
NULL
,
NULL
,
&
Access
,
&
ntAccessStatus
);
err
=
GetLastError
();
ok
(
ntret
==
STATUS_ACCESS_VIOLATION
,
"NtAccessCheck should have failed with STATUS_ACCESS_VIOLATION, got %x
\n
"
,
ntret
);
ok
(
err
==
0xdeadbeef
,
"NtAccessCheck shouldn't set last error, got %d
\n
"
,
err
);
ok
(
Access
==
0xdeadbeef
&&
ntAccessStatus
==
0xdeadbeef
,
"Access and/or AccessStatus were changed!
\n
"
);
}
else
win_skip
(
"NtAccessCheck unavailable. Skipping.
\n
"
);
/* sd with NULL dacl */
Access
=
AccessStatus
=
0xdeadbeef
;
ret
=
SetSecurityDescriptorDacl
(
SecurityDescriptor
,
TRUE
,
NULL
,
FALSE
);
ok
(
ret
,
"SetSecurityDescriptorDacl failed with error %d
\n
"
,
GetLastError
());
ret
=
AccessCheck
(
SecurityDescriptor
,
Token
,
KEY_READ
,
&
Mapping
,
...
...
@@ -963,6 +1058,7 @@ static void test_AccessCheck(void)
ok
(
res
,
"AddAccessDeniedAce failed with error %d
\n
"
,
GetLastError
());
/* sd with dacl */
Access
=
AccessStatus
=
0xdeadbeef
;
ret
=
AccessCheck
(
SecurityDescriptor
,
Token
,
KEY_READ
,
&
Mapping
,
PrivSet
,
&
PrivSetLen
,
&
Access
,
&
AccessStatus
);
ok
(
ret
,
"AccessCheck failed with error %d
\n
"
,
GetLastError
());
...
...
@@ -980,6 +1076,7 @@ static void test_AccessCheck(void)
/* Access denied by SD */
SetLastError
(
0xdeadbeef
);
Access
=
AccessStatus
=
0xdeadbeef
;
ret
=
AccessCheck
(
SecurityDescriptor
,
Token
,
KEY_WRITE
,
&
Mapping
,
PrivSet
,
&
PrivSetLen
,
&
Access
,
&
AccessStatus
);
ok
(
ret
,
"AccessCheck failed with error %d
\n
"
,
GetLastError
());
...
...
dlls/ntdll/sec.c
View file @
800b05c4
...
...
@@ -1562,6 +1562,9 @@ NtAccessCheck(
SecurityDescriptor
,
ClientToken
,
DesiredAccess
,
GenericMapping
,
PrivilegeSet
,
ReturnLength
,
GrantedAccess
,
AccessStatus
);
if
(
!
PrivilegeSet
||
!
ReturnLength
)
return
STATUS_ACCESS_VIOLATION
;
SERVER_START_REQ
(
access_check
)
{
struct
security_descriptor
sd
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment