Message ID | 20230427125607.362035-1-iii@linux.ibm.com |
---|---|
State | Unresolved |
Headers |
Return-Path: <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp263821vqo; Thu, 27 Apr 2023 06:21:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4is6VmyU43QxOz6ddeFGGPXT/xPz4cbTTWHW/+T/e1+hw45bsONNV4nY48bCL1rpeva2Ni X-Received: by 2002:a05:6402:4:b0:502:20f0:3ee1 with SMTP id d4-20020a056402000400b0050220f03ee1mr1585178edu.31.1682601702605; Thu, 27 Apr 2023 06:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682601702; cv=none; d=google.com; s=arc-20160816; b=VvqSJ3BvwH/gTzQpMcwD7Lsuokth3bjlTqrhJ1VeCUL1G0WYz820o5V2hQO4fD2RDr 8UL5kxPhWrMq9AkSoD36sLNsLl/ljnH7/N+8xRnANxUNyrqfiXUhIGhettjuoD4NrPMU 7D4REtYFNgcW45mTEhq54BOixgnba01FQ0ZUk1/LftXnOm0IrSPU/TpNYalQfKLPng8O bobGgd1h+pVtw1AHL3PXElRQw6IlLMXPdMlRi1/4gFPBLMpBJ2GJNdJYlzp+F7665XeI IfemXnNSWgUk3tcCXPcm3zDH1C+/M2BH6KLnC6KCGaRtrP+SyPXkd2P/+QGiULcUYOT5 Qk8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=HU4szL03gKdIXidTVjBZpvC2wsAc2goxzmCauvkSDc8=; b=0CFwSOMpIG82aR4L7fzYUFgCNPwRydQMKrTbwLHU37o61k1sNXtUgwh/VsN3n+y7vd sMEBqgEAXsr/ObFdvS4GloIuHDIsk33cprMWWf9K5RC9aw4R1oOWzaOniSna6aQQeEyW Eo2kPzHU3PHS+4EkWwhqJJ2O7MtybtPghZO6q/Ur4P9rcEPFsBXcbhujeERZaB3zPV61 v1QxAgdA6+S9Vi6MWXO0u0NhvqtdX883SQG2RUREYANOHJB0uUNDmbyjyYTXCjguuLfJ GONzJEWPlXioTbTw9Q7AljMEu2Gm9Jj1hxjhQIl64U7f/GPTU9GKj9UNDv+154kLrWOt bAkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=QqXREome; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l8-20020a056402344800b00506aec4dfb3si14938905edc.192.2023.04.27.06.21.42 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 06:21:42 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=QqXREome; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 516453858431 for <ouuuleilei@gmail.com>; Thu, 27 Apr 2023 13:21:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 516453858431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682601700; bh=HU4szL03gKdIXidTVjBZpvC2wsAc2goxzmCauvkSDc8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=QqXREomeF6Z0JIGDl5ibvCdWovDf43Ht7ugEy32wJTJnxmA6JmMqfW8zSB5AcMbLj TucnXk220M5EA+4JGbx19vgwZwfKXSchXunUiZleK/LYvqEvv9zcrXA4ZUO2rZTl45 ZM2rRtWbii3f5V8aECviS5XF+pg+Le+YldJOsiOQ= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id BDD543858C31 for <binutils@sourceware.org>; Thu, 27 Apr 2023 13:21:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BDD543858C31 Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33RD6xBN013042 for <binutils@sourceware.org>; Thu, 27 Apr 2023 13:21:31 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3q7s701bqd-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for <binutils@sourceware.org>; Thu, 27 Apr 2023 13:21:31 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 33QLrc0r007999 for <binutils@sourceware.org>; Thu, 27 Apr 2023 12:56:14 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3q47772y9q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for <binutils@sourceware.org>; Thu, 27 Apr 2023 12:56:14 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 33RCuAC242992016 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Apr 2023 12:56:10 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B721B20049; Thu, 27 Apr 2023 12:56:10 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 795B120040; Thu, 27 Apr 2023 12:56:10 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.75.51]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 27 Apr 2023 12:56:10 +0000 (GMT) To: binutils@sourceware.org Cc: Ilya Leoshkevich <iii@linux.ibm.com> Subject: [PATCH] gas: fix building tc-bpf.c on s390x Date: Thu, 27 Apr 2023 14:56:07 +0200 Message-Id: <20230427125607.362035-1-iii@linux.ibm.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Uc6QplDi1wutLnQQ_ddT3L3dyHEZLJcF X-Proofpoint-ORIG-GUID: Uc6QplDi1wutLnQQ_ddT3L3dyHEZLJcF 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-27_07,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=747 impostorscore=0 phishscore=0 suspectscore=0 clxscore=1011 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304270116 X-Spam-Status: No, score=-12.2 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, T_SCC_BODY_TEXT_LINE 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> From: Ilya Leoshkevich via Binutils <binutils@sourceware.org> Reply-To: Ilya Leoshkevich <iii@linux.ibm.com> Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764335763143400054?= X-GMAIL-MSGID: =?utf-8?q?1764335763143400054?= |
Series |
gas: fix building tc-bpf.c on s390x
|
|
Checks
Context | Check | Description |
---|---|---|
snail/binutils-gdb-check | warning | Git am fail log |
Commit Message
Ilya Leoshkevich
April 27, 2023, 12:56 p.m. UTC
char is unsigned on s390x, so there are a lot of warnings like: gas/config/tc-bpf.c: In function 'get_token': gas/config/tc-bpf.c:900:14: error: comparison is always false due to limited range of data type [-Werror=type-limits] 900 | if (ch == EOF || len > MAX_TOKEN_SZ) | ^~ Make ch explicitly signed. There is also: gas/config/tc-bpf.c:735:30: error: 'bpf_endianness' may be used uninitialized in this function [-Werror=maybe-uninitialized] 735 | dst, be ? size[endianness - BPF_BE16] : size[endianness - BPF_LE16]); | ~~~~~~~~~~~^~~~~~~~~~ -Wmaybe-uninitialized doesn't seem to understand the FSM; just initialize bpf_endianness to silence it. --- gas/config/tc-bpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 27.04.2023 14:56, Ilya Leoshkevich via Binutils wrote: > --- a/gas/config/tc-bpf.c > +++ b/gas/config/tc-bpf.c > @@ -885,7 +885,7 @@ get_token (const char **insn, char *token, size_t *tlen) > } while (0) > > const char *str = *insn; > - char ch, ch2 = 0; > + signed char ch, ch2 = 0; But this doesn't make things any better. If you grep for uses of EOF in gas, you'll find that the corresponding variables typically are of type int, and that's what I expect you want to use here as well. > @@ -1362,7 +1362,7 @@ bpf_pseudoc_to_normal_syntax (const char *str, char **errmsg) > } while (0) > > enum bpf_token_type ttype; > - enum bpf_token_type bpf_endianness, > + enum bpf_token_type bpf_endianness = BPF_UNKNOWN, The variable surely wants an initializer, but I'm uncertain whether the one you picked is suitable. I don't know bpf, but I see only two options: There is a default endianness, in which case that wants to be the initializer. Or endianness needs to be specified explicitly before any of the constructs leading to build_bpf_endianness() may be used. In that case the initializer chosen is perhaps fine, but the variable then still having that value would need to be diagnosed. With what you've done we now end up with an out of bounds array access in build_bpf_endianness(). You would better have Cc-ed the arch maintainer anyway; doing so now. Jan
On Fri, 2023-04-28 at 08:42 +0200, Jan Beulich wrote: > On 27.04.2023 14:56, Ilya Leoshkevich via Binutils wrote: > > --- a/gas/config/tc-bpf.c > > +++ b/gas/config/tc-bpf.c > > @@ -885,7 +885,7 @@ get_token (const char **insn, char *token, > > size_t *tlen) > > } while (0) > > > > const char *str = *insn; > > - char ch, ch2 = 0; > > + signed char ch, ch2 = 0; > > But this doesn't make things any better. If you grep for uses of EOF > in > gas, you'll find that the corresponding variables typically are of > type > int, and that's what I expect you want to use here as well. You are right, int is better. Thanks. > > @@ -1362,7 +1362,7 @@ bpf_pseudoc_to_normal_syntax (const char > > *str, char **errmsg) > > } while (0) > > > > enum bpf_token_type ttype; > > - enum bpf_token_type bpf_endianness, > > + enum bpf_token_type bpf_endianness = BPF_UNKNOWN, > > The variable surely wants an initializer, but I'm uncertain whether > the > one you picked is suitable. I don't know bpf, but I see only two > options: > There is a default endianness, in which case that wants to be the > initializer. Or endianness needs to be specified explicitly before > any > of the constructs leading to build_bpf_endianness() may be used. In > that > case the initializer chosen is perhaps fine, but the variable then > still > having that value would need to be diagnosed. With what you've done > we > now end up with an out of bounds array access in > build_bpf_endianness(). > > You would better have Cc-ed the arch maintainer anyway; doing so now. In that regard the patch does not make things worse. If we end up not initializing the variable on the intended path, with today's code we would still have an OOB access (but with a random offset). The goal here is only to silence the warning, which I believe is emitted incorrectly. If I read the FSM correctly, this can only happen due to a bug, no user input (valid or invalid) should be leading to this. So, just to be on the safe side, I would add gas_assert() to build_bpf_endianness(). > Jan
diff --git a/gas/config/tc-bpf.c b/gas/config/tc-bpf.c index 171fc682806..adcf5edc645 100644 --- a/gas/config/tc-bpf.c +++ b/gas/config/tc-bpf.c @@ -885,7 +885,7 @@ get_token (const char **insn, char *token, size_t *tlen) } while (0) const char *str = *insn; - char ch, ch2 = 0; + signed char ch, ch2 = 0; enum bpf_token_type ttype = BPF_UNKNOWN; size_t len = 0; const char *expr = NULL; @@ -1362,7 +1362,7 @@ bpf_pseudoc_to_normal_syntax (const char *str, char **errmsg) } while (0) enum bpf_token_type ttype; - enum bpf_token_type bpf_endianness, + enum bpf_token_type bpf_endianness = BPF_UNKNOWN, bpf_atomic_insn; enum bpf_token_type bpf_jmp_op = BPF_JEQ; /* Arbitrary. */ enum bpf_token_type bpf_cast = BPF_CAST_U8; /* Arbitrary. */