From nobody Fri Apr 26 04:47:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557857143; cv=none; d=zoho.com; s=zohoarc; b=BVAppj30GihldHPcUdBiMJWPPj0hXYQ5diRugpJ++TT8i3Ci7zbR3yXqZ4y8j3Gmsp4tjURWoc03OgRPNQNXC3/az3kMFXqG3qqU8c1736Mg6GpTrsjzySTHih7fVJ+PG3Kd8O54HV8cNU53uLSymqjMgv4QBtQx5d4sOrovG9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557857143; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=wLp4owlQVK0zq4wT8m9ss72OLaZLoyavdjMIQYGqVkg=; b=VqGIFcBtampu8u83AZLWMgqTZCCfn+BEthJDccdzYCMsdwLZjnWNXVjN1Q2azVSqG6xDncqq/FrFEEkFfAN4aeULml4iUEqK7+0L/d/18w/+iwIWXs5X1JUpuHB+RZ5wR01pinDTnyQAyBiywD5+LnUlc52G8w3gRxTJjXh/jy0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557857143744545.9301461322362; Tue, 14 May 2019 11:05:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:51998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQbo4-0004Ds-NW for importer@patchew.org; Tue, 14 May 2019 14:05:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQbln-00030h-Qw for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQblm-0002YR-Nz for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40676) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQblm-0002YH-It for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE3E73002619 for ; Tue, 14 May 2019 18:03:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 76BEE5D720; Tue, 14 May 2019 18:03:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EBE5611385FA; Tue, 14 May 2019 20:03:11 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 20:03:06 +0200 Message-Id: <20190514180311.16028-2-armbru@redhat.com> In-Reply-To: <20190514180311.16028-1-armbru@redhat.com> References: <20190514180311.16028-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 14 May 2019 18:03:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/6] qemu-bridge-helper: Fix misuse of isspace() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" parse_acl_file() passes char values to isspace(). Undefined behavior when the value is negative. Not a security issue, because the characters come from trusted $prefix/etc/qemu/bridge.conf and the files it includes. Furthermore, isspace()'s locale-dependence means qemu-bridge-helper uses the user's locale for parsing $prefix/etc/bridge.conf. Feels wrong. Use g_ascii_isspace() instead. This fixes the undefined behavior, and makes parsing of $prefix/etc/bridge.conf locale-independent. Signed-off-by: Markus Armbruster --- qemu-bridge-helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c index 5396fbfbb6..f9940deefd 100644 --- a/qemu-bridge-helper.c +++ b/qemu-bridge-helper.c @@ -75,7 +75,7 @@ static int parse_acl_file(const char *filename, ACLList *= acl_list) char *ptr =3D line; char *cmd, *arg, *argend; =20 - while (isspace(*ptr)) { + while (g_ascii_isspace(*ptr)) { ptr++; } =20 @@ -99,12 +99,12 @@ static int parse_acl_file(const char *filename, ACLList= *acl_list) =20 *arg =3D 0; arg++; - while (isspace(*arg)) { + while (g_ascii_isspace(*arg)) { arg++; } =20 argend =3D arg + strlen(arg); - while (arg !=3D argend && isspace(*(argend - 1))) { + while (arg !=3D argend && g_ascii_isspace(*(argend - 1))) { argend--; } *argend =3D 0; --=20 2.17.2 From nobody Fri Apr 26 04:47:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557857140; cv=none; d=zoho.com; s=zohoarc; b=RDwossMRIjf3fW3ZcriSEpCv0tbJNUBHaSq1EfQbcETb3v8uJ3ErYbFyQZNZQbPXx2T8WpL5CxnTlnhYdEsBW+rY8M6YvauxkpTPXhdynbzLKzuz2SORFwbX8J0QqI3PB/oeg0PnWg1YVL3VZBOEgrx/ybAQTW1VQpjrYMB1Si8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557857140; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VBvn8ECGuyfTuESSKgvrzYn3VOajurgOJU3Pk+yWCDg=; b=BciEHCZvQx3WTumapYaN/vQsUHwNzpjaW+YGVFJbVAgEolSCFzz86PJRdSOcSO9oad7qPd9ZLJ4k/rlWGMb5C/8y4UMN8xTR4tA1gS5EkL6NvgejQq+HBq+/P86AyKmWXO7W6RvFZnHyGHaA6D+SyXXRMay9tdTcslATYcyRuz8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557857140192661.3303593122323; Tue, 14 May 2019 11:05:40 -0700 (PDT) Received: from localhost ([127.0.0.1]:51996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQbo1-0004Bt-7L for importer@patchew.org; Tue, 14 May 2019 14:05:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQbln-00030p-Rk for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQblm-0002Yo-Uq for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48911) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQblm-0002YJ-Ni for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17BF334CF for ; Tue, 14 May 2019 18:03:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 83B805EDE1; Tue, 14 May 2019 18:03:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F0CCB113861C; Tue, 14 May 2019 20:03:11 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 20:03:07 +0200 Message-Id: <20190514180311.16028-3-armbru@redhat.com> In-Reply-To: <20190514180311.16028-1-armbru@redhat.com> References: <20190514180311.16028-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 14 May 2019 18:03:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/6] tests/vhost-user-bridge: Fix misuse of isdigit() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" vubr_set_host() passes char values to isdigit(). Undefined behavior when the value is negative. Fix by using qemu_isdigit() instead. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- tests/vhost-user-bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c index 0033b61f2e..d70b107ebc 100644 --- a/tests/vhost-user-bridge.c +++ b/tests/vhost-user-bridge.c @@ -645,7 +645,7 @@ vubr_host_notifier_setup(VubrDev *dev) static void vubr_set_host(struct sockaddr_in *saddr, const char *host) { - if (isdigit(host[0])) { + if (qemu_isdigit(host[0])) { if (!inet_aton(host, &saddr->sin_addr)) { fprintf(stderr, "inet_aton() failed.\n"); exit(1); --=20 2.17.2 From nobody Fri Apr 26 04:47:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557857299; cv=none; d=zoho.com; s=zohoarc; b=lza4FlQRhOjIMLYGA/GPZ6Phdii/QVCapwlLDtIojanOfGMamGcDuL1TJRj6pNNf1PyOZtAVl04t+Q4pBT/+LnyXZApQxQGrhw5JjS3nBUOcHbpC1zRpls0tWK0KOovq/JQfz935PKazNqV08wvBXAOnm0LxwGZ6uvna1lM8pS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557857299; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=puSN+X3K7R7dOsMn5Q4Z7M6Kh4ol2xsugx53bHfl2Xs=; b=LjUjm8dEuT++vNvPLEvk7IjXtVYpGSktKtM/vF40rvatcaaow1qdqESTfelYyGPk52UXZ+Zm9v49m9qSVE4vHeYiwymtwY1Dw/NT+PEIgbpON1jNfhJMPf8m0QaFvWuu3jbMnjO8RsMpTaTGohYHthBnGVoxQAgSc9AmCItIpt0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557857299438984.0342730662817; Tue, 14 May 2019 11:08:19 -0700 (PDT) Received: from localhost ([127.0.0.1]:52050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQbqZ-0006Q5-EX for importer@patchew.org; Tue, 14 May 2019 14:08:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQblp-00031u-26 for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQblo-0002a1-5o for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30373) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQblo-0002ZM-0a for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B137309B15C for ; Tue, 14 May 2019 18:03:19 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7EAC45D72A; Tue, 14 May 2019 18:03:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 001D011385D0; Tue, 14 May 2019 20:03:11 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 20:03:08 +0200 Message-Id: <20190514180311.16028-4-armbru@redhat.com> In-Reply-To: <20190514180311.16028-1-armbru@redhat.com> References: <20190514180311.16028-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 14 May 2019 18:03:19 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/6] gdbstub: Reject invalid RLE repeat counts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" "Debugging with GDB / Appendix E GDB Remote Serial Protocol / Overview" specifies "The printable characters '#' and '$' or with a numeric value greater than 126 must not be used." gdb_read_byte() only rejects values < 32. This is wrong. Impact depends on the caller: * gdb_handlesig() passes a char. Incorrectly accepts '#', '$' and '\127'. * gdb_chr_receive() passes an uint8_t. Additionally accepts characters with the most-significant bit set. Correct the validity check to match the specification. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- gdbstub.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdbstub.c b/gdbstub.c index d54abd17cc..c41eb1de07 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2064,7 +2064,11 @@ static void gdb_read_byte(GDBState *s, int ch) } break; case RS_GETLINE_RLE: - if (ch < ' ') { + /* + * Run-length encoding is explained in "Debugging with GDB / + * Appendix E GDB Remote Serial Protocol / Overview". + */ + if (ch < ' ' || ch =3D=3D '#' || ch =3D=3D '$' || ch > 126) { /* invalid RLE count encoding */ trace_gdbstub_err_invalid_repeat((uint8_t)ch); s->state =3D RS_GETLINE; --=20 2.17.2 From nobody Fri Apr 26 04:47:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557857292; cv=none; d=zoho.com; s=zohoarc; b=cQwidMVNQr2SXaKBAhH+FTUFVPfU1G/BTpcQ7Wt32KaBBvxa8JCSZHMDVcEmpZsMCblG/jom7FlvlYOALCShBHBM1u3MVFgFgTI9fOjaFO925OlllRxBoiLeK1DuJL8eRAm4OhpUITeL9K4n2jXNMqElBTE8BwJ8X7As7zpld6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557857292; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=G6N4tgao43761DdMCeVvQST75RC1+vsSC/3PCfAQLVk=; b=XkItkIq3Ws98rgBiO+IYxkq8bNNYtOEgum9QQwct94N44yigvmOLMDBgWKphCUQ7UPovKuQrhCirmMb9Yk3LD5SBh9NmIhkl/dzvQupSOXYWslA4i9VWYYeKToi5xespJmWGPN9kzCX4Fw66RZPqsRUHManeq1kMW2h17bcz0Dk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557857292712353.337574125654; Tue, 14 May 2019 11:08:12 -0700 (PDT) Received: from localhost ([127.0.0.1]:52046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQbqT-0006Lo-HV for importer@patchew.org; Tue, 14 May 2019 14:08:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQbln-000308-4d for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQblm-0002YD-1e for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58396) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQbll-0002Xw-Qm for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F204821D9 for ; Tue, 14 May 2019 18:03:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 847A460FE4; Tue, 14 May 2019 18:03:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 039AA1138538; Tue, 14 May 2019 20:03:12 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 20:03:09 +0200 Message-Id: <20190514180311.16028-5-armbru@redhat.com> In-Reply-To: <20190514180311.16028-1-armbru@redhat.com> References: <20190514180311.16028-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 14 May 2019 18:03:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 4/6] gdbstub: Fix misuse of isxdigit() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" gdb_read_byte() passes its @ch argument to isxdigit(). Undefined behavior when the value is negative. Two callers: * gdb_chr_receive() passes an uint8_t value. Safe. * gdb_handlesig() a char value. Unsafe. Not a security issue, because the characters come from the gdb client, which is trusted. The obvious fix would be casting @ch to unsigned char. But note that gdb_read_byte() already casts @ch to uint8_t in many places. Uses of @ch without such a cast: (1) Compare to a character constant with =3D=3D or !=3D (2) s->linesum +=3D ch (3) Store ch or ch ^ 0x20 into s->line_buf[] (4) Check for invalid RLE count: ch < ' ' || ch =3D=3D '#' || ch =3D=3D '$' || ch > 126 (5) Pass to isxdigit() (6) Pass to fromhex() Change the parameter type from int to uint8_t, and drop the now redundant casts. Affects the above uses as follows: (1) No change: the character constants are all non-negative. (2) Effectively no change: we only ever use s->linesum & 0xff, and s->linesum is int. (3) No change: s->line_buf[] is char[]. (4) No change. (5) Avoid undefined behavior. (6) No change: only reached when isxdigit(ch) Signed-off-by: Markus Armbruster --- gdbstub.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index c41eb1de07..b129df4e59 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1987,7 +1987,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const= char *fmt, ...) va_end(va); } =20 -static void gdb_read_byte(GDBState *s, int ch) +static void gdb_read_byte(GDBState *s, uint8_t ch) { uint8_t reply; =20 @@ -2001,7 +2001,7 @@ static void gdb_read_byte(GDBState *s, int ch) } else if (ch =3D=3D '+') { trace_gdbstub_io_got_ack(); } else { - trace_gdbstub_io_got_unexpected((uint8_t)ch); + trace_gdbstub_io_got_unexpected(ch); } =20 if (ch =3D=3D '+' || ch =3D=3D '$') @@ -2024,7 +2024,7 @@ static void gdb_read_byte(GDBState *s, int ch) s->line_sum =3D 0; s->state =3D RS_GETLINE; } else { - trace_gdbstub_err_garbage((uint8_t)ch); + trace_gdbstub_err_garbage(ch); } break; case RS_GETLINE: @@ -2070,11 +2070,11 @@ static void gdb_read_byte(GDBState *s, int ch) */ if (ch < ' ' || ch =3D=3D '#' || ch =3D=3D '$' || ch > 126) { /* invalid RLE count encoding */ - trace_gdbstub_err_invalid_repeat((uint8_t)ch); + trace_gdbstub_err_invalid_repeat(ch); s->state =3D RS_GETLINE; } else { /* decode repeat length */ - int repeat =3D (unsigned char)ch - ' ' + 3; + int repeat =3D ch - ' ' + 3; if (s->line_buf_index + repeat >=3D sizeof(s->line_buf) - = 1) { /* that many repeats would overrun the command buffer = */ trace_gdbstub_err_overrun(); @@ -2096,7 +2096,7 @@ static void gdb_read_byte(GDBState *s, int ch) case RS_CHKSUM1: /* get high hex digit of checksum */ if (!isxdigit(ch)) { - trace_gdbstub_err_checksum_invalid((uint8_t)ch); + trace_gdbstub_err_checksum_invalid(ch); s->state =3D RS_GETLINE; break; } @@ -2107,7 +2107,7 @@ static void gdb_read_byte(GDBState *s, int ch) case RS_CHKSUM2: /* get low hex digit of checksum */ if (!isxdigit(ch)) { - trace_gdbstub_err_checksum_invalid((uint8_t)ch); + trace_gdbstub_err_checksum_invalid(ch); s->state =3D RS_GETLINE; break; } --=20 2.17.2 From nobody Fri Apr 26 04:47:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557857436; cv=none; d=zoho.com; s=zohoarc; b=RYVhR73CgKZxEVF+yXYBzEmyN6x45OziYx4fMFauHzJYjxpOgUwkDUoFn1dTfHn8X9Pw618EtZjxpRW27H7YcCRT3rOw36Ue4CqA0K+O1oasrIPDCJJLN0O/AjCImvQVEPYu97LsEXUUfZvkNCOlQuuexx/vaa9jIyhWGCzye/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557857436; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=AFyL6Z2QTDylWZ4jmbuvhWJ9l56Bj2SZVzpO5EGrhJ8=; b=jkteowUNyLhbtpMxoZH0XDk24jEXpf9c3M2YubGDTX0wAju7QKHZUOd7RGVvAgudm5KM0XzT/FgFqb1/31MxaWI4a6UMu4Zzu6kXUAEOV4diwpldoVAVT+xqI7tJkFcqMfa0dDeOn81iHRdNX9TUtSjRzbiRtP8+ME/Y29GC3Uw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557857436712954.1597109253921; Tue, 14 May 2019 11:10:36 -0700 (PDT) Received: from localhost ([127.0.0.1]:52073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQbsR-0007qZ-2U for importer@patchew.org; Tue, 14 May 2019 14:10:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQblu-00036b-1N for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQblt-0002d6-5V for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40754) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQblt-0002ca-07; Tue, 14 May 2019 14:03:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4BC77308425B; Tue, 14 May 2019 18:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 532B412A6F; Tue, 14 May 2019 18:03:20 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 073331138407; Tue, 14 May 2019 20:03:12 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 20:03:10 +0200 Message-Id: <20190514180311.16028-6-armbru@redhat.com> In-Reply-To: <20190514180311.16028-1-armbru@redhat.com> References: <20190514180311.16028-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 14 May 2019 18:03:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 5/6] pc-bios/s390-ccw: Clean up harmless misuse of isdigit() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , thuth@redhat.com, Cornelia Huck , philmd@redhat.com, qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" atoui() and get_index() pass char values to isdigit(). With a standard isdigit(), we'd get undefined behavior when the value is negative. Can't happen as char is unsigned on s390x. Even if it could, we're actually using isdigit() from pc-bios/s390-ccw/libc.h here, which works fine for negative values. Clean up anyway, just to avoid setting a bad example. Cc: Christian Borntraeger Cc: Thomas Huth Cc: Cornelia Huck Cc: qemu-s390x@nongnu.org Signed-off-by: Markus Armbruster Acked-by: Christian Borntraeger --- pc-bios/s390-ccw/libc.c | 2 +- pc-bios/s390-ccw/menu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pc-bios/s390-ccw/libc.c b/pc-bios/s390-ccw/libc.c index a786566c4c..3187923950 100644 --- a/pc-bios/s390-ccw/libc.c +++ b/pc-bios/s390-ccw/libc.c @@ -38,7 +38,7 @@ uint64_t atoui(const char *str) } =20 while (*str) { - if (!isdigit(*str)) { + if (!isdigit(*(unsigned char *)str)) { break; } val =3D val * 10 + *str - '0'; diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c index 82a4ae6315..ce3815b201 100644 --- a/pc-bios/s390-ccw/menu.c +++ b/pc-bios/s390-ccw/menu.c @@ -134,7 +134,7 @@ static int get_index(void) =20 /* Check for erroneous input */ for (i =3D 0; i < len; i++) { - if (!isdigit(buf[i])) { + if (!isdigit((unsigned char)buf[i])) { return -1; } } --=20 2.17.2 From nobody Fri Apr 26 04:47:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557857497; cv=none; d=zoho.com; s=zohoarc; b=KnaTwXoeGiSGPW6RRi3px/tSFZ0UFzHBZn8LGYxQ6KgWYO8g3ScNJXE3J2nfyT4cPMbN82d3zqXNqRKsUyXjtUFgbiqb9iAuB6l55zRKyf1omCqGd3nH4fuaKdlH0CyI8JpRODG7z2uf57WUX+jy/vLimiHJk2Rs4GXcDxwxDDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557857497; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=1q+Kq5sQpk3iSU0q23AwAhaMMiczqJz6+uXSL4/JiNA=; b=YwB4UemmDVfqWAx4WoSNZgsHJT/qlBPu9fYC4/RuIlBa6UcE+lrbg9MgK6MUyIu9OOjw+6feQtz/Q44FZJdiBdOkjl/5b7gI75U74uTwshPiHp+i5uwp5+1TYKo1dueEw6sGN5vcq/vCfsf3aWphkEnLPEtcFwKK+vDrmm+3yB8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557857497676405.6800913106806; Tue, 14 May 2019 11:11:37 -0700 (PDT) Received: from localhost ([127.0.0.1]:52118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQbto-0000bE-Ol for importer@patchew.org; Tue, 14 May 2019 14:11:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQbmH-0003OS-SZ for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQbmF-0002vW-Lv for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46214) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQbmF-0002uI-Gx for qemu-devel@nongnu.org; Tue, 14 May 2019 14:03:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F034B3092659 for ; Tue, 14 May 2019 18:03:45 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53817608A7; Tue, 14 May 2019 18:03:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0B6E0113304E; Tue, 14 May 2019 20:03:12 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 20:03:11 +0200 Message-Id: <20190514180311.16028-7-armbru@redhat.com> In-Reply-To: <20190514180311.16028-1-armbru@redhat.com> References: <20190514180311.16028-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 14 May 2019 18:03:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 6/6] cutils: Simplify how parse_uint() checks for whitespace X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use qemu_isspace() so we don't have to cast to unsigned char. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- util/cutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/cutils.c b/util/cutils.c index d682c90901..9aacc422ca 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -683,7 +683,7 @@ int parse_uint(const char *s, unsigned long long *value= , char **endptr, } =20 /* make sure we reject negative numbers: */ - while (isspace((unsigned char)*s)) { + while (qemu_isspace(*s)) { s++; } if (*s =3D=3D '-') { --=20 2.17.2