frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

D4d4

https://www.nmichaels.org/musings/d4d4/d4d4/
287•csense•3d ago

Comments

rokkamokka•4h ago
God I love blame for use cases like this
nokeya•4h ago
May this be exploited?
pm215•3h ago
If you can already subvert the flow of execution enough to jump somewhere you shouldn't be, you probably have better targets elsewhere in the binary than a conditional branch.
Normal_gaussian•3h ago
Certainly true if you control the entire value; but if you can only flip a bit or two then this does provide a trampoline to increase the exploits range.

Probably more of a "stick it in the toolbox for automatic use" rather than building an exploit around it type of situation however.

JdeBP•3h ago
You have almost, with that statement, figured out what this really is and why it is there.

* https://news.ycombinator.com/item?id=44970832

rasz•3h ago
TLDR: Linker is kicking up the 4d3d3d3.
davedx•3h ago
Sounds like this could cause some awful heisenbugs if the instruction was ever reached?
chaboud•3h ago
Do you want obfuscated supply-chain state-actor vulnerabilities? Because this is how you get obfuscated supply-chain state-actor vulnerabilities!

(Unless someone stays up all night to find the bugs....)

Normal_gaussian•3h ago
This is cool; and yes, fairly clearly a bug with the commit showing both the name (trap instruction) and INT3 (debug) being used for x86.

I definitely wouldn't have got this far looking at this - I'd have quickly assumed it was a sentinel value being used for padding and moved on with my day. Good work.

skrebbel•3h ago
Cool story! If I may rant off topic a bit though, it boggles my mind that people put stuff like this:

> [This patch] fills holes in executable sections with 0xd4 (ARM) or 0xef (MIPS). These trap instructions were suggested by Theo de Raadt.

into commit messages, but not in the code. What's the cost? What's the downside to having a 2 to 3 line comment above a constant in a C file? Why pretend like all this is super obvious when clearly it isn't?

There seems to be some unwritten cultural rule, particularly in FOSS land, that you're supposed to write code as if you're an all-knowing oracle, as if everything is obvious, and so comments are for losers (as are descriptive variable names). I simply can't understand how and why that developed.

Ghoelian•3h ago
A lot of developers think code should be self-documenting, which I fully agree with. Unfortunately though I don't think I've ever worked on a project that was actually self-documented, even though that is what the leads wanted.
lionkor•2h ago
I really like putting context into commits, not into code comments. The reasoning is pretty simple: Comments aren't checked. I might write "This is done this way because John Doe suggested it, it's much more efficient this way", and then someone else changes the code to be buggy, wrong, and slow. Now, the comment is explaining behavior that is no longer there, and wrongly suggests that the code does/means something it doesn't.

Another argument is comments-as-noise, as I would call it. The more "unnecessary" comments you write, the more core developers (who write and read most of the code), will learn to ignore comments. Then, critical comments like "Be careful not to call this when XYZ isn't initialized yet, unless you don't mind ABC happening" are ignored, and ta-da! comments are now useless.

Commit messages are attached to specific changes. If I want to know why a line of code is the way it is, I can git blame it, and see which commit is to blame, together with issue numbers, authors, maybe reviewers, context, history, etc.

Should there be a comment briefly explaining this patch? Probably. But the commit message should add the other context.

Kwpolska•15m ago
Git blame won't show you the history you care about if the line is changed in the future.
ahofmann•2h ago
But this works as intended? The code isn't cluttered with documentation, that doesn't necessarily makes sense when reading the code, but by reading the commit, one can understand why the code was written like that.
Dylan16807•2h ago
Cluttered? A sentence describing a magic value is not clutter.
lintfordpickle•1h ago
I'm not necessarily disagreeing with you (because apparently this is missing), but a descriptive constant/variable name would be even less clutter than even a 1-line comment
mananaysiempre•2h ago
Huh? Quoting a bit more from the article:

> [W]e find this in ARM.cpp:

> trapInstr = {0xd4, 0xd4, 0xd4, 0xd4};

The only thing left to explain is that the trap instruction is used as padding, but you can’t tell from here if that’s obvious or not. Opening the actual code[1], we see that the occurrences of trapInstr are all along the lines of

> void ARM::writePlt( /* ... */ ) {

> /* ... */

> memcpy(buf + 12, trapInstr.data(), 4); // Pad to 16-byte boundary

which isn’t the absolute best, but seems clear enough (if of course you know what a PLT is, which you should if you’re writing a linker).

I do think this merits an explanation that we’re using (what’s intended to be) a trap because the traditional option of using a nop makes ASLR less effective. But then the commit message you’re quoting doesn’t mention that either.

[1] https://github.com/llvm/llvm-project/blob/b20c291baec94ba370...

vessenes•2h ago
I think it's a human thing. The Torah is succinct; The Talmud has a lot to say about it. For a large codebase, the comments would be huge, and also I think distracting.

In fact, as a former code auditor I can say that comments at times make bug finding harder -- they frame you up a certain way. I definitely preferred to audit without comments.

Anyway, there are definitely valid reasons. I think the commit log or dev notes files are generally preferable, especially when combined with good naming.

JdeBP•3h ago
It's not exploitable. It's an exploit mitigation, in fact. It's not a bug; it's intentional that it works this way. And Nathan Michaels didn't think that if you want to find Theo de Raadt writing on some subject, better try OpenBSD discussion fora, not the LLVM mailing list. (-:

This was put into OpenBSD back in 2017. It's not "trap instructions". It's "trapsleds". The idea is to trap the sleds (a.k.a. slides) of NOP instructions that linkers used to put in between compiled code for alignment, and which could be exploited with "return-oriented programming" where an attacker could cause execution to jump to any address in the padding range (possibly needing the inexactitude because of constraints upon byte substitutions) and slide along all of the NOPs to the target function.

* https://undeadly.org/cgi?action=article;sid=20170622065629

* https://isopenbsdsecu.re/mitigations/trapsled/

vintagedave•3h ago
The article states that on ARM Thumb, the instruction meant to be interpreted as a trap does not trap but jumps, instead.
JdeBP•2h ago
Welcome to a world where people copy ideas from OpenBSD and miss parts of them. If you believe some OpenBSD people, this happens all the time. (-:

Don't get them talking, for starters, about the flag files problems that people have introduced to doas, for example, because they didn't copy the OpenBSD kernel feature that original doas relies upon. Or you'll invoke the spirit of Ted Unangst.

* https://news.ycombinator.com/item?id=37314526

Here, they've missed the clear explanation in the original of how and why it both traps and jumps. (And what caution made them add the jump, even though Microsoft had prior to that time been doing the trap-only version for years.)

colanderman•2h ago
You are misunderstanding the purpose of the initial jump in a trap sled. It is to redirect code which expects to flow through the sled past the traps, while leaving the traps for anything else which lands in that range.

The padding the article is talking about lives between functions. It is not meant to be executed, nothing is needed to jump over it. (The unconditional bx lr before it is the return at the end of the function.)

JdeBP•1h ago
I'm not misunderstanding it. Quite the contrary. I've not written the straw man words that you have just tried to put into my mouth, or said anything other than look to Todd Mortimer's own explanation for this. The actual misunderstanding is yours. You've not read Todd Mortimer's and Theo de Raadt's explanations of the OpenBSD original being for both scenarios, and their not knowing of a way to distinguish them in gcc at the point where they are placing the patch.

And you also haven't spotted, even though Nathan Michaels called it out, that the LLVM version is from someone who either read what Theo de Raadt wrote in the commit or read Todd Mortimer's account of the BSDCan conversation, and copied the idea from GCC for x86 into LLVM for ARM. Rui Ueyama, like you, didn't absorb all of the original explanation, however, otherwise xe would have caught why Todd Mortimer didn't originally do the Microsoft-style string of all-the-same instructions that Rui Ueyama then did.

colanderman•59m ago
From your own link:

> The trapsleds implemented in this diff convert NOP sleds longer than 2 bytes from a series of 0x66666690 instructions to a 2 byte short JMP over a series of INT3 instructions that fill the rest of the gap.

The BMI instructions in the article are not jumping over breakpoint (INT3) instructions. They're conditionally jumping backwards by some amount.

Why in your belief is this? Please use your own words or a relevant direct quote to state your understanding of how a trapsled works.

Dylan16807•2h ago
> It's not exploitable.

The article doesn't say it is.

> It's an exploit mitigation, in fact.

The article made that clear.

> It's not a bug; it's intentional that it works this way.

What is "this way"? Trap or jump? If you're saying a jump is supposed to count as a trap, it's a pretty bad one. It still allows a lot of jumps to the padding to continue and execute valuable code.

colanderman•2h ago
The instructions have to be trap instructions for it to work.

The conditional branch-backward instruction it is is almost as bad as the series of NOPs, since it is still likely to redirect an attacker to functioning code. (If the attacker can clear the mi flag first, these are just NOPs!)

Hence yes, this is a broken exploit mitigation.

JdeBP•1h ago
And this is where the OpenBSD people will paraphrase Henry Spencer and say that those who do not understand OpenBSD are doomed to reinvent it badly. (Personally, I think that that's putting OpenBSD onto a pedestal. It's no ideal; one gets the same tradeoffs and problems as everywhere else.) In this case, the reinvention for LLVM targetting ARM, that credits seeing this committed to OpenBSD by Theo de Raadt, totally ignored that the original for gas targetting x86 both trapped and jumped.

I intentionally also pointed you to a collection of several critiques of the whole idea, long-since made. (-:

colanderman•48m ago
Why, in your own words, is the jump supposed to be there? (Keep in mind this code is in between two functions.)

And why, in your own words, is it OK for the jump to be a conditional backwards jump?

k33n•2h ago
I think it’s just an artifact of objdump and not even real.
terminalbraid•1h ago
How does someone reconcile your statement with the second part of the article where they find the LLVM source that's explicitly generating it with comments suggesting why?
colanderman•1h ago
Hex D4xxxxxx is indeed (almost) BRK... on ARM64 [1].

Being ARM32, these should be BKPT (hex BExx). [2]

[1] https://developer.arm.com/documentation/ddi0602/2025-06/Base...

[2] https://developer.arm.com/documentation/ddi0597/2024-09/Base...

Using Podman, Compose and BuildKit

https://emersion.fr/blog/2025/using-podman-compose-and-buildkit/
88•LaSombra•2h ago•13 comments

Ride in Your Privately-Owned Train Cars to See North America

https://www.amtrak.com/privately-owned-rail-cars
35•jasoncartwright•47m ago•27 comments

Margin debt surges in June to record high

https://www.advisorperspectives.com/dshort/updates/2025/07/23/margin-debt-surges-record-high-june-2025
60•pera•1h ago•71 comments

D4d4

https://www.nmichaels.org/musings/d4d4/d4d4/
290•csense•3d ago•34 comments

Weaponizing image scaling against production AI systems

https://blog.trailofbits.com/2025/08/21/weaponizing-image-scaling-against-production-ai-systems/
20•tatersolid•58m ago•0 comments

AI Mode in Search gets new agentic features and expands globally

https://blog.google/products/search/ai-mode-agentic-personalized/
37•meetpateltech•2h ago•37 comments

Show HN: ChartDB Cloud – Visualize and Share Database Diagrams

https://app.chartdb.io
5•Jonathanfishner•18m ago•0 comments

Show HN: OS X Mavericks Forever

https://mavericksforever.com/
74•Wowfunhappy•2d ago•21 comments

Show HN: Using Common Lisp from Inside the Browser

https://turtleware.eu/posts/Using-Common-Lisp-from-inside-the-Browser.html
14•jackdaniel•1h ago•0 comments

Activeloop (YC S18) Is Hiring Member of Technical Staff – Back End Engineering

https://careers.activeloop.ai/
1•davidbuniat•1h ago

Mark Zuckerberg freezes AI hiring amid bubble fears

https://www.telegraph.co.uk/business/2025/08/21/zuckerberg-freezes-ai-hiring-amid-bubble-fears/
142•pera•2h ago•143 comments

AWS CEO says using AI to replace junior staff is 'Dumbest thing I've ever heard'

https://www.theregister.com/2025/08/21/aws_ceo_entry_level_jobs_opinion/
31•JustExAWS•26m ago•2 comments

The Open-Office Trap (2014)

https://www.newyorker.com/business/currency/the-open-office-trap
34•cebert•3h ago•25 comments

Sütterlin

https://en.wikipedia.org/wiki/S%C3%BCtterlin
15•anonu•2d ago•10 comments

To Infinity but Not Beyond

https://meyerweb.com/eric/thoughts/2025/08/20/to-infinity-but-not-beyond/
29•roosgit•3h ago•2 comments

Show HN: I replaced vector databases with Git for AI memory (PoC)

https://github.com/Growth-Kinetics/DiffMem
134•alexmrv•6h ago•34 comments

Why are anime catgirls blocking my access to the Linux kernel?

https://lock.cmpxchg8b.com/anubis.html
667•taviso•22h ago•692 comments

Show HN: I was curious about spherical helix, ended up making this visualization

https://visualrambling.space/moving-objects-in-3d/
806•damarberlari•23h ago•131 comments

AI crawlers, fetchers are blowing up websites; Meta, OpenAI are worst offenders

https://www.theregister.com/2025/08/21/ai_crawler_traffic/
31•rntn•1h ago•11 comments

Code review can be better

https://tigerbeetle.com/blog/2025-08-04-code-review-can-be-better/
318•sealeck•14h ago•178 comments

Epson MX-80 Fonts

https://mw.rat.bz/MX-80/
124•m_walden•4d ago•41 comments

A statistical analysis of Rotten Tomatoes

https://www.statsignificant.com/p/is-rotten-tomatoes-still-reliable
178•m463•13h ago•94 comments

Home Depot sued for 'secretly' using facial recognition at self-checkouts

https://petapixel.com/2025/08/20/home-depot-sued-for-secretly-using-facial-recognition-technology-on-self-checkout-cameras/
213•mikece•21h ago•279 comments

Data, objects, and how we're railroaded into poor design (2018)

https://www.tedinski.com/2018/01/23/data-objects-and-being-railroaded-into-misdesign.html
73•dvrp•8h ago•36 comments

Universal Tool Calling Protocol (UTCP)

https://github.com/universal-tool-calling-protocol/python-utcp
51•edweis•3d ago•51 comments

SK hynix dethrones Samsung as world’s top DRAM maker

https://koreajoongangdaily.joins.com/news/2025-08-15/business/tech/Thanks-Nvidia-SK-hynix-dethrones-Samsung-as-worlds-top-DRAM-maker-for-first-time-in-over-30-years/2376834
153•ksec•3d ago•60 comments

Sixteen bottles of wine riddle

https://chriskw.xyz/2025/08/11/Wine/
20•chriskw•3d ago•8 comments

Gemma 3 270M re-implemented in pure PyTorch for local tinkering

https://github.com/rasbt/LLMs-from-scratch/tree/main/ch05/12_gemma3
394•ModelForge•23h ago•55 comments

Mirror Ball Emoji Proposal (2018) [pdf]

https://www.unicode.org/L2/L2019/19310-mirror-ball-emoji.pdf
47•michalc•4d ago•35 comments

Python f-string cheat sheets (2022)

https://fstring.help/cheat/
93•shlomo_z•8h ago•18 comments