This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] MIPS: Prevent buffer overrun in uninitialised variable fix
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Matthew Fortune <Matthew dot Fortune at imgtec dot com>
- Cc: "Jeff Law <law at redhat dot com> (law at redhat dot com)" <law at redhat dot com>, "'gcc-patches at gcc dot gnu dot org' (gcc-patches at gcc dot gnu dot org)" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 20 Apr 2017 14:55:40 +0200
- Subject: Re: [PATCH] MIPS: Prevent buffer overrun in uninitialised variable fix
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 41BDD75EAE
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 41BDD75EAE
- References: <6D39441BF12EF246A7ABCE6654B0235380C0761B@HHMAIL01.hh.imgtec.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Apr 20, 2017 at 12:49:49PM +0000, Matthew Fortune wrote:
> Hi Jeff,
>
> I missed a load of test failures while on vacation and just noticed
> that the fix you did for a potentially uninitialized variable warning
> is overwriting the stack and breaking MSA in MIPS.
>
> I guess you may have intended to set the length appropriately and
> only zero the elements that would not be set in the loop:
>
> memset (&orig_perm[nelt], 0, MAX_VECT_LEN - nelt);
>
> but I switched it to just zero initialise the whole array for
> simplicity in the patch below.
>
> I thought I'd check with you before committing. Obviously I'd like to
> apply this to GCC 7 branch as well.
As it is just 16, it is not a big deal either way, memsetting everything
might be even faster. If it would be bigger than that, the MAX_VECT_LEN -
nelt case would be better.
> gcc/
> * config/mips/mips.c (mips_expand_vec_perm_const): Re-fix
> uninitialized variable warning to avoid buffer overrun.
Ok, thanks, even for GCC 7 branch.
Jakub