Phase 8 v3: refuse a same-VM, cross-device raw block copy from within StarshipOS
Two research passes confirmed the identity record itself (seed/pubkey/ cert) is already unreachable from any FORTH primitive -- only C-level read_devblock/write_devblock touch it. But a device's ordinary user block content CAN be copied between two attached devices today, using only stock, unpinned words: <src> BLOCK <dst> BUFFER 1024 MOVE UPDATE SAVE-BUFFERS, or the dedicated RELOCATE-BLOCK word (whose own doc comment already admits "performs no policy validation of its own"). Checked whether the existing per-block owner_fp/BLK-ACL-ALLOW@ metadata already solves this -- it doesn't: owner_fp encodes who (a VM identity pubkey), never where (physical device), and blk_get_buffer()/blk_update() never consult acl_allow/acl_ttl at all -- those fields are completely inert. Small, targeted fix, no rearchitecture: - blk_subsys_relocate_block() (block_subsystem.c): same-device check. Its own documented purpose is wear-leveling (relocate on the SAME device) -- never stated as cross-device, and nothing enforced that until now. - New public blk_lbn_device_handle() (block_subsystem.c/.h): the missing LBN-to-device direction (blk_get_device_range() already goes the other way). Opaque, stable, == comparable. - MOVE (memory_words.c) and CMOVE/CMOVE> (string_words.c): refuse when both addresses are block-window addresses backed by two different devices -- the exact shape of the composed attack. A copy where either end is ordinary VM memory (the overwhelming common case: staging text from PAD, editing a block in place) is untouched. - blk_vm_check_epoch()/blk_vm_slot_for_addr() exposed (block_words.h) so the two new call sites share the same window-slot invalidation contract rather than a second, divergent copy of it. Verified live on all three architectures, not just boot-clean: same- device MOVE/RELOCATE-BLOCK still succeed exactly as before; cross-device MOVE/CMOVE/RELOCATE-BLOCK all refused. Zero UNKNOWN WORD, identical dict_hash across all three (this change adds no FORTH-visible word, only internal refusal conditions, as predicted). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
b7d9ed5425
commit
26c1117ccd
@@ -46,6 +46,7 @@
|
||||
#include "../../include/log.h"
|
||||
#include "../../include/vm.h"
|
||||
#include "../../include/vm_api.h"
|
||||
#include "include/block_words.h" /* blk_vm_is_cross_device_copy() -- Phase 8 v3 */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
@@ -626,6 +627,14 @@ static void string_word_cmove(VM *vm) {
|
||||
(long) addr1, (long) addr2, (long) u);
|
||||
return;
|
||||
}
|
||||
/* Phase 8 v3 (2026-09-23): refuse a same-VM, cross-device raw block
|
||||
* copy -- see blk_vm_is_cross_device_copy()'s own doc comment. */
|
||||
if (blk_vm_is_cross_device_copy(vm, src, dst)) {
|
||||
vm->error = 1;
|
||||
log_message(LOG_ERROR, "CMOVE: refused cross-device block copy (src=%ld dst=%ld)",
|
||||
(long) addr1, (long) addr2);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Ascending copy (low->high) */
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
@@ -665,6 +674,14 @@ static void string_word_cmove_greater(VM *vm) {
|
||||
(long) addr1, (long) addr2, (long) u);
|
||||
return;
|
||||
}
|
||||
/* Phase 8 v3 (2026-09-23): refuse a same-VM, cross-device raw block
|
||||
* copy -- see blk_vm_is_cross_device_copy()'s own doc comment. */
|
||||
if (blk_vm_is_cross_device_copy(vm, src, dst)) {
|
||||
vm->error = 1;
|
||||
log_message(LOG_ERROR, "CMOVE>: refused cross-device block copy (src=%ld dst=%ld)",
|
||||
(long) addr1, (long) addr2);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Descending copy (high->low) */
|
||||
for (size_t i = n; i > 0; i--) {
|
||||
|
||||
Reference in New Issue
Block a user