public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: "zhuyan (M)" <zhuyan34@huawei.com>
Cc: "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>
Subject: Re: [PATCH v2] memcpy: use bhs/bls instead of bge/blt [BZ #25620]
Date: Tue, 14 Apr 2020 22:26:56 +0000	[thread overview]
Message-ID: <alpine.DEB.2.21.2004142220180.15813@digraph.polyomino.org.uk> (raw)
In-Reply-To: <95923e664fc9426c9c121efeaa69268c@huawei.com>

On Mon, 13 Apr 2020, zhuyan (M) wrote:

> In ARMv7, the memcpy() implementation allows for program execution to 
> continue in scenarios where a segmentation fault or crash should have 
> occurred. The dangers occur in that subsequent execution and iterations 
> of this code will be executed with this corrupted data.
> 
> Such as, we use 'memcpy' copy 0x80000000 byte to buffer(The buffer size 
> is 100 bytes), it didn't crash.

This patch includes an architecture-specific test, specific to memcpy.  
My understanding of Wilco's request in bug 25620 was for an 
architecture-independent test or tests, covering all string functions with 
such large arguments, so we can ensure we're consistent across 
architectures.  To quote comment 16, "Still we should have a new test that 
checks every string function which has a size_t input, using a positive 
test if the huge mmap succeeds and a negative test checking for a crash. 
That should flush out any other cases across all targets.".

Even if you just add a test of memcpy and leave testing other string 
functions for later, I think it ought to be an architecture-independent 
test.

Note 1: we can't effectively test for this issue on 64-bit systems, 
because a 2^63 byte allocation isn't generally practical (the virtual 
address space may not actually support using all 64 bits) and looping over 
the whole of such an allocation would take an infeasible amount of time.

Note 2: to avoid problems with allocation failure when writing to the 
whole of such a large allocation on a 32-bit system that doesn't actually 
have 2 GB of memory available, see support/blob_repeat.c that provides 
helper functions, for use in testcases, that repeat mappings of a smaller 
region of memory over a larger part of the address space.

> +#define TEST_FUNCTION do_test ()
> +#include "../test-skeleton.c"

test-skeleton.c is the older way of writing tests.  New tests should use 
support/test-driver.c, see support/README-testing.c.

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2020-04-14 22:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-13 14:16 zhuyan (M)
2020-04-14 22:26 ` Joseph Myers [this message]
2020-04-21 14:36   ` Florian Weimer
2020-04-21 21:27     ` Joseph Myers
2020-04-28 21:14       ` Florian Weimer
2020-04-30 20:33       ` Florian Weimer
2020-04-30 20:22 ` Florian Weimer
2020-04-15 11:59 Wilco Dijkstra
2020-05-01 12:58 Wilco Dijkstra
2020-05-06 12:40 zhuyan (M)

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=alpine.DEB.2.21.2004142220180.15813@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=zhuyan34@huawei.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).