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 66DB13858D37 for ; Fri, 28 Apr 2023 09:39:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66DB13858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33S9b0v0014629; Fri, 28 Apr 2023 09:39:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pp1; bh=nLmH3C2oKX9C1ZJgvHghTaKG0s/qei6hKFjd86TW+0A=; b=m7aAKjxQknFNHzfvTcucUp7sHcH8Q2gkOQtjtrt3XqUgRHCdjfs19AOtfeuPF/j5gKws 8xnHkLPZ8jmY/ZELJllSXXd7fHjN5WmHpcjVyQbTeE0MgkcgIU0DvTo4uWKb1usd9ZiP BVFsXBtedQJ5vUGoEGpj1N2Y9pLgsH4gOOli4uupjvizaREVAiADGHQxQUpzo7Ekx4RG FeQklxDzx7U7WA3+9+XT3m7FeKS75CsjQt7OmwUt/eCzifNUEvg/VbhdaasLqinox8tS cTRLeH89DwYQw7wQbFPH5LkcTpBLBqifar1tCe2FRTrdHK38Jmq3rKg7UINzmF2kVacf vg== Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3q8bjar7qf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Apr 2023 09:39:33 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 33S4LG4h024273; Fri, 28 Apr 2023 09:38:01 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3q47772uxv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Apr 2023 09:38:01 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 33S9bx3A35652094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 09:37:59 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0EF3E2004B; Fri, 28 Apr 2023 09:37:59 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE5D120040; Fri, 28 Apr 2023 09:37:58 +0000 (GMT) Received: from [9.171.49.95] (unknown [9.171.49.95]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 28 Apr 2023 09:37:58 +0000 (GMT) Message-ID: <78d8001581eafec9a53ac440d6e43b8c52362068.camel@linux.ibm.com> Subject: Re: [PATCH] gas: fix building tc-bpf.c on s390x From: Ilya Leoshkevich To: Jan Beulich Cc: binutils@sourceware.org, Jose Marchesi Date: Fri, 28 Apr 2023 11:37:58 +0200 In-Reply-To: References: <20230427125607.362035-1-iii@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: mb-lrNvF26ZyLQ1dINVWkTHmUnTPXsqw X-Proofpoint-ORIG-GUID: mb-lrNvF26ZyLQ1dINVWkTHmUnTPXsqw 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-28_04,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 mlxlogscore=429 priorityscore=1501 adultscore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304280077 X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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 List-Id: 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) > > =C2=A0=C2=A0=C2=A0=C2=A0 } while (0) > > =C2=A0 > > =C2=A0=C2=A0 const char *str =3D *insn; > > -=C2=A0 char ch, ch2 =3D 0; > > +=C2=A0 signed char ch, ch2 =3D 0; >=20 > 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) > > =C2=A0=C2=A0=C2=A0=C2=A0 } while (0) > > =C2=A0 > > =C2=A0=C2=A0 enum bpf_token_type ttype; > > -=C2=A0 enum bpf_token_type bpf_endianness, > > +=C2=A0 enum bpf_token_type bpf_endianness =3D BPF_UNKNOWN, >=20 > 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(). >=20 > 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