From nobody Wed Jul 31 23:44:39 2024 X-Original-To: dev-commits-src-main@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 4WZ7x35mktz5RZt1; Wed, 31 Jul 2024 23:44:39 +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 4WZ7x34sq9z4x0R; Wed, 31 Jul 2024 23:44:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722469479; 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=4UGc9p0pF1H8oBKsydarNfNGv48ZiaoKQd9hMHvk0vo=; b=ku/UbzhNGmjD+Bsw/mMouYst8CNOcFRqv9T7ymzuBRp2DtBG70tFIy/GSnufCf/XhzQBzf 5jeDhFVmY/wi41XCrubETCFhidXglT6tfHo9UX0sIEUg0GGvjScLl+eaTxMDdjgv+HyBaU K6iK4z/TKl/c9dhRTYDXQskndjj3lY7nXP+T2L8IPuwNJZKnhNaANOKPKRr705zuYQRL8U P8LGKvYH1XYCJpchKsaa8RWXhWKR44OyIugfrIGGbHM+FKl7ND4kv+7r6OSlC9ZHPCjNQn CoQQd4rFxk8wdi1nnI5m/QOh7j+4+I3KihaulpIGFIkIe+fhCFYhM6ZPP/8VNA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722469479; a=rsa-sha256; cv=none; b=drXKrO/U2dhs47n+Rel/qPfjGpR98sdwa+ylRGyv4FqeV0RLwYoCMPDp7yvPbR1M9PnPzP 628et8Urjziq/8FdVL2iTgRo7BlG396+bDIwrEUfu7wtJ4AenVBnVRNQ485tlbz6M7CYtI RXtbDC/07yLZdn9WYp21K3Fd7/thU10Hm5OJq/rO2KINv8kumFC6ekFMEeXK6tZXkJaz8+ wm6m4oZsOOVms5bqRHIL94tVFX/abRdPjKRuLPgQAIe8nUEC8ri9UZgS4dzXAxHJXH7Tz4 mRDKqrobZW1kJiM/mW2Dx0q7HtRNLfQEdcE0WALnJAWm3KePTprDTOA+Uyjqdw== 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=1722469479; 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=4UGc9p0pF1H8oBKsydarNfNGv48ZiaoKQd9hMHvk0vo=; b=Drp8XVL91GWtc0ByhKUfC04xixivPrusnIeRntNNMOAAr8SS2TJi8BiPTGXMyeouP4sUtq 50q/+acTYPQLiB0vU9NypRGrK+WSFtzOYHHwThcc7qdFijwnfeyctmxGX47shMk7W0NUEN PmeoT8Cpr3mEW77vCMap6zmEUiS8LAFehTV9FPZ5f4Joi5VwoCKhyarHgQ9JnH7K6Bdut6 xs67rB4qybm8A9biRoo0sZG1w+Tp48f4f9URT2b4ySCgobOTqa4txhvsQ+rH07sKm9PFm4 v8Ii/R5X5LmO0n+ul2Wpgp/AKXSWuTfccsQfEa3lfkHgBJVxfZZPGB94rx5cdQ== 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 4WZ7x34TPdzLnr; Wed, 31 Jul 2024 23:44:39 +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 46VNidYM016960; Wed, 31 Jul 2024 23:44:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46VNidTN016957; Wed, 31 Jul 2024 23:44:39 GMT (envelope-from git) Date: Wed, 31 Jul 2024 23:44:39 GMT Message-Id: <202407312344.46VNidTN016957@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: b4fb947923b5 - main - bhyve: Escape binary data sent in reply packets List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: b4fb947923b566a3a8a6ad8e5f8ea8dec0c68ee4 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b4fb947923b566a3a8a6ad8e5f8ea8dec0c68ee4 commit b4fb947923b566a3a8a6ad8e5f8ea8dec0c68ee4 Author: Mark Johnston AuthorDate: 2024-07-31 22:41:13 +0000 Commit: Mark Johnston CommitDate: 2024-07-31 22:41:13 +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 --- 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 a13166e1e2c8..7c04b0017c80 100644 --- a/usr.sbin/bhyve/gdb.c +++ b/usr.sbin/bhyve/gdb.c @@ -651,6 +651,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) { @@ -1801,10 +1823,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);