From patchwork Wed May 12 06:33:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 43383 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9D9673857812; Wed, 12 May 2021 06:34:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D9673857812 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620801261; bh=rkbB/Ek5YBjngXgX+NpcTP8+neDpORt91lIh7w1Q8Us=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=gDGtqveb3IItMHjHIWsv61f/MlM3VmnEpN1O61FxmdtrrFmAdixzdb2yWaLR1eY/i HuUh0cfZEMlyU23F+WZdG4SM9Vj4RufDkMpYMACULQP7c28nzZQDXGaXiSeXYeRVkt 42/B+sMAZyjedBgMxwwYGVxNMYmf4ZTadGiMnMsI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id F1ABA385780B for ; Wed, 12 May 2021 06:34:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F1ABA385780B Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14C6X615189889 for ; Wed, 12 May 2021 02:34:18 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 38g83n2jpm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 May 2021 02:34:18 -0400 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 14C6YI9G001525 for ; Wed, 12 May 2021 02:34:18 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 38g83n2jp2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 May 2021 02:34:18 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 14C6XTXY012992; Wed, 12 May 2021 06:34:16 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma05fra.de.ibm.com with ESMTP id 38dj98h3cd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 May 2021 06:34:16 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14C6YDvp33948028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 May 2021 06:34:13 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1112E42045; Wed, 12 May 2021 06:34:13 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB85D42042; Wed, 12 May 2021 06:34:12 +0000 (GMT) Received: from t35lp56.lnxne.boe (unknown [9.152.108.100]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 12 May 2021 06:34:12 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [PATCH] Fix stringop-overflow warning in bug-regex19.c. Date: Wed, 12 May 2021 08:33:45 +0200 Message-Id: <20210512063345.2269779-1-stli@linux.ibm.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: z85PoB1z2awBfR4X8hwpmJEs17hISzrD X-Proofpoint-GUID: he0xbska99hkSXWEw8FDU4suowpKLCQp X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-05-12_03:2021-05-11, 2021-05-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 suspectscore=0 clxscore=1011 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120047 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, 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-Patchwork-Original-From: Stefan Liebler via Libc-alpha From: Stefan Liebler Reply-To: Stefan Liebler Cc: Stefan Liebler , msebor@redhat.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Starting with commit 26492c0a14966c32c43cd6ca1d0dca5e62c6cfef "Annotate additional APIs with GCC attribute access.", gcc emits this warning on s390x: In function ‘do_one_test’, inlined from ‘do_mb_tests’ at bug-regex19.c:385:11: bug-regex19.c:271:9: error: ‘re_search’ specified size 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] 271 | res = re_search (®buf, test->string, strlen (test->string), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 272 | test->start, strlen (test->string) - test->start, NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../include/regex.h:2, from bug-regex19.c:22: bug-regex19.c: In function ‘do_mb_tests’: ../posix/regex.h:554:17: note: in a call to function ‘re_search’ declared with attribute ‘read_only (2, 3)’ 554 | extern regoff_t re_search (struct re_pattern_buffer *__buffer, | ^~~~~~~~~ ... The function do_one_test is inlined into do_mb_tests on s390x (at least with gcc 10). If do_one_test is marked with __attribute__ ((noinline)), there are no warnings on s390x. If do_one_test is marked with __attribute__ ((always_inline)), there are the same warnings on x86_64. test->string points to a variable length array on stack of do_mb_tests and the content is generated based on the passed test struct. --- posix/bug-regex19.c | 1 + 1 file changed, 1 insertion(+) diff --git a/posix/bug-regex19.c b/posix/bug-regex19.c index 9bbffb17e3..fcae533762 100644 --- a/posix/bug-regex19.c +++ b/posix/bug-regex19.c @@ -251,6 +251,7 @@ static struct test_s }; int +__attribute__ ((noinline)) do_one_test (const struct test_s *test, const char *fail) { int res;