Skip to content

Commit 9c1578c

Browse files
committed
Further changes to the way memory accesses are treated.
1 parent c8112cd commit 9c1578c

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

proposals/0219-stricter-vm-verification.md

+30-24
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ category: Standard
88
type: Core
99
status: Review
1010
created: 2025-01-06
11-
feature: GJVDwRkUPNdk9QaK4VsU4g1N41QNxhy1hevjf8kz45Mq
11+
feature: C37iaPi6VE4CZDueU1vL8y6pGp5i8amAbEsF31xzz723
1212
---
1313

1414
## Summary
@@ -73,45 +73,51 @@ The virtual address space of the stack frames must become consecutive:
7373
This goes for all programs globally and is not opt-in.
7474
Thus, this change is independent of SIMD-0166.
7575

76-
### VM write access
76+
### VM memory access
7777

78-
When a write access to the input region (`0x400000000..0x500000000`) happens,
79-
which overlaps with a range in which an accounts payload, including its resize
80-
padding but not its metadata, was serialized it must be checked that:
78+
The payload address space of an account is the range in the serialized input
79+
region (`0x400000000..0x500000000`) which covers the payload and optionally the
80+
10 KiB resize padding (if not a loader-v1 program), but not the accounts
81+
metadata.
82+
83+
For loads / read accesses to an accounts payload address space check that:
84+
85+
- The access is completely within the current length of the account,
86+
otherwise `InstructionError::AccountDataTooSmall` must be thrown.
87+
88+
For stores / write accesses to an accounts payload address space check that:
8189

8290
- The account is flagged as writable,
8391
otherwise `InstructionError::ReadonlyDataModified` must be thrown
8492
- The account is owned by the currently executed program,
85-
otherwise `InstructionError::ExternalAccountDataModified` must be thrown
86-
87-
Thus, changing and later restoring data in unowned accounts is prohibited.
93+
otherwise `InstructionError::ExternalAccountDataModified` must be thrown.
94+
- The access is completely within the current length of the account,
95+
otherwise grow the account length and fill it with zeros up to the end of the
96+
access or the end of the payload address space, which ever is lower.
8897

8998
### Syscall slice parameters
9099

91-
When a range in virtual address space which:
92-
93-
- starts in any account data (including its resize padding) and leaves it
94-
- starts outside account data and enters it
95-
96-
is passed to `memcpy`, `memmove`, `memset`, or `memcmp`, it must throw
97-
`SyscallError::InvalidLength`.
98-
99100
Except for CPI, all other syscalls which
100101
act on ranges in the virtual address space are confined to a single
101-
memory region for now. Meaning they have to stay within one of:
102+
memory region. Meaning they have to stay within one of:
102103

103-
- Readonly data
104-
- Stack
105-
- Heap
104+
- Readonly data (`0x100000000..0x200000000`)
105+
- Stack (`0x200000000..0x300000000`)
106+
- Heap (`0x300000000..0x400000000`)
107+
- Instruction meta data
106108
- Account meta data
107-
- Account data without resize padding
108-
- Account resize padding
109+
- Account payload address space
110+
- Instruction payload
109111

110-
And can not cross into any other region. This restriction is planned to
111-
be lifted in another SIMD.
112+
And can not cross into any other region.
112113

113114
## Impact
114115

116+
Changing and later restoring data in unowned accounts is now prohibited.
117+
The same goes for growing an unowned account and later truncating it to its
118+
original length. Or reading from the uninitialized memory beyond the current
119+
length of any account.
120+
115121
These restrictions have been extensively tested by replay against MNB.
116122
Most of the dApps devs whose dApps would fail have been contacted and had
117123
their dApps fixed already.

0 commit comments

Comments
 (0)