From: Wolfgang Denk Date: Fri, 05 Apr 2013 13:17:10 +0200 Subject: [U-Boot] env: fix potential stack overflow in environment functions In-Reply-To: <20130403153014.GF7035@bill-the-cat> References: <1363987581-28050-1-git-send-email-robherring2@gmail.com> <20130403153014.GF7035@bill-the-cat> Message-ID: <20130405111710.8C04C200589@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Tom Rini, In message <20130403153014.GF7035@bill-the-cat> you wrote: > > On Fri, Mar 22, 2013 at 11:26:21AM -0000, Rob Herring wrote: > > > From: Rob Herring > > > > Most of the various environment functions create CONFIG_ENV_SIZE buffers on > > the stack. At least on ARM and PPC which have 4KB stacks, this can overflow > > the stack if we have large environment sizes. So move all the buffers off > > the stack to static buffers. > > > > Signed-off-by: Rob Herring > > Applied to u-boot/master, thanks! I'm unhappy about this. The patch makes no sense to me, and in addition it causes build warnings for some boards (PPC: debris, kvme080): env_nvram.c: In function 'env_init': env_nvram.c:124:16: warning: pointer targets in initialization differ in signedness [-Wpointer-sign] I tried to explain this before, but eventually you missed my remarks, so here they go again: * The functiuons we are talking about run after relocation, i. e. when we have a full standard C runtime environment. In this situation we can assume to have virtually unlimited stack space available - actually limited only by the RAM size. * Moving the buffers from the stack into BSS is bad, as this way we permanently lose the space for these buffers, nut we need them only for a very short time, so we are wasting lots of memory. * If some board have for some reasons unreasonable small stack sizes, these need to be fixed. Rob refers to LMB stack space in his previous message - if there are indeed such small stack sizes used there, this is a problem that needs to be fixed elsewhere, but NOT by adapting all the rest of the U-Boot code to an artifical small stack. I hereby request to revert that commit. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de How long does it take a DEC field service engineer to change a lightbulb? It depends on how many bad ones he brought with him.