Annotation of htdocs/docs/kernel/non-exec.html, revision 1.76

1.55      nia         1: <!DOCTYPE html>
1.68      martin      2: <html lang="en">
1.1       dsieger     3: <head>
1.72      maya        4: <meta charset="utf-8">
1.1       dsieger     5: <meta name="generator" content="Website XSL Stylesheet V2.6.0">
                      6: <link rel="home" href="../../." title="Welcome to The NetBSD Project: Of course it runs NetBSD.">
                      7: <link rel="up" href="../../docs/kernel/." title="NetBSD Documentation: Kernel">
                      8: <link rel="previous" href="../../docs/kernel/lazyfpu.html" title="NetBSD Documentation: How lazy FPU context switch works">
                      9: <link rel="next" href="../../docs/kernel/ddwg.html" title="NetBSD Device Driver Writing Guide">
                     10: <link rel="first" href="../../docs/kernel/lazyfpu.html" title="NetBSD Documentation: How lazy FPU context switch works">
                     11: <link rel="last" href="../../docs/kernel/elf-notes.html" title="NetBSD Documentation: Vendor-specific ELF Note Elements">
1.10      dsieger    12: <link rel="stylesheet" href="../../global.css" type="text/css">
1.46      maya       13: <link rel="stylesheet" href="../../donations/thermo/fundraiser.css" type="text/css">
1.1       dsieger    14: <title>Non-executable stack and heap</title>
1.67      andvar     15: <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
1.1       dsieger    16: </head>
1.69      andvar     17: <body class="website"><div class="webpage" id="docs-kernel-non-exec">
                     18: <div id="top"><a href="#mainContent" id="skiplink" tabindex="1">Skip to main content.</a></div>
1.47      maya       19: <input id="hamburger" type="checkbox"><label class="menuicon" for="hamburger"><span></span><span></span><span></span></label><div id="navBar" role="navigation">
1.29      maya       20: <div id="centralHeader"><div id="logo">
1.48      maya       21: <a href="../../"><img id="projectLogo" alt="" height="120" src="../../images/NetBSD-smaller-tb.png"></a><a href="/"><div id="fundraiser">
1.46      maya       22: <br><div id="fundraiser-amount"><div id="fundraiser-raised"></div></div>
                     23: </div></a>
1.29      maya       24: </div></div>
1.6       dsieger    25: <span class="doNotDisplay">
                     26:          Navigation:
1.18      jym        27:        </span><ul>
                     28: <li>
                     29: <a href="../../">
1.49      maya       30:          Home</a><ul>
1.18      jym        31: <li><a href="../../changes/">
                     32:            Recent changes</a></li>
1.32      maya       33: <li><a href="//blog.NetBSD.org/">
1.18      jym        34:            NetBSD blog</a></li>
1.45      maya       35: <li><a href="../../gallery/presentations/">
                     36:            Presentations</a></li>
1.18      jym        37: </ul>
                     38: </li>
                     39: <li>
                     40: <a href="../../about/">
                     41:          About</a><ul>
1.37      maya       42: <li><a href="../../people/developers.html">
1.49      maya       43:            Developers</a></li>
1.18      jym        44: <li><a href="../../gallery/">
1.42      leot       45:            Gallery</a></li>
1.49      maya       46: <li><a href="//wiki.NetBSD.org/ports/">
                     47:            Ports</a></li>
1.54      nia        48: <li><a href="//www.pkgsrc.org/">
1.49      maya       49:            Packages</a></li>
1.18      jym        50: </ul>
                     51: </li>
                     52: <li>
                     53: <a href="../../docs/">
                     54:          Documentation</a><ul>
                     55: <li><a href="../../docs/misc/index.html">
                     56:            FAQ &amp; HOWTOs</a></li>
                     57: <li><a href="../../docs/guide/en/">
                     58:            The Guide</a></li>
1.51      nia        59: <li><a href="//man.NetBSD.org/">
1.18      jym        60:            Manual pages</a></li>
1.32      maya       61: <li><a href="//wiki.NetBSD.org/">
1.18      jym        62:            Wiki</a></li>
                     63: </ul>
                     64: </li>
                     65: <li>
                     66: <a href="../../support/">
                     67:          Support</a><ul>
1.50      leot       68: <li><a href="/community/">
1.49      maya       69:            Community</a></li>
1.50      leot       70: <li><a href="/mailinglists/">
                     71:            Mailing lists</a></li>
1.18      jym        72: <li><a href="../../support/send-pr.html">
1.49      maya       73:            Bug reports</a></li>
1.18      jym        74: <li><a href="../../support/security/">
                     75:            Security</a></li>
                     76: </ul>
                     77: </li>
                     78: <li>
                     79: <a href="../../developers/">
                     80:          Developers</a><ul>
