From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Sadovsky Date: Mon, 11 Jan 2021 01:40:13 +0300 Subject: [PATCH] Add support for stack-protector In-Reply-To: <20210110153900.19429-1-joel.peshkin@broadcom.com> References: <20210110153900.19429-1-joel.peshkin@broadcom.com> Message-ID: <49a0fb9e-e2a4-c26f-e192-818e16d60e30@googlemail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, > + > +unsigned long __stack_chk_guard = 0xfeedf00ddeadbeef; sizeof(unsigned long) isn't always 8, even gcc issues a warning when it's invoked with proper options (e.g. 32-bit build): > warning: conversion from ?long long unsigned int? to ?long unsigned int? changes value from ?18369602397475290863? to ?3735928559? [-Woverflow] Maybe there's some better way to initialize this variable. E.g. with #if ? #else ? #endif or using some initialization function that is invoked early. I should also mention that a fixed canary value doesn't actually bring proper protection against exploits, thus run-time initialization with a random value is usually preferred. I'm not sure whether it's important at all in bootloader code, I just wanted to be sure that it isn't unnoticed. Cheers, Alex.