mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Denis Efremov <efremov@linux.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: David Laight <David.Laight@ACULAB.COM>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	Jes Sorensen <jes.sorensen@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Bastien Nocera <hadess@hadess.net>,
	Dmitry Vyukov <dvyukov@google.com>,
	Larry Finger <Larry.Finger@lwfinger.net>
Subject: Re: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls
Date: Tue, 1 Oct 2019 23:15:39 +0300	[thread overview]
Message-ID: <6ea8c7b8-2b60-9baf-2374-3a3dac2d05b4@linux.com> (raw)
In-Reply-To: <20191001185730.GM29696@kadam>

On 01.10.2019 21:58, Dan Carpenter wrote:
> On Tue, Oct 01, 2019 at 06:13:21PM +0300, Denis Efremov wrote:
>> Just found an official documentation to this issue:
>> https://gcc.gnu.org/gcc-4.9/porting_to.html
>> "Null pointer checks may be optimized away more aggressively
>> ...
>> The pointers passed to memmove (and similar functions in <string.h>) must be non-null
>> even when nbytes==0, so GCC can use that information to remove the check after the
>> memmove call. Calling copy(p, NULL, 0) can therefore deference a null pointer and crash."
>>
> 
> Correct.  In glibc those functions are annotated as non-NULL.
> 
> extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
>                      size_t __n) __THROW __nonnull ((1, 2));
> 
> We aren't going to do that in the kernel.  A second difference is that
> in the kernel we use -fno-delete-null-pointer-checks so it doesn't
> delete the NULL checks.
> 

Thank you for the clarification. This is really helpful.

Best regards,
Denis

  reply	other threads:[~2019-10-01 20:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30 11:01 Denis Efremov
2019-09-30 13:18 ` David Laight
2019-09-30 14:25   ` Denis Efremov
2019-10-01 13:56     ` Dan Carpenter
2019-10-01 14:36       ` David Laight
2019-10-01 15:13         ` Denis Efremov
2019-10-01 16:00           ` David Laight
2019-10-01 18:58           ` Dan Carpenter
2019-10-01 20:15             ` Denis Efremov [this message]
2019-10-09 14:38             ` Dan Carpenter
2019-09-30 15:40   ` Denis Efremov
2019-10-09  9:35 ` Hans de Goede
2019-10-09 10:43   ` Denis Efremov

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=6ea8c7b8-2b60-9baf-2374-3a3dac2d05b4@linux.com \
    --to=efremov@linux.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=Larry.Finger@lwfinger.net \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=dvyukov@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hadess@hadess.net \
    --cc=hdegoede@redhat.com \
    --cc=jes.sorensen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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

Powered by JetHome