| Deutsch English Français Italiano |
|
<vsc058$20pih$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: BGB <cr88192@gmail.com> Newsgroups: comp.arch Subject: Re: Constant Stack Canaries Date: Sun, 30 Mar 2025 12:47:59 -0500 Organization: A noiseless patient Spider Lines: 34 Message-ID: <vsc058$20pih$1@dont-email.me> References: <vsbcnl$1d4m5$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 30 Mar 2025 19:48:25 +0200 (CEST) Injection-Info: dont-email.me; posting-host="3c56c10740bf5254f35010eaf7ea1581"; logging-data="2123345"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ejP9B0S1jsbDICaDPekTuu3Vgn9uXw+Q=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:fEBfr1JVLNekjzErYNS7loDPNNk= Content-Language: en-US In-Reply-To: <vsbcnl$1d4m5$1@dont-email.me> Bytes: 2472 On 3/30/2025 7:16 AM, Robert Finch wrote: > Just got to thinking about stack canaries. I was going to have a special > purpose register holding the canary value for testing while the program > was running. But I just realized today that it may not be needed. Canary > values could be handled by the program loader as constants, eliminating > the need for a register. Since the value is not changing while the > program is running, it could easily be a constant. This may require a > fixup record handled by the assembler / linker to indicate to the loader > to place a canary value. > > Prolog code would just store an immediate to the stack. On return a TRAP > instruction could check for the immediate value and trap if not present. > But the process seems to require assembler / linker support. > They are mostly just a normal compiler feature IME: Prolog stores the value; Epilog loads it and verifies that the value is intact. Using a magic number generated by the compiler. Nothing fancy needed in the assemble or link stages. In my case, canary behavior is one of: Use them in functions with arrays or similar (default); Use them everywhere (optional); Disable them entirely (also optional). In my case, it is only checking 16-bit magic numbers, but mostly because a 16-bit constant is cheaper to load into a register in this case (single 32-bit instruction, vs a larger encoding needed for larger values). ....