From patchwork Mon May 6 12:46:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eslam Elnikety X-Patchwork-Id: 10931003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58DDF92A for ; Mon, 6 May 2019 12:49:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 468A8285C6 for ; Mon, 6 May 2019 12:49:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A269285E3; Mon, 6 May 2019 12:49:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D361F285C6 for ; Mon, 6 May 2019 12:49:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNd10-0007A0-EQ; Mon, 06 May 2019 12:46:42 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNd0z-00079v-8p for xen-devel@lists.xenproject.org; Mon, 06 May 2019 12:46:41 +0000 X-Inumbo-ID: fa158b12-6ffc-11e9-add5-53dc52203767 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id fa158b12-6ffc-11e9-add5-53dc52203767; Mon, 06 May 2019 12:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1557146794; x=1588682794; h=from:to:cc:subject:date:message-id:mime-version; bh=dSLHyPzAMbnbdtyI/v3Kdo/lD2dWh3pn9p4uGEuUl0s=; b=jc6QVni4pQ848gC+6ry+Waa7beq+ebY2dt5BIDaFT+qyXfhvndA5wV0R HDSvWw4+0efnaIDRd86VLAXhjgyUMa3ItgHikKpB4BjwbToEt8qt8QCji PEmVvJ7vETGjlJa4U596m10QYkmfFA8G4dM2ipLTNRgIcsnpGJbWYMcSH M=; X-IronPort-AV: E=Sophos;i="5.60,437,1549929600"; d="scan'208";a="764923419" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-8549039f.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 May 2019 12:46:31 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2a-8549039f.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id x46CkQfT062600 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Mon, 6 May 2019 12:46:29 GMT Received: from EX13D03EUA003.ant.amazon.com (10.43.165.89) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 6 May 2019 12:46:28 +0000 Received: from EX13MTAUEB001.ant.amazon.com (10.43.60.96) by EX13D03EUA003.ant.amazon.com (10.43.165.89) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 6 May 2019 12:46:27 +0000 Received: from dev-dsk-elnikety-1c-28a13cba.eu-west-1.amazon.com (10.15.5.186) by mail-relay.amazon.com (10.43.60.129) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 6 May 2019 12:46:27 +0000 Received: by dev-dsk-elnikety-1c-28a13cba.eu-west-1.amazon.com (Postfix, from userid 6438462) id DB5284634E; Mon, 6 May 2019 12:46:26 +0000 (UTC) From: Eslam Elnikety To: Date: Mon, 6 May 2019 12:46:24 +0000 Message-ID: <20190506124624.54454-1-elnikety@amazon.com> X-Mailer: git-send-email 2.15.3.AMZN MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH] mm: option to _always_ scrub freed domheap pages X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Eslam Elnikety , Tim Deegan , Julien Grall , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Give the administrator further control on when to scrub domheap pages by adding an option to always scrub. This is a safety feature that, when enabled, prevents a (buggy) domain from leaking secrets if it accidentally frees a page without proper scrubbing. Signed-off-by: Eslam Elnikety Acked-by: George Dunlap --- docs/misc/xen-command-line.pandoc | 8 ++++++++ xen/common/page_alloc.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 7dcb22932a..5a92949c5a 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -270,6 +270,14 @@ and not running softirqs. Reduce this if softirqs are not being run frequently enough. Setting this to a high value may cause boot failure, particularly if the NMI watchdog is also enabled. +### scrub_domheap +> `= ` + +> Default: `false` + +Scrub domains' freed pages. This is a safety net against a (buggy) domain +accidentally leaking secrets by releasing pages without proper sanitization. + ### clocksource (x86) > `= pit | hpet | acpi | tsc` diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index be44158033..678a00ac9b 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -214,6 +214,12 @@ custom_param("bootscrub", parse_bootscrub_param); static unsigned long __initdata opt_bootscrub_chunk = MB(128); size_param("bootscrub_chunk", opt_bootscrub_chunk); +/* + * scrub_domheap -> Domheap pages are scrubbed when freed + */ +static bool_t opt_scrub_domheap = 0; +boolean_param("scrub_domheap", opt_scrub_domheap); + #ifdef CONFIG_SCRUB_DEBUG static bool __read_mostly scrub_debug; #else @@ -2378,9 +2384,10 @@ void free_domheap_pages(struct page_info *pg, unsigned int order) /* * Normally we expect a domain to clear pages before freeing them, * if it cares about the secrecy of their contents. However, after - * a domain has died we assume responsibility for erasure. + * a domain has died we assume responsibility for erasure. We do + * scrub regardless if option scrub_domheap is set. */ - scrub = d->is_dying || scrub_debug; + scrub = d->is_dying || scrub_debug || opt_scrub_domheap; } else {