From nobody Tue Jan 30 14:19:35 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TPS3X4mJDz58vyf; Tue, 30 Jan 2024 14:19:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TPS3X1WQGz4kht; Tue, 30 Jan 2024 14:19:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706624376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=947GsZtzOQOOdiLemwtax8h5uXxqhX4Pb9HYQWGzLMI=; b=ceVQhM8Pjw2WCG5RWFlQfc7iXE5zL6RhvBBs4+Hyw04G4O2Q8SPerErXA01V9Xuc+Zb737 2HDPUmC42wb5blzDYVJLgRIJ37Vn0VCTEYJX8bkF8T0K89ZIuxNDSOMTFnBGP3f1kFj/iS +CNXcH7POvLES36vLflm637/TIUnLWshl3LXfeYGiIbKG/jyQh1zltqAV95a9krmENo8Fx lM8+/XYq7zaBIJd6+be89YVnJXJ2SKxboZbh7Ny+BzVmoEJyW3oIZ27feufaori23KtFTd QBlUB/sATQiThr7PHRCGSbul1N/HBIUavk2G56XKsl7kAnbDwJrqY5M5+o2V1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706624376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=947GsZtzOQOOdiLemwtax8h5uXxqhX4Pb9HYQWGzLMI=; b=rfW7b+tFBEMOMD6a0vV4tncFCntZLhvNsI+hPHlGouZn7Sj8Kyhcfijzv0xknMhWyjXzOA jReDofmah8FHWQ72JmKhyaIwqXpDt/LE8xpu2z3dyHVnihVgYtbTkKRt7oGG8xmZJuG0Pd 865R8dC9MKuij/QiFoi1aGFRSIh6bl/NhFruEjwBHeWFesmgh3fkb4pUQJNpmVP2/3JXTC eM5YuCMjYyhFnCQv6Cw//ET5xqvb0ub6tVkQ7UXkymdXJC01fetxxju8/DqjLA3JpydDtw S4uDLWQos/TuE9n/80taHloASLI9m9YijoAp0dzZ+g50ZPooZRPuVAM8sDlMJA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706624376; a=rsa-sha256; cv=none; b=DZBteJIxqyA3/AEjkKqmhFmh+LXWIFH7BCj/tuekPiTBsN+OPOYvZKTQOkVRkDilk3l26S f1W2CQDdr1QHIKf+46ZKNLCuCy03xA/SW0FNV0rHF1ezWC+jEBGCKMRts5NXzfR5kyIpsC A7XkYYCw+5bqHMj04sdG91XDYw7z9C6vj7Qc5FyGU55g4A/GEbn3/dCbaS/63YmJDlS1LZ YMQDIEQfeVSUTsHkswUW5Ht0BiX3nrcObS9RNi6ziCPplEWkOkMVb6yV9DN3YBUJF7Lyhs YKF6bBXWFcoi/9Uc+dY37SyXnQZjvRIEMzw7plnbS8Xr54GQTm9/3aUEkJtwZg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TPS3X0Vd3zfX5; Tue, 30 Jan 2024 14:19:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40UEJZZh096754; Tue, 30 Jan 2024 14:19:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40UEJZCu096751; Tue, 30 Jan 2024 14:19:35 GMT (envelope-from git) Date: Tue, 30 Jan 2024 14:19:35 GMT Message-Id: <202401301419.40UEJZCu096751@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 83b800c59020 - stable/13 - bhyve: Avoid underflows when handling remote commands List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 83b800c59020f4b208666459896281d385fdc557 Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=83b800c59020f4b208666459896281d385fdc557 commit 83b800c59020f4b208666459896281d385fdc557 Author: Mark Johnston AuthorDate: 2024-01-23 16:40:40 +0000 Commit: Mark Johnston CommitDate: 2024-01-30 14:19:28 +0000 bhyve: Avoid underflows when handling remote commands Reviewed by: corvink, jhb MFC after: 1 week Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D43480 (cherry picked from commit cfa2c78aee859bfc6549951bb6a36085fdd374e8) --- usr.sbin/bhyve/gdb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c index cec9ac92ac1c..62f16998450f 100644 --- a/usr.sbin/bhyve/gdb.c +++ b/usr.sbin/bhyve/gdb.c @@ -983,6 +983,8 @@ gdb_read_mem(const uint8_t *data, size_t len) bool started; int error; + assert(len >= 1); + /* Skip 'm' */ data += 1; len -= 1; @@ -1094,6 +1096,8 @@ gdb_write_mem(const uint8_t *data, size_t len) size_t resid, todo, bytes; int error; + assert(len >= 1); + /* Skip 'M' */ data += 1; len -= 1; @@ -1488,7 +1492,7 @@ gdb_query(const uint8_t *data, size_t len) data += strlen("qThreadExtraInfo"); len -= strlen("qThreadExtraInfo"); - if (*data != ',') { + if (len == 0 || *data != ',') { send_error(EINVAL); return; } @@ -1539,7 +1543,7 @@ handle_command(const uint8_t *data, size_t len) case 'H': { int tid; - if (data[1] != 'g' && data[1] != 'c') { + if (len < 2 || (data[1] != 'g' && data[1] != 'c')) { send_error(EINVAL); break; }