logoalt Hacker News

Memory Safe Inline Assembly

56 pointsby pizlonatorlast Saturday at 3:29 AM13 commentsview on HN

Comments

anitiltoday at 4:06 AM

I find it charming that to distinguish Fil-C from the K&R language they use the term 'Yolo-C'. I have never used inline asm before, I actually didn't realise how much behaviour it's specifying! (When I've needed asm it was on non-gcc compilers)

Edit to add: If I'm understanding this correctly we should be able to run this against projects and detect asm violations, I feel like this would be very valuable to be able to feed these back to maintainers

dataflowtoday at 4:25 AM

Unrelated question but since you're here: what's the state of support for Boost?

show 1 reply
jdw64today at 3:03 AM

What is more frightening about this than safe C assembly is that this level of implementation is achievable not with a SOTA model, but with a cost effective model like KIMI. There was human judgment involved in the middle, but reading the article, My reading of the process is as follows:

1.A developer identified the necessity of inline assembly.

2.Defined the safety boundaries for 'memory-safe' inline assembly.

3.Established strict policies for memory access.

4.Curated an allowlist of permissible instructions.

5.Set rigorous test criteria and 'done' conditions.

In short, with the overall guardrails in place, a sub agent loop was run, and this level of code was produced. This raises a number of interesting points about how we should use AI. I haven't looked at all the code, but the idea of passing assembly through safe zones without memory access, and using that as a foundation to achieve this level of implementation through AI, is quite impressive

IAmLiterallyABtoday at 3:23 AM

I wonder if an adversarial user could bypass the checks and achieve memory corruption / code execution. Maybe not a practical attack in most situations but a fun exercise.

> This includes things like asm volatile("" : : : "memory"), which is an old-school way of saying atomic_signal_fence(memory_order_seq_cst).

Not quite. AIUI, the first is just a barrier for the compiler, while the second is also a CPU memory barrier. Godbolt seems to confirm that.

https://godbolt.org/z/a844zKej8

show 1 reply
anitiltoday at 4:12 AM

Do we have a sense for how many of the programs that work [0] are now detected as having asm violations?

[0] https://fil-c.org/programs_that_work

show 1 reply