1.73      leot       81: <li><a href="//cvsweb.NetBSD.org/">
1.49      maya       82:            CVSWeb</a></li>
1.32      maya       83: <li><a href="//nxr.NetBSD.org/">
1.18      jym        84:            Cross-reference</a></li>
1.32      maya       85: <li><a href="//releng.NetBSD.org/">
1.18      jym        86:            Release engineering</a></li>
1.32      maya       87: <li><a href="//wiki.NetBSD.org/projects/">
1.18      jym        88:            Projects list</a></li>
                     89: </ul>
                     90: </li>
                     91: </ul>
1.3       dsieger    92: </div>
1.39      maya       93: <div id="content"><div id="mainContent" class="fullWidth"><div class="rowOfBoxes">
1.3       dsieger    94: <h1>Non-executable stack and heap</h1>
1.69      andvar     95: <div class="sect1" id="content_top">
1.70      andvar     96: <div class="titlepage"></div>
1.1       dsieger    97: 
                     98: <p>
                     99: Starting with version 2.0, NetBSD supports non-executable mappings on
                    100: platforms where the hardware allows it. Process stack and heap mappings are
                    101: non-executable by default. This makes exploiting potential buffer overflows
                    102: harder. NetBSD supports PROT_EXEC permission via mmap() for all platforms
                    103: where the hardware differentiates execute access from data access, though
                    104: not necessarily with single-page granularity. When the hardware has a
                    105: larger granularity, the rule is that if any page in the larger unit is
                    106: executable, then the entire larger unit is executable, otherwise the entire
                    107: larger unit is not executable.
                    108: </p>
                    109: 
                    110: <p>
1.57      maya      111: No compile-time option is needed to enable this software support,
                    112: it's always available. 
                    113: </p>
                    114: 
                    115: <p>
1.58      maya      116: This support is also used on some kernel configurations for PaX mprotect (also
                    117: known as W^X), which forbids even a single page from being mapped both writable
1.76    ! martin    118: and executable. See <a href="//man.NetBSD.org/NetBSD-11.1/paxctl.8">paxctl(8)</a> for more information.
1.58      maya      119: </p>   
1.56      maya      120: 
1.69      andvar    121: <div class="sect2" id="supported-platforms">
                    122: <div class="titlepage"><h3 class="titlepage">Supported platforms</h3></div>
1.1       dsieger   123: 
                    124: 
                    125: <p>
                    126: Here is a list of support levels based on hardware
                    127: limitations. In this list "the stack" refers to the traditional UNIX
                    128: process stack, not pthreads stacks.
                    129: </p>
                    130: 
1.23      tron      131: <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1.16      spz       132: <li class="listitem">
1.56      maya      133: <span class="bold"><strong>aarch64, arm newer than ARMv6, amd64, sparc64, sparc (sun4m, sun4d), powerpc (ibm4xx), 
                    134: alpha, hppa, i386 with PAE (not the default):</strong></span>
1.1       dsieger   135: Full support, each page is independently executable or not.
                    136: </li>
1.16      spz       137: <li class="listitem">
1.14      snj       138: <span class="bold"><strong>powerpc (e.g., macppc):</strong></span>
1.1       dsieger   139: The hardware granularity is a segment (256MB) instead of a page.
                    140: By default, the segment containing the stack is not executable.
                    141: </li>
1.16      spz       142: <li class="listitem">
1.56      maya      143: <span class="bold"><strong>i386 by default (no PAE):</strong></span>
1.1       dsieger   144: The hardware support is pretty limited, so the granularity is very coarse.
                    145: The current software implementation in NetBSD is that there are only two
                    146: regions of the application address space which may be independently
                    147: executable or not: the stack and everything else.  By default,
                    148: the stack is not executable and everything else is executable
                    149: </li>
1.16      spz       150: <li class="listitem">
1.56      maya      151: <span class="bold"><strong>Everything else; arm older than ARMv6, m68k, mips, sh3, 
1.1       dsieger   152: sparc(sun, sun4c), vax:</strong></span>
                    153: No support, the hardware does not differentiate execute vs. data accesses,
                    154: so anything readable to a process as data is executable by the process
                    155: as code.
                    156: </li>
                    157: </ul></div>
                    158: 
                    159: </div>
                    160: </div>
1.3       dsieger   161: </div></div></div>
                    162: <div class="navfoot"></div>
1.69      andvar    163: <div id="footer"><div id="footerContent">
                    164: <span class="footfeed"><a href="//www.NetBSD.org/cgi-bin/feedback.cgi">
1.3       dsieger   165:          Contact</a> |
1.9       kano      166:       </span><span class="footcopy"><a href="../../about/disclaimer.html">
1.3       dsieger   167:       Disclaimer</a> |
                    168: 
1.71      leot      169:       <span class="copyright">Copyright © 1994-2026 The NetBSD Foundation, Inc. </span>ALL RIGHTS RESERVED.<br>NetBSD<sup>®</sup> is a registered trademark of The NetBSD
1.69      andvar    170:        Foundation, Inc.</span>
                    171: </div></div>
1.1       dsieger   172: </div></body>
                    173: </html>

CVSweb <webmaster@jp.NetBSD.org>