mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4343] [CLOSED] [Engine] dsv41: a kept conversation's files are its owner's alone (0600) #5019
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5019
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4343
Author: @suifei
Created: 10/27/2026
Status: ❌ Closed
Base:
main← Head:claude/busy-albattani-fjntdn📝 Commits (1)
1e2d2d8[Engine] dsv41: a kept conversation's files are its owner's alone (0600)📊 Changes
4 files changed (+95 additions, -9 deletions)
View changed files
📝
docs/DEEPSEEK41.md(+2 -1)📝
src/dsv41/ds4_main.cpp(+17 -7)📝
src/dsv41/ds4_slotmeta.hpp(+38 -0)📝
tests/dsv41/slot_test.cpp(+38 -1)📄 Description
Problem and result
The DeepSeek engine keeps a displaced conversation in its slot folder.
serve/server.py'sdeepseek_slot_env()turns this on for every DeepSeek engine (STRATA_DS4_SLOT_KEEP=1). A slot's.metaholds the conversation's token ids, which decode to the prompt. Its.binholds the model state. Both files were written with the process umask. On the box where this was found, the folder wasdrwxrwxr-xand the files664, so any other user on the machine could read every kept conversation.After this change, on Linux:
0600as it is made;0600when the engine starts;0700.Windows is unchanged: the folder's inherited ACL decides there.
Related discussion
none
Approach
ds4_slotmeta.hppgets two helpers:create_private(path)removes any leftover file of that name, then creates the file withopen(O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0600). The mode is set as the file is made, so no other user can open it in between. A file is removed first because a mode only applies at creation, and an interrupted write can leave a.tmpwith a looser mode.make_private(path)sets an existing file to0600.create_privateon their.tmpbefore the stream opens and truncates it:slotmeta::writefor.meta, andslot_write_fileinds4_main.cppfor.bin. The stream keeps the mode.make_privateon every.metaand.binit keeps.0700only whencreate_directoriesjust created it. A folder that already exists keeps its mode, becauseSTRATA_DS4_SLOT_DIRcan name a folder of the user's own. The file modes protect the content either way.chmoddoes not change mtime, so the 7-day expiry is unaffected.docs/DEEPSEEK41.mdsays who can read the slots.Validation
Revision
1e2d2d8(base4b9e05a). Ubuntu 24.04 container, Linux 6.18 x86_64, g++ 13.3.0, CUDA 13.2, four L20s.Passed:
-DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=native -DSTRATA_BUILD_DSV41=ON -DSTRATA_BUILD_TESTS=ON, CUDA 13.2, Release):strata-dsv4135,588,952 bytes andds4_slot_test74,264 bytes linked./tmp/build0600/ds4_slot_testprintedslot_test: all passed, exit 0. The new checks run withumask(0), so a mode can only come from the code: a written.metais0600; a write over a leftover0666.tmpstill gives a0600file and leaves no.tmp;make_privateturns a0664file into0600;create_privategives an empty0600file and returns false for a missing folder;make_privatereturns false for a missing file.STRATA_DS4_SLOT_DIR=/tmp/slot0600-test, a throw-away folder; a slot whose identity does not match is deleted at start, so never the production folder):stat -c '%a' /tmp/slot0600-test-> 700;ds4 slots: wrote 2 conversation(s) to /tmp/slot0600-test; the four files (2.bin, 2.meta) were 600;chmod 664, the same folder, the engine restarted:ds4 slots: folder /tmp/slot0600-test: 2 conversation(s) kept from earlier runs(kept, not refused or deleted), andstat -c '%a'on the four files -> 600 again - the start-up scan made them private;took back ... from the folderline, so that turn read its prompt again (about 1,100 tokens, under a second here, so the turn's 2.5 s does not tell the two apart). The start-up scan registers a kept conversation as a file slot - the.binis read only when a prompt actually continues it, and that path printstook back a N-token conversation from the folder. Taking a conversation back is not what this change asserts; what the run shows is that the files survive, are tightened to0600and are not deleted.g++ -std=c++17 -fsyntax-only -Wall -Wextra -DSTRATA_VERSION='"x"' -Isrc/dsv41 -Iinclude src/dsv41/ds4_main.cpp: no errors and no warnings.Failed:
none observed
Not run:
#ifndef _WIN32and were not compiled there.statfor the mode bits, not a second user's access.GENwith the kept conversation's own tokens plus a few new ones, thentook back a N-token conversation from the folderandDONE'sreusedclose to N. The end-to-end run's next turn didnot continue the kept conversation closely enough to take it back, so this is left for a follow-up run.
Limits
ds4-slotsfolder of an existing install stays775, so other users can still list file names, sizes and times, but not read the content.chmod 700on it closes that.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.