Skip to content

Commit d17acea

Browse files
authored
Merge pull request #10 from dark-tree/kmres_fix
Small feature - added data sanitization to kmres, so that Maks doesn'…
2 parents 8881288 + 9276df2 commit d17acea

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/kernel/kmalloc.asm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ bits 32
77
section .text
88

99
extern memmove
10+
extern clamp
1011

1112
global kmalloc
1213
global kset
@@ -87,6 +88,29 @@ push EDI
8788
add EAX, [EBP+12]
8889
sub EAX, 1 ;Calculating where the last byte of the desired reservation is, by adding size to offset and subtracting 1
8990

91+
mov EBX, [offset]
92+
add EBX, [size]
93+
sub EBX, 1
94+
95+
push EBX
96+
mov ECX, [offset]
97+
push ECX
98+
push EAX
99+
call clamp
100+
add ESP, 12
101+
102+
push EAX
103+
104+
push EBX
105+
mov ECX, [offset]
106+
push ECX
107+
push DWORD [EBP+8]
108+
call clamp
109+
add ESP, 12
110+
mov [EBP+8], EAX
111+
112+
pop EAX
113+
90114
sub EAX, [offset]
91115
mov EDX, 0
92116
mov EBX, KMALLOC_BLOCK_SIZE

0 commit comments

Comments
 (0)