[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191001135649.GH22609@kadam>
Date: Tue, 1 Oct 2019 16:56:49 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Denis Efremov <efremov@...ux.com>
Cc: David Laight <David.Laight@...LAB.COM>,
"devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
Jes Sorensen <jes.sorensen@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"stable@...r.kernel.org" <stable@...r.kernel.org>,
Hans de Goede <hdegoede@...hat.com>,
Bastien Nocera <hadess@...ess.net>,
Dmitry Vyukov <dvyukov@...gle.com>,
Larry Finger <Larry.Finger@...inger.net>
Subject: Re: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls
On Mon, Sep 30, 2019 at 05:25:43PM +0300, Denis Efremov wrote:
> On 9/30/19 4:18 PM, David Laight wrote:
> > From: Denis Efremov
> >> Sent: 30 September 2019 12:02
> >> memcpy() in phy_ConfigBBWithParaFile() and PHY_ConfigRFWithParaFile() is
> >> called with "src == NULL && len == 0". This is an undefined behavior.
> >
> > I'm pretty certain it is well defined (to do nothing).
>
> Well, technically you are right. However, UBSAN warns about passing NULL
> to memcpy and from the formal point of view this is an undefined behavior [1].
> There were a discussion [2] about interesting implication of assuming that
> memcpy with 0 size and NULL pointer is fine. This could result in that compiler
> assume that pointer is not NULL.
That's true for glibc memcpy() but not for the kernel memcpy(). In the
kernel there are lots of places which do a zero size memcpy().
The glibc attitude is "the standard allows us to put knives here" so
let's put knives everywhere in the path. And the GCC attitude is let's
silently remove NULL checks instead of just printing a warning that the
NULL check isn't required... It could really make someone despondent.
regards,
dan carpenter
Powered by blists - more mailing lists