From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 8062B385BF83 for ; Tue, 14 Apr 2020 22:27:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8062B385BF83 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=joseph_myers@mentor.com IronPort-SDR: s83SRDtyE7MjEywI9QPby/Mr7up0mLf2Lf1zbkMqxyoGudyKgJRPrWi444vP+lBNwV+mjx8UVO /D9Af53ryIRU5v08zP8SBqPakWh3MSQQ2f+UKFY0bi450zI8B3W6wUMQ5atrGxvkGe/4JXNbHH TSB/ojMsEKLmg+tzTulSKlMlEaIK/lFVBACUtR0enYm2lbel/VpeMqP01HaOtqcHdkvjtL/mFc oWIB9TeBSEf/JYAiom6Iu/DBuykYHuReMI+pJtveVxhCX0XJ4RC1sBD0XX86ZU4mcT37e1tO6l rUk= X-IronPort-AV: E=Sophos;i="5.72,384,1580803200"; d="scan'208";a="47670583" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 14 Apr 2020 14:27:01 -0800 IronPort-SDR: dWFEvgr6flr+A5xbvVe/bFibolkCoKfZQLoE+CWAMPvNDZZlVxAv/JmBtNep3m2VL9Gp86XBYt fI8xsHiCDo2aQHG0VyCXzwlKmf6olb/PJRE2xswfcFfKV4945AdaywRrBMZZjFnCjpisiwzNL7 casIyjX/DYIuxdwpJ78uBGVenulrsiBZcTuW7of/lm7q2twheu33MdC0obYgjExixNLjUImgvk 7OhC7aiD2YNpr2XHhVnmVqy/up0xOArsETW1lwOS7s3grGp4TYYWf86/jIsaleJSw7ywCFAAzH tJU= Date: Tue, 14 Apr 2020 22:26:56 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: "zhuyan (M)" CC: "libc-alpha@sourceware.org" Subject: Re: [PATCH v2] memcpy: use bhs/bls instead of bge/blt [BZ #25620] In-Reply-To: <95923e664fc9426c9c121efeaa69268c@huawei.com> Message-ID: References: <95923e664fc9426c9c121efeaa69268c@huawei.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Apr 2020 22:27:03 -0000 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