Skip to content

Commit db419ef

Browse files
committed
[WIN32K] Fix protection of USER heap
Create the section with PAGE_READWRITE, not PAGE_EXECUTE_READWRITE and map in user mode with PAGE_READONLY, not PAGE_EXECUTE_READ. Original commit was ea5261f in 2006. The comments suggest that back then the heap code had issues with it, which is not the case anymore.
1 parent 9139d0f commit db419ef

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

win32ss/user/ntuser/desktop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3262,7 +3262,7 @@ IntMapDesktopView(IN PDESKTOP pdesk)
32623262
&ViewSize,
32633263
ViewUnmap,
32643264
SEC_NO_CHANGE,
3265-
PAGE_EXECUTE_READ); /* Would prefer PAGE_READONLY, but thanks to RTL heaps... */
3265+
PAGE_READONLY);
32663266
if (!NT_SUCCESS(Status))
32673267
{
32683268
ERR("Failed to map desktop\n");

win32ss/user/ntuser/usrheap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ IntUserHeapCommitRoutine(
8181
&ViewSize,
8282
ViewUnmap,
8383
SEC_NO_CHANGE,
84-
PAGE_EXECUTE_READ); /* Would prefer PAGE_READONLY, but thanks to RTL heaps... */
84+
PAGE_READONLY);
8585

8686
if (!NT_SUCCESS(Status))
8787
return Status;
@@ -97,7 +97,7 @@ IntUserHeapCommitRoutine(
9797
0,
9898
CommitSize,
9999
MEM_COMMIT,
100-
PAGE_EXECUTE_READ);
100+
PAGE_READONLY);
101101

102102
if (NT_SUCCESS(Status))
103103
{
@@ -139,7 +139,7 @@ IntUserHeapCreate(IN PVOID SectionObject,
139139
&ViewSize,
140140
ViewUnmap,
141141
SEC_NO_CHANGE,
142-
PAGE_EXECUTE_READ); /* Would prefer PAGE_READONLY, but thanks to RTL heaps... */
142+
PAGE_READONLY);
143143
if (!NT_SUCCESS(Status))
144144
return NULL;
145145

@@ -148,7 +148,7 @@ IntUserHeapCreate(IN PVOID SectionObject,
148148
0,
149149
&ViewSize,
150150
MEM_COMMIT,
151-
PAGE_EXECUTE_READ); /* Would prefer PAGE_READONLY, but thanks to RTL heaps... */
151+
PAGE_READONLY);
152152

153153
MmUnmapViewOfSection(PsGetCurrentProcess(),
154154
MappedView);
@@ -193,7 +193,7 @@ UserCreateHeap(OUT PVOID *SectionObject,
193193
SECTION_ALL_ACCESS,
194194
NULL,
195195
&SizeHeap,
196-
PAGE_EXECUTE_READWRITE, /* Would prefer PAGE_READWRITE, but thanks to RTL heaps... */
196+
PAGE_READWRITE,
197197
SEC_RESERVE | 1,
198198
NULL,
199199
NULL);
@@ -315,7 +315,7 @@ MapGlobalUserHeap(IN PEPROCESS Process,
315315
&ViewSize,
316316
ViewUnmap,
317317
SEC_NO_CHANGE,
318-
PAGE_EXECUTE_READ); /* Would prefer PAGE_READONLY, but thanks to RTL heaps... */
318+
PAGE_READONLY);
319319
if (!NT_SUCCESS(Status))
320320
{
321321
ERR_CH(UserProcess, "MapGlobalUserHeap - Failed to map the global heap! 0x%x\n", Status);

0 commit comments

Comments
 (0)