00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#include "cmp.h"
00026
00027
#ifdef ALLOC_PRAGMA
00028
#pragma alloc_text(PAGE,CmpValidateHiveSecurityDescriptors)
00029
#endif
00030
00031 extern ULONG
CmpUsedStorage;
00032
00033 BOOLEAN
00034 CmpValidateHiveSecurityDescriptors(
00035 IN
PHHIVE Hive
00036 )
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 {
00060
PCM_KEY_NODE RootNode;
00061
PCM_KEY_SECURITY SecurityCell;
00062
HCELL_INDEX ListAnchor;
00063
HCELL_INDEX NextCell;
00064
HCELL_INDEX LastCell;
00065
00066
CMLOG(
CML_FLOW,
CMS_SEC) {
00067 KdPrint((
"CmpValidateHiveSecurityDescriptor: Hive = %lx\n",(ULONG_PTR)
Hive));
00068 }
00069
if (!
HvIsCellAllocated(
Hive,
Hive->
BaseBlock->
RootCell)) {
00070
00071
00072
00073
return(
FALSE);
00074 }
00075 RootNode = (
PCM_KEY_NODE)
HvGetCell(
Hive,
Hive->
BaseBlock->
RootCell);
00076 ListAnchor = NextCell = RootNode->
Security;
00077
00078
do {
00079
if (!
HvIsCellAllocated(
Hive, NextCell)) {
00080
CMLOG(
CML_MAJOR,
CMS_SEC) {
00081 KdPrint((
"CM: CmpValidateHiveSecurityDescriptors\n"));
00082 KdPrint((
" NextCell: %08lx is invalid HCELL_INDEX\n",NextCell));
00083 }
00084
return(
FALSE);
00085 }
00086 SecurityCell = (
PCM_KEY_SECURITY)
HvGetCell(
Hive, NextCell);
00087
if (NextCell != ListAnchor) {
00088
00089
00090
00091
00092
if (SecurityCell->
Blink != LastCell) {
00093
CMLOG(
CML_MAJOR,
CMS_SEC) {
00094 KdPrint((
" Invalid Blink (%ld) on security cell %ld\n",SecurityCell->
Blink, NextCell));
00095 KdPrint((
" should point to %ld\n", LastCell));
00096 }
00097
return(
FALSE);
00098 }
00099 }
00100
CMLOG(
CML_MINOR,
CMS_SEC) {
00101 KdPrint((
"CmpValidSD: SD shared by %d nodes\n",SecurityCell->
ReferenceCount));
00102 }
00103
if (!
SeValidSecurityDescriptor(SecurityCell->
DescriptorLength, &SecurityCell->
Descriptor)) {
00104
CMLOG(
CML_MAJOR,
CMS_SEC) {
00105
CmpDumpSecurityDescriptor(&SecurityCell->
Descriptor,
"INVALID DESCRIPTOR");
00106 }
00107
return(
FALSE);
00108 }
00109
SetUsed(
Hive, NextCell);
00110 LastCell = NextCell;
00111 NextCell = SecurityCell->
Flink;
00112 }
while ( NextCell != ListAnchor );
00113
return(
TRUE);
00114 }