From nobody Thu Aug 15 14:30:01 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 4Wl6w93qX8z5SGDK; Thu, 15 Aug 2024 14:30:01 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wl6w92tWpz4NTC; Thu, 15 Aug 2024 14:30:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723732201; 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=HQfiJdeksuQDs9IplC5X0atJFNDSvB2LQFyi2u5+XCo=; b=t8PLDZIT6rgWZll60AqWO7Fzq/modub3X/Is+/a1E4ccl1P/0Oy+LMQQ6LilKqTTwJzkFH +rT2pCVkIkaT6RWtGdMzfyuSz42p2guASePl6CixtXFPk3Tqq2XKT836Hl93L7TPZDK5x5 GQjk8GJfKGPGeUEfrIeP87L0I/qNLAw4XjXQ/vZl6u769STN08Yljkr/6b3z1zXAA5n4Nc CozCg7NWuVBfzYPRWwZlrTioQkMr0RbPocLbfkvXil9r6FGC1c+XYjqj8CjCj6XqHh+sCa vu1wuJ4vVyFUpCUr4P9IXeGLyADak5YynGMrfjW4G1HgOngDZd9dLy9t9ZJzIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723732201; a=rsa-sha256; cv=none; b=SETMD2BdujMXe5Rlw8swYOpUsRPMZMVHR5wS6SJURp5cr2319fVel/pQJXHsweEeKXK5Cl j3B/2tJsYNrrJzz3N/OMCVnZMPBT/FJGLue6WG3Sc9uxWGA6YL+9ft0ObtLijCbkUjpitE uciSbURD8xHFKcilm2CzV+/rcNr2vPgohi+A/Urv2EI7/xISmRgnRB7vHTkCIXbck0tT1o pDkPXZHHUmabi4LC6+cu5ZrWefnQaL35djLUbLv0xhjICxDytECgVS9vFazTOHKaPh/+2O YeyhozVyWaQScxto00dcMI6nPzoUX0DOZsbiK8uMsREbyn1y+wHAuYTCVYhCRw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723732201; 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=HQfiJdeksuQDs9IplC5X0atJFNDSvB2LQFyi2u5+XCo=; b=vCzvggvcC9AE39EokjGHmMgF+dY601RCAXvlMd9LOCJx8YDGHcWh/A2bFeMwLQrU2SbDH1 ZMMU2VFleKN2yqYo8z/Dd451BErbqguYiRSHrgrVPIsP3oDkAw4IrI6butrrlyRN+HTfSP VIjTjYKZm/ooyuBedH/5Y3P1KlgvFiNi+ImXfZ2Nci0IW24S1Ew+Qe8MgKWsuYfpHlLA0q Ghdr42CKCDBwwtn0fiCxZ+gX00v9QPyfCV0B8TUIpKX2kSa527+731SG1SO8KKhY23pj4F yNEdzzQdUXOgw2st6hS0RjCsnnQd7JS1TyPfNRZVe9z+4ujYqKJ7C5lMjUduoQ== 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 4Wl6w92ML3zQqb; Thu, 15 Aug 2024 14:30:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47FEU1u4018642; Thu, 15 Aug 2024 14:30:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47FEU1EY018637; Thu, 15 Aug 2024 14:30:01 GMT (envelope-from git) Date: Thu, 15 Aug 2024 14:30:01 GMT Message-Id: <202408151430.47FEU1EY018637@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: f4d580a54734 - stable/14 - bhyve: Escape binary data sent in reply packets 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/14 X-Git-Reftype: branch X-Git-Commit: f4d580a547341362cacc79383a24e51c6875ff9a Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f4d580a547341362cacc79383a24e51c6875ff9a commit f4d580a547341362cacc79383a24e51c6875ff9a Author: Mark Johnston AuthorDate: 2024-07-31 22:41:13 +0000 Commit: Mark Johnston CommitDate: 2024-08-15 14:29:49 +0000 bhyve: Escape binary data sent in reply packets Per https://sourceware.org/gdb/current/onlinedocs/gdb.html/Overview.html#Binary-Data certain bytes must be escaped. The XML register definitions we have so far do not run afoul of that rule, but the stub should handle them anyway. Reviewed by: jhb MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D46194 (cherry picked from commit b4fb947923b566a3a8a6ad8e5f8ea8dec0c68ee4) --- usr.sbin/bhyve/gdb.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c index 0319aaf0a9cd..abdc64a4a75a 100644 --- a/usr.sbin/bhyve/gdb.c +++ b/usr.sbin/bhyve/gdb.c @@ -564,6 +564,28 @@ append_packet_data(const uint8_t *data, size_t len) } } +static void +append_binary_data(const uint8_t *data, size_t len) +{ + uint8_t buf[2]; + + for (; len > 0; data++, len--) { + switch (*data) { + case '}': + case '#': + case '$': + case '*': + buf[0] = 0x7d; + buf[1] = *data ^ 0x20; + append_packet_data(buf, 2); + break; + default: + append_packet_data(data, 1); + break; + } + } +} + static void append_string(const char *str) { @@ -1675,10 +1697,10 @@ gdb_query(const uint8_t *data, size_t len) append_char('l'); } else if (doff + dlen >= xmllen) { append_char('l'); - append_packet_data(xml + doff, xmllen - doff); + append_binary_data(xml + doff, xmllen - doff); } else { append_char('m'); - append_packet_data(xml + doff, dlen); + append_binary_data(xml + doff, dlen); } finish_packet(); (void)munmap(__DECONST(void *, xml), xmllen);