Open files and security

A key point again regarding security, for both the exec and fork scenarios.

When you perform an exec operation, the predecessor process's VAS is essentially overwritten by that of the successor process. However, realize that the predecessor process's open files (held within the OS in a per-process structure called the OFDT, mentioned earlier) remain intact and are, in effect, inherited by the successor process. This could pose a serious security threat. Think about it: what if a security-sensitive file being used by the predecessor is not closed and an exec performed? The successor now has access to it via its file descriptor, whether it exploits that knowledge or not.

The same argument holds true for the fork; if ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.