TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Dereferencing a NULL pointer always segfaults, right? Not if you're clever...

65 pointsby nelhageabout 15 years ago

6 comments

Eliezerabout 15 years ago
My first reaction to this headline was "Surely there is never any circumstance where this is genuinely a smart thing to do, no matter how <i>clever</i>" but I confess I wasn't thinking in terms of security vulnerabilities.
评论 #1232567 未加载
评论 #1232217 未加载
评论 #1232056 未加载
kingkilrabout 15 years ago
In a related bit of cleverness I've heard that the JVM doesn't actually put NULL checks in it's generated ASM, instead it installs a SIGSEGV handler that catchs the null pointer exception and does the right thing.
评论 #1232550 未加载
jhgabout 15 years ago
I'm not sure who's the intended audience of this. It is called an Introduction to Virtual Memory that is aimed at C programmers.<p>How many C programmers are out there that do not know how VM works?
评论 #1232213 未加载
Locke1689about 15 years ago
I'll stick around for the second installment, I guess, but this was a bit too basic for my tastes.
评论 #1232084 未加载
scott_sabout 15 years ago
Check it out: <a href="http://lwn.net/Articles/347006/" rel="nofollow">http://lwn.net/Articles/347006/</a><p>These null pointers are sometimes <i>function pointers</i>. Wow. You don't even need to muck with the stack and change the return address to get arbitrary code execution.<p>I admit I'm surprised Linux even lets you mmap 0x0. I suppose most systems won't, since mmap_min_addr will probably be set to a sane address, but it's still a legit vulnerability.
bedigerabout 15 years ago
Not under HP-UX on a "PA" processor. The page at 0x0 isn't neccessarily unmapped or marked noread/nowrite/nonothing. As I recall one or the other HP C compilers has a way around this, but unless you take care, you won't use that compiler flag, and you end up having NULL pointer de-refs.