public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'Herbert Xu'" <herbert@gondor.apana.org.au>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: "Anders Roxell" <anders.roxell@linaro.org>,
	"Kees Cook" <keescook@chromium.org>,
	"Horia Geantă" <horia.geanta@nxp.com>,
	"Gaurav Jain" <gaurav.jain@nxp.com>,
	"Pankaj Gupta" <pankaj.gupta@nxp.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-hardening@vger.kernel.org"
	<linux-hardening@vger.kernel.org>,
	"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	"kernel test robot" <lkp@intel.com>
Subject: RE: [PATCH] crypto: caam - Avoid GCC memset bug warning
Date: Sat, 31 Dec 2022 16:44:45 +0000	[thread overview]
Message-ID: <f3e9add2210a46af99cf0fc79121c7db@AcuMS.aculab.com> (raw)
In-Reply-To: <Y6zx9H7pZZ6VTzUd@gondor.apana.org.au>

From: Herbert Xu
> Sent: 29 December 2022 01:49
> 
> On Wed, Dec 28, 2022 at 12:30:35PM +0100, Uwe Kleine-König wrote:
> >
> > > -	if (len) /* avoid sparse warning: memcpy with byte count of 0 */
> > > +	/* Avoid gcc warning: memcpy with data == NULL */
> > > +	if (!IS_ENABLED(CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG) || data)
> >
> > I just tried: For me a plain
> >
> > 	if (data)
> >
> > is also enough to make both gcc and sparse happy.
> 
> Of course it is.  The point of the extra condition is to remove
> the unnecessary check on data unless we are in debugging mode
> (as it is only needed in debugging mode to work around the buggy
> compiler).

IIRC the 'problematic' case is one where 'len' and 'data'
are actually compile-time zeros - in which case you don't
want to call memcpy() at all.
In all other cases I think there is something to copy so you
don't really want the check (or the one in memcpy() will do).

Whether (builtin_constant_p(data) && !data) is good enough is
another matter.
It might need the (sizeof *(1 ? (void *)(data) : (int *)0) == 1)
test.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

      reply	other threads:[~2022-12-31 16:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221222162513.4021928-1-u.kleine-koenig@pengutronix.de>
     [not found] ` <Y6VK4IJkHiawAbJz@gondor.apana.org.au>
     [not found]   ` <20221223174719.4n6pmwio4zycj2qm@pengutronix.de>
2022-12-28  8:46     ` [PATCH] crypto: caam - Avoid GCC memset bug warning Herbert Xu
2022-12-28  9:39       ` Uwe Kleine-König
2022-12-28 11:03         ` [v2 PATCH] " Herbert Xu
2022-12-28 11:30       ` [PATCH] " Uwe Kleine-König
2022-12-29  1:48         ` Herbert Xu
2022-12-31 16:44           ` David Laight [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3e9add2210a46af99cf0fc79121c7db@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=anders.roxell@linaro.org \
    --cc=davem@davemloft.net \
    --cc=gaurav.jain@nxp.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=horia.geanta@nxp.com \
    --cc=keescook@chromium.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=pankaj.gupta@nxp.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox