TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

65 点作者 nelhage大约 15 年前

6 条评论

Eliezer大约 15 年前
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 未加载
kingkilr大约 15 年前
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 未加载
jhg大约 15 年前
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 未加载
Locke1689大约 15 年前
I'll stick around for the second installment, I guess, but this was a bit too basic for my tastes.
评论 #1232084 未加载
scott_s大约 15 年前
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.
bediger大约 15 年前
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.