From patchwork Mon Sep 20 17:25:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 12506009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDA80C4332F for ; Mon, 20 Sep 2021 17:25:53 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81D00632D6 for ; Mon, 20 Sep 2021 17:25:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 81D00632D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191048.340919 (Exim 4.92) (envelope-from ) id 1mSN33-0004DJ-Ix; Mon, 20 Sep 2021 17:25:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191048.340919; Mon, 20 Sep 2021 17:25:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSN33-0004D6-F1; Mon, 20 Sep 2021 17:25:45 +0000 Received: by outflank-mailman (input) for mailman id 191048; Mon, 20 Sep 2021 17:25:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSN32-0003ck-Ip for xen-devel@lists.xenproject.org; Mon, 20 Sep 2021 17:25:44 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 86b3c526-b7fb-4aca-b34f-30ec78337ff1; Mon, 20 Sep 2021 17:25:38 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 86b3c526-b7fb-4aca-b34f-30ec78337ff1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1632158738; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zbv4TRtvbYbmEr6riLgsvffP+odFSfYHHa0VIndkMik=; b=czcX31EqGTGZ3IsHSbQkA8hJFnS9o8lBr4M9FKTRwp2kVz/bH9I6/m/N 0hy7rjE3067uXX1iO5UkLN1FNG/EIEwUuSPpxpPLkZvjayT9ifiJm9ksA aRM3u5gRHVm7HVc4xdLZmCgILOmkHpCjyUgFXQk5K1E306svtwZm8MNiH E=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 0Ea6ZAnbzQ6qbl6elFK2DEpm081owM6O7Abkn5hvmJwOYOeDTH+CNPorjHTYd6EOQMJ0fZQHE+ UAeoH5yOlXKzVBZ97qJUwcnKiBd3Tnz/DTmcUKq6Bxb0+YXeY+kHqQBJGv3bL9sewPuNaONJ2z 8Y9VTsI6lD1rypsBrIlMGMgXfl1qwwNHziUovvPyyNImCCXwVinTOZvqEkuBp5OG08PjTOuRRQ CNAnphP92Ln9cLBh1vu5Z5entE58H6vg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0s+ALySl X-IronPort-AV: E=Sophos;i="5.85,308,1624334400"; d="scan'208";a="53560991" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Dario Faggioli , Juergen Gross , Volodymyr Babchuk , Meng Xu Subject: [PATCH v2 00/12] xen/trace: Fix leakage of uninitialised stack into the tracebuffer Date: Mon, 20 Sep 2021 18:25:17 +0100 Message-ID: <20210920172529.24932-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Patches 1-3 fix bugs causing uninitialised stack to leak into the trace buffers. Xentrace is a developer/debugging activity restricted to fully privileged entities, so the leaking of uninitialised stack contents is not a security concern here. Patches 4 and 5 are cleanup worthy of backporting, because their knock-on effects in release builds. Patches 6 and later are cleanup and probably not for backporting. They convert all trace records to using fixed types, and move some PV-specifics to only be built for PV && TRACEBUFFER, and removing stub files from all architectures. I have yet more cleanup in progress making most of the macros disappear, but this series is getting long enough already, (and taking time I don't really have). Andrew Cooper (12): xen/trace: Don't over-read trace objects xen/memory: Remove tail padding from TRC_MEM_* records xen/credit2: Remove tail padding from TRC_CSCHED2_* records x86/hvm: Reduce stack usage from HVMTRACE_ND() x86/hvm: Remove duplicate calls caused by tracing xen/credit2: Clean up trace handling xen/rt: Clean up trace handling xen/sched: Clean up trace handling xen/trace: Minor code cleanup x86/pv: Move x86/trace.c to x86/pv/trace.c xen/arch: Drop asm-*/trace.h x86/trace: Clean up trace handling tools/xentrace/formats | 4 + tools/xentrace/xenalyze.c | 12 +- xen/arch/x86/Makefile | 1 - xen/arch/x86/hvm/hpet.c | 15 +- xen/arch/x86/hvm/hvm.c | 5 +- xen/arch/x86/hvm/svm/svm.c | 8 +- xen/arch/x86/hvm/vlapic.c | 23 ++- xen/arch/x86/hvm/vmx/vmx.c | 9 +- xen/arch/x86/hvm/vpic.c | 9 +- xen/arch/x86/irq.c | 4 +- xen/arch/x86/mm/p2m-pod.c | 17 +- xen/arch/x86/mm/p2m-pt.c | 6 +- xen/arch/x86/mm/shadow/multi.c | 2 +- xen/arch/x86/pv/Makefile | 1 + xen/arch/x86/pv/emul-inv-op.c | 2 +- xen/arch/x86/pv/emul-priv-op.c | 1 + xen/arch/x86/pv/ro-page-fault.c | 2 +- xen/arch/x86/pv/trace.c | 141 ++++++++++++++ xen/arch/x86/pv/traps.c | 2 +- xen/arch/x86/trace.c | 159 ---------------- xen/arch/x86/traps.c | 3 +- xen/common/memory.c | 4 +- xen/common/sched/core.c | 4 +- xen/common/sched/credit.c | 38 ++-- xen/common/sched/credit2.c | 344 +++++++++++++++++------------------ xen/common/sched/null.c | 42 +++-- xen/common/sched/rt.c | 121 ++++++------ xen/common/trace.c | 60 +++--- xen/include/asm-arm/trace.h | 12 -- xen/include/asm-x86/hvm/trace.h | 30 ++- xen/include/asm-x86/{ => pv}/trace.h | 8 +- xen/include/xen/trace.h | 13 +- 32 files changed, 537 insertions(+), 565 deletions(-) create mode 100644 xen/arch/x86/pv/trace.c delete mode 100644 xen/arch/x86/trace.c delete mode 100644 xen/include/asm-arm/trace.h rename xen/include/asm-x86/{ => pv}/trace.h (92%)