lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 7 Jun 2018 10:06:37 +0200
From:   Johan Hovold <johan@...nel.org>
To:     Viresh Kumar <viresh.kumar@...aro.org>
Cc:     Steven Rostedt <rostedt@...dmis.org>, gregkh@...uxfoundation.org,
        alex.elder@...aro.org, Johan Hovold <johan@...nel.org>,
        kbuild test robot <lkp@...el.com>,
        linux-arch@...r.kernel.org, michal.lkml@...kovi.net,
        linux-kernel@...r.kernel.org, arnd@...db.de,
        yamada.masahiro@...ionext.com, lgirdwood@...il.com,
        broonie@...nel.org, rdunlap@...radead.org, x86@...nel.org,
        linux@...linux.org.uk, changbin.du@...el.com,
        linux-sparse@...r.kernel.org, mingo@...hat.com, kbuild-all@...org,
        akpm@...ux-foundation.org, changbin.du@...il.com,
        tglx@...utronix.de, linux-kbuild@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v5 2/4] kernel hacking: new config NO_AUTO_INLINE to
 disable compiler auto-inline optimizations

On Thu, Jun 07, 2018 at 09:47:18AM +0530, Viresh Kumar wrote:

> On 06-06-18, 14:26, Steven Rostedt wrote:
> > On Wed, 6 Jun 2018 16:26:00 +0200
> > Johan Hovold <johan@...nel.org> wrote:
> > 
> > > Looks like the greybus code above is working as intended by checking for
> > > unterminated string after the strncpy, even if this does now triggers
> > > the truncation warning.
> 
> So why exactly are we generating a warning here ? Is it because it is possible
> that the first n bytes of src may not have the null terminating byte and the
> dest may not be null terminated eventually ?

Yes, new warning in GCC 8:

	https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Warning-Options.html#index-Wstringop-truncation

> Maybe I should just use memcpy here then ?

No, as you note below, you use strncpy to clear the rest of the buffer.

> But AFAIR, I used strncpy() specifically because it also sets all the remaining
> bytes after the null terminating byte with the null terminating byte. And so it
> is pretty easy for me to check if the final string is null terminated by
> checking [max - 1] byte against '\0', which the code is doing right now.
> 
> I am not sure what would the best way to get around this incorrect-warning.

It seems gcc just isn't smart enough in this case (where you check for
overflow and never use a non-terminated string), but it is supposed to
detect when the string is unconditionally terminated. So perhaps just
adding a redundant buf[size-1] = '\0' before returning in the error path
or after the error path would shut it up. But that's a bit of a long
shot, I admit.

Probably best to leave things as they are, and let the gcc folks find a
way to handle such false positives.

Thanks,
Johan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