虚拟地址

发布于 2024-11-05 19:01:30 字数 45 浏览 1 评论 0原文

假设我正在启动同一程序的两个实例。两个程序的文本区域是否具有相同的虚拟地址?

Suppose I'm starting two instances of the same program. Will the text region of both programs have same virtual addresses?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

软甜啾 2024-11-12 19:01:30

视情况而定。在大多数系统上,如果您在相同的环境(相同的参数等)中运行相同的程序两次,您将发现相同的地址映射。这只是因为进程所做的大部分操作都是确定性的,仅取决于环境、命令行参数、读取的文件内容,而不取决于日期或进程 ID 等数据的更改。这在调试时非常有用:如果重新启动程序,有时即使在进行小的代码更改和重新编译之后,内存布局也有可能保持不变。当然,并发运行的程序的不同实例可能具有相同的虚拟地址,但它们不会具有相同的物理地址。

某些系统(例如 OpenBSD 或具有各种强化设置的 Linux)实现地址空间布局随机化 (ASLR)。 ASLR意味着每次进程启动时,其代码、数据、堆栈和堆的虚拟地址都是随机确定的。这是一项安全功能,旨在使安全漏洞的利用更加困难:利用代码不能只访问已知地址的已知代码。然而,随着 ASLR 变得越来越流行,解决它的漏洞也变得更加复杂。 ASLR 仍然很有用,因为它增加了漏洞编写者的工作量,而不会增加很多复杂性。

Depends. On most systems, if you run the same program twice in the same environment (same parameters, etc.), you'll find the same address mapping. This is simply because most of what the process does is deterministic, dependent only on the environment, command-line parameters, contents of files read, but not on changing data such as the date or process ID. This is very useful when debugging: if you restart your program, sometimes even after a small code change and recompilation, you have a chance that the memory layout remained the same. Of course, different instances of the program running concurrently may have the same virtual addresses, but they won't have the same physical addresses.

Some systems, such as OpenBSD, or Linux with various hardening settings, implement address space layout randomization (ASLR). ASLR means that each time a process starts, the virtual addresses of its code, data, stack(s) and heap(s) are determined at random. This is a security features, designed to make exploits of security vulnerabilities harder: the exploit code can't just access known code at known addresses. However, as ASLR becomes more popular, exploits also become more sophisticated to work around it. ASLR remains useful because it increases the workload for the exploit writer without adding a lot of complexity.

吹泡泡o 2024-11-12 19:01:30

可能不会,但他们有可能可以。每个进程都有自己独立的内存空间。

Probably not, but it's possible that they could. Each process has its own independent memory space.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文