From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796495269; b=WOWRePZDkIIchhXwi/FA2TPy0nq+kXQA+roI/j9Av7DlUC9CU3kpXxjklJf0G0uUPznq edBuptL46Sqw5dxV8reSb8jJJSlLTAwrLCS2apBND7+OESRyh43XUMoKnYLQL/CdX/y/U Z837nRAWF2XjHUgw8dLIq3OssA9XSp7GGeNSmbyvJ5ycjZrIFAiB1JsVq/OZNEfu3pEqK JSvQ3fJvcnwrtk8Dl12IMN42D99LdQisYAveoXo9VgUzmKI5pPCNCGV7rCe1GCJsxEFFQ 8qO+EJaNDE7GNi3neHhfSlx7AWPfL3+YPvCsTx+B7UAxMepqtJkjJOiHLW70AKiyz0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796495269; h=Received:DKIM-Signature:From:To:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=4d5H1zQWO+PzIRJrhVv1PCy5CQuh90vtVGEDVK3tGmM=; b=rcY0vuVbPgD8Js2dv9A4mumixNeq+PEyKHI4wt5AwPRgLiSo4IkLo2Fjtzi2N6XEu5e8 Dg7uVx3MbP37UBqik3OlhmK80+TC5cQ8qG90uniaXosYMfjyUfLbfDcGscUHncBjPLpsc rfuYu+6vh9Py+/iNX85QLR2WIuFPfpINYIUIl+IhEq/UF1ivYXVn4IBDDUgpt0XWFIZgo Qk5lpMJnXuW8mhf+WHnLJ/viTeMCz30QWWZN469G8tOEnN3et7zXWVTlItroSkMIw1M1o upt1w8za73z7X0Gravfqz6YYej7pA97iX7NvbkaoGw/UPPJrJrzLHklKoKxcGwrSpcQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hDoGIn8N; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFBC1606A31F for ; Sat, 5 Dec 2026 18:27:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hDoGIn8N Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0BEC1F00936 for ; Sat, 5 Dec 2026 18:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796495268; bh=4d5H1zQWO+PzIRJrhVv1PCy5CQuh90vtVGEDVK3tGmM=; h=From:To:Subject:Date:In-Reply-To:References; b=hDoGIn8N+xUE2maD6pmxX0rFtRBCvyWq9Qn2LUAqBxzrbF5h/kT6uwjz+WNDDcIFB nB7lvi5fPY7NrW17VKSb2N+2P5anIjdQ4hECEHO1Nx6S3PWVkwWpj63uhRKxOxGlLq +K5RhButVLdNKjnNoMhKr8x+KYbpiLt+8SfzJb0N6OduKH8DmVwTdPDiyhyGwNwoLR pix32WcDmwKg/+uePungK47cMccoitpcXY4/eoWdXMFr/EtPEKEUb0fTXEH8cXQTxK lXWwqGuF/cNST43itLTTQAtL2dtleh8RoT629nbmAm22wysu5WbIfDNJf8ocRhbK1R 2pmCILPbSYEvA== From: Chuck Lever To: Subject: [PATCH 7/8] tlshd: Escape certificate names before logging tag filter results Date: Sat, 5 Dec 2026 13:27:42 -0500 Message-ID: <20261205182743.79220-8-cel@kernel.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261205182743.79220-1-cel@kernel.org> References: <20261205182743.79220-1-cel@kernel.org> X-Mailing-List: kernel-tls-handshake@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When the debug loglevel is nonzero, the x.509 issuer and subject tag filters log the issuer or subject DN of the peer's certificate. Whoever created the certificate chose the names in both DNs. gnutls_x509_crt_get_dn3() and gnutls_x509_crt_get_issuer_dn3() can return a DN that contains a raw newline or escape character, and such a DN passes the UTF-8 check. A newline logged this way can make part of a name look like a separate log record. Pass each DN through g_strescape() before logging it. The filters still match against the unescaped DN. Non-ASCII characters in a logged name now appear as octal escapes, and the backslashes of RFC 4514 escaping appear doubled. Fixes: f11519ab4a45 ("tlshd: Match ingress certificates with defined TLS session tags") Signed-off-by: Chuck Lever --- src/tlshd/tags.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tlshd/tags.c b/src/tlshd/tags.c index 1863f4b34510..ed83062433b1 100644 --- a/src/tlshd/tags.c +++ b/src/tlshd/tags.c @@ -1505,6 +1505,7 @@ tlshd_tags_filter_type_match_x509_tbs_issuer(struct tlshd_tags_filter *filter, gnutls_x509_crt_t peercert; gnutls_datum_t dn; bool res = false; + gchar *desc; int ret; if (!tlshd_tags_get_peer_x509_cert(session, &peercert)) @@ -1530,10 +1531,12 @@ tlshd_tags_filter_type_match_x509_tbs_issuer(struct tlshd_tags_filter *filter, (const gchar *)dn.data, NULL); #endif + desc = g_strescape((const gchar *)dn.data, NULL); tlshd_log_debug("Filter '%s' %s issuer '%s'", filter->fi_name, res ? "matched" : "did not match", - dn.data); + desc); + g_free(desc); gnutls_free(dn.data); deinit: gnutls_x509_crt_deinit(peercert); @@ -1627,6 +1630,7 @@ tlshd_tags_filter_type_match_x509_tbs_subject(struct tlshd_tags_filter *filter, gnutls_x509_crt_t peercert; gnutls_datum_t dn; bool res = false; + gchar *desc; int ret; if (!tlshd_tags_get_peer_x509_cert(session, &peercert)) @@ -1652,10 +1656,12 @@ tlshd_tags_filter_type_match_x509_tbs_subject(struct tlshd_tags_filter *filter, (const gchar *)dn.data, NULL); #endif + desc = g_strescape((const gchar *)dn.data, NULL); tlshd_log_debug("Filter '%s' %s subject '%s'", filter->fi_name, res ? "matched" : "did not match", - dn.data); + desc); + g_free(desc); gnutls_free(dn.data); deinit: gnutls_x509_crt_deinit(peercert); -- 2.56.0