Message ID | 20230412060845.981953-1-guojiufu@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> 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 ED7C23858404 for <patchwork@sourceware.org>; Wed, 12 Apr 2023 06:09:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED7C23858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681279763; bh=vDr8l1M77CNUw5VKhZ0XSqvZLkNnNjcFGq+1nvbHfD8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=lOU5rF2pmQGXBAsTvYnKp6I9lU1f8ZoQh5UACKsqyGHiYqBONTHjRaF3bSpHFPzEB s5495sEtbcE+h6JBug+PmSvuvHLuCKej1D2/igq59XKEmPNm6jEV18X39YHXKEFUts RMGi0aZgfuvdTyUyuKp+HSuiWeBWu5z1Mm2S6NIk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 4F6953858D28; Wed, 12 Apr 2023 06:08:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F6953858D28 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33C4EBrD024292; Wed, 12 Apr 2023 06:08:53 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pwneeu75c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Apr 2023 06:08:53 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33C4HVem007404; Wed, 12 Apr 2023 06:08:53 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pwneeu74m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Apr 2023 06:08:52 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 33C0kmv5028714; Wed, 12 Apr 2023 06:08:51 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3pu0m2257x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Apr 2023 06:08:50 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 33C68luk22151786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Apr 2023 06:08:47 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D7D620049; Wed, 12 Apr 2023 06:08:47 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 408AB20040; Wed, 12 Apr 2023 06:08:46 +0000 (GMT) Received: from ltcden2-lp1.aus.stglabs.ibm.com (unknown [9.3.90.43]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 12 Apr 2023 06:08:46 +0000 (GMT) To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, guojiufu@linux.ibm.com, meissner@linux.ibm.com Subject: [PATCH] testsuite: filter out warning noise for CWE-1341 test Date: Wed, 12 Apr 2023 14:08:45 +0800 Message-Id: <20230412060845.981953-1-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Pueqtt81NO_Yy7fCT-wV8gtsV9PHz5FX X-Proofpoint-ORIG-GUID: AXO-JPTmEHDwzBasPuh_k_dsMpkTEmeU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-12_01,2023-04-11_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304120054 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jiufu Guo via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jiufu Guo <guojiufu@linux.ibm.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
testsuite: filter out warning noise for CWE-1341 test
|
|
Commit Message
Jiufu Guo
April 12, 2023, 6:08 a.m. UTC
Hi, The case file-CWE-1341-example.c checkes [CWE-1341](`double-fclose`). While on some systems, besides [CWE-1341], a message of [CWE-415] is also reported. On those systems, attribute `malloc` may be attached on fopen: ``` # 258 "/usr/include/stdio.h" 3 4 extern FILE *fopen (const char *__restrict __filename, const char *__restrict __modes) __attribute__ ((__malloc__)) __attribute__ ((__malloc__ (fclose, 1))) ; or say: __attribute_malloc__ __attr_dealloc_fclose __wur; ``` It would be ok to suppress other message except CWE-1341 for this case. This patch add -Wno-analyzer-double-free to make this case pass on those systems. Tested on ppc64 both BE and LE. Is this ok for trunk? BR, Jeff (Jiufu) gcc/testsuite/ChangeLog: PR target/108722 * gcc.dg/analyzer/file-CWE-1341-example.c: Update. --- gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c | 3 +++ 1 file changed, 3 insertions(+)
Comments
Add more reviewers. :) Jiufu Guo <guojiufu@linux.ibm.com> writes: > Hi, > > The case file-CWE-1341-example.c checkes [CWE-1341](`double-fclose`). > While on some systems, besides [CWE-1341], a message of [CWE-415] is > also reported. On those systems, attribute `malloc` may be attached on > fopen: > ``` > # 258 "/usr/include/stdio.h" 3 4 > extern FILE *fopen (const char *__restrict __filename, > const char *__restrict __modes) > __attribute__ ((__malloc__)) __attribute__ ((__malloc__ (fclose, 1))) ; > > or say: __attribute_malloc__ __attr_dealloc_fclose __wur; > ``` > > It would be ok to suppress other message except CWE-1341 for this case. > This patch add -Wno-analyzer-double-free to make this case pass on > those systems. > > Tested on ppc64 both BE and LE. > Is this ok for trunk? > > BR, > Jeff (Jiufu) > > gcc/testsuite/ChangeLog: > > PR target/108722 > * gcc.dg/analyzer/file-CWE-1341-example.c: Update. > > --- > gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c b/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c > index 2add3cb109b..830cb0376ea 100644 > --- a/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c > +++ b/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c > @@ -19,6 +19,9 @@ > > IN NO EVENT SHALL THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE MITRE CORPORATION, ITS BOARD OF TRUSTEES, OFFICERS, AGENTS, AND EMPLOYEES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE INFORMATION OR THE USE OR OTHER DEALINGS IN THE CWE. */ > > +/* This case checks double-fclose only, suppress other warning. */ > +/* { dg-additional-options -Wno-analyzer-double-free } */ > + > #include <stdio.h> > #include <stdlib.h> > #include <string.h>
On Thu, 13 Apr 2023, Jiufu Guo wrote: > > Add more reviewers. :) > > Jiufu Guo <guojiufu@linux.ibm.com> writes: > > > Hi, > > > > The case file-CWE-1341-example.c checkes [CWE-1341](`double-fclose`). > > While on some systems, besides [CWE-1341], a message of [CWE-415] is > > also reported. On those systems, attribute `malloc` may be attached on > > fopen: > > ``` > > # 258 "/usr/include/stdio.h" 3 4 > > extern FILE *fopen (const char *__restrict __filename, > > const char *__restrict __modes) > > __attribute__ ((__malloc__)) __attribute__ ((__malloc__ (fclose, 1))) ; Ouch. I think this should be fixed in the analyzer, "stripping" malloc tracking from fopen/fclose since it does this manually. I've adjusted the bug accordingly. The workaround in the testsuite is OK for trunk. Thanks, Richard. > > or say: __attribute_malloc__ __attr_dealloc_fclose __wur; > > ``` > > > > It would be ok to suppress other message except CWE-1341 for this case. > > This patch add -Wno-analyzer-double-free to make this case pass on > > those systems. > > > > Tested on ppc64 both BE and LE. > > Is this ok for trunk? > > > > BR, > > Jeff (Jiufu) > > > > gcc/testsuite/ChangeLog: > > > > PR target/108722 > > * gcc.dg/analyzer/file-CWE-1341-example.c: Update. > > > > --- > > gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c b/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c > > index 2add3cb109b..830cb0376ea 100644 > > --- a/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c > > +++ b/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c > > @@ -19,6 +19,9 @@ > > > > IN NO EVENT SHALL THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE MITRE CORPORATION, ITS BOARD OF TRUSTEES, OFFICERS, AGENTS, AND EMPLOYEES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE INFORMATION OR THE USE OR OTHER DEALINGS IN THE CWE. */ > > > > +/* This case checks double-fclose only, suppress other warning. */ > > +/* { dg-additional-options -Wno-analyzer-double-free } */ > > + > > #include <stdio.h> > > #include <stdlib.h> > > #include <string.h> >
On Thu, Apr 13, 2023 at 07:39:01AM +0000, Richard Biener wrote: > On Thu, 13 Apr 2023, Jiufu Guo wrote: > I think this should be fixed in the analyzer, "stripping" malloc > tracking from fopen/fclose since it does this manually. I've adjusted > the bug accordingly. Yeah. > > > +/* This case checks double-fclose only, suppress other warning. */ > > > +/* { dg-additional-options -Wno-analyzer-double-free } */ So please add "(PR108722)" or such to the comment here? That is enough for future people to see if this is still necessary, to maybe remove it from the testcase here, but certainly not cargo-cult it to other testcases! Thanks, Segher
Hi, On 2023-04-13 20:08, Segher Boessenkool wrote: > On Thu, Apr 13, 2023 at 07:39:01AM +0000, Richard Biener wrote: >> On Thu, 13 Apr 2023, Jiufu Guo wrote: >> I think this should be fixed in the analyzer, "stripping" malloc >> tracking from fopen/fclose since it does this manually. I've adjusted >> the bug accordingly. > > Yeah. > >> > > +/* This case checks double-fclose only, suppress other warning. */ >> > > +/* { dg-additional-options -Wno-analyzer-double-free } */ > > So please add "(PR108722)" or such to the comment here? That is enough > for future people to see if this is still necessary, to maybe remove it > from the testcase here, but certainly not cargo-cult it to other > testcases! Good suggestions, thanks! Committed via r13-7176-gedc6659c97c4a7. BR, Jeff (Jiufu) > > Thanks, > > > Segher
diff --git a/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c b/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c index 2add3cb109b..830cb0376ea 100644 --- a/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c +++ b/gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c @@ -19,6 +19,9 @@ IN NO EVENT SHALL THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE MITRE CORPORATION, ITS BOARD OF TRUSTEES, OFFICERS, AGENTS, AND EMPLOYEES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE INFORMATION OR THE USE OR OTHER DEALINGS IN THE CWE. */ +/* This case checks double-fclose only, suppress other warning. */ +/* { dg-additional-options -Wno-analyzer-double-free } */ + #include <stdio.h> #include <stdlib.h> #include <string.h>