From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 700083857028 for ; Thu, 20 Aug 2020 22:55:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 700083857028 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 07KMda9m038624 for ; Thu, 20 Aug 2020 18:55:29 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 3317abkyjn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Aug 2020 18:55:29 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 07KMsfE8022101 for ; Thu, 20 Aug 2020 22:55:28 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma05wdc.us.ibm.com with ESMTP id 3304th7mhe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Aug 2020 22:55:28 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 07KMtOcx30933690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Aug 2020 22:55:24 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1EFFB6E04E; Thu, 20 Aug 2020 22:55:27 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C96D56E052; Thu, 20 Aug 2020 22:55:26 +0000 (GMT) Received: from [9.163.50.10] (unknown [9.163.50.10]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 20 Aug 2020 22:55:26 +0000 (GMT) Subject: Re: [PATCH v8] string: Adds tests for test-strncasecmp and test-strncpy To: Raphael Moreira Zinsly , libc-alpha@sourceware.org Cc: pc@us.ibm.com References: <20200729182740.18447-1-rzinsly@linux.ibm.com> From: Paul E Murphy Message-ID: <25616e5a-59ae-aa03-b452-a870c097941d@linux.ibm.com> Date: Thu, 20 Aug 2020 17:55:26 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200729182740.18447-1-rzinsly@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-08-20_07:2020-08-19, 2020-08-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008200183 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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: Thu, 20 Aug 2020 22:55:31 -0000 On 7/29/20 1:27 PM, Raphael Moreira Zinsly via Libc-alpha wrote: > Changes since v7: > - Fixed comments to make them clearer. > > --- >8 --- > > Adds tests to check if strings placed at page bondaries are Minor grammar/spelling nit: "Add tests" and "page boundaries". Similarly, commit title might be improved by rewording to something like: "string: test strncasecmp and strncpy near page boundaries" > handled correctly by strncasecmp and strncpy similar to tests > for strncmp and strnlen. > --- > string/test-strncasecmp.c | 43 +++++++++++++++++++++++++++++++++++++++ > string/test-strncpy.c | 35 +++++++++++++++++++++++++++++++ > 2 files changed, 78 insertions(+) > > diff --git a/string/test-strncasecmp.c b/string/test-strncasecmp.c > index 6a9c27beae..502222ed1d 100644 > --- a/string/test-strncasecmp.c > +++ b/string/test-strncasecmp.c > @@ -137,6 +137,48 @@ do_test (size_t align1, size_t align2, size_t n, size_t len, int max_char, > do_one_test (impl, s1, s2, n, exp_result); > } > > +static void > +do_page_tests (void) This test looks OK. > static void > do_random_tests (void) > { > @@ -334,6 +376,7 @@ test_locale (const char *locale) > } > > do_random_tests (); > + do_page_tests (); > } > > int > diff --git a/string/test-strncpy.c b/string/test-strncpy.c > index c978753ad8..2919bbe181 100644 > --- a/string/test-strncpy.c > +++ b/string/test-strncpy.c > @@ -155,6 +155,40 @@ do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char) > do_one_test (impl, s2, s1, len, n); > } > > +static void > +do_page_tests (void) > +{ > + CHAR *s1, *s2; > + const size_t maxoffset = 64; > + > + /* Put s1 at the maxoffset from the edge of buf1's last page. */ > + s1 = (CHAR *) buf1 + BUF1PAGES * page_size / sizeof(CHAR) - maxoffset; > + /* s2 needs room to put a string with size of maxoffset + 1 at s2 + > + (maxoffset - 1). */ Does this only test the interesting page boundary case of s2 when off2 == (maxoffset-1)? Should the n of do_one_test instead be maxoffset + (maxoffset - off2) to ensure each iteration straddles the guard page of s1 and s2? > + s2 = (CHAR *) buf2 + page_size / sizeof(CHAR) - maxoffset * 2; > + > + MEMSET (s1, 'a', maxoffset - 1); > + s1[maxoffset - 1] = '\0'; > + > + /* Both strings are bounded to a page with read/write access and the next > + page is protected with PROT_NONE (meaning that any access outside of the > + page regions will trigger an invalid memory access). > + > + The loop copies the string s1 for all possible offsets up to maxoffset > + for both inputs with a size larger than s1 (so memory access outside the > + expected memory regions might trigger invalid access). */ > + > + for (size_t off1 = 0; off1 < maxoffset; off1++) > + { > + for (size_t off2 = 0; off2 < maxoffset; off2++) > + { > + FOR_EACH_IMPL (impl, 0) > + do_one_test (impl, (s2 + off2), (s1 + off1), maxoffset - off1 - 1, > + maxoffset + 1); > + } > + } > +}