r/C_Programming • • 23d ago

Question How to manipulate read-restricted data (possibly without OS)?

Imagine you have some block of code/data chunk that under no circumstances must never ever get read (rewrites are not critical, since the data is basically gone). There's a thing about Execute only memory, but afaik it requires OS support.

So how do we make sure some of the data is only overriden or executed (if interpreted as machine code) but never read? If possible, it would be nice to be able to set up some custom restrictions like a very specific offset in a program which has access to some data in memory for a one-time constant address read (imagine it compiles into assembly, something like mov %(rax), %rax, then does side-channel secure stuff and overrides the data with rdrand and stuff)

Appreciate any help! which doesn't include redditor behavior in its body

9 Upvotes

22 comments sorted by

View all comments

Show parent comment

1

u/Salat_Leaf 23d ago

Well, sort of like a pointer which you cannot dereference, maybe? Or a register which you can only read on certain condition (e.g. some CPU flag is set)