From patchwork Sat Sep 15 16:23:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10601549 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 2F3DF112B for ; Sat, 15 Sep 2018 16:34:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 112812A9D9 for ; Sat, 15 Sep 2018 16:34:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 024E92AA08; Sat, 15 Sep 2018 16:34:49 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85A052A9D9 for ; Sat, 15 Sep 2018 16:34:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 105DD8E0002; Sat, 15 Sep 2018 12:34:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 08E6C8E0001; Sat, 15 Sep 2018 12:34:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E991D8E0002; Sat, 15 Sep 2018 12:34:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id A81AD8E0001 for ; Sat, 15 Sep 2018 12:34:47 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id x2-v6so5158768pgp.4 for ; Sat, 15 Sep 2018 09:34:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:user-agent:mime-version :content-transfer-encoding; bh=apwCu8bcW8ZzHHhvjThvgAikQbB/aKtAwSqUCwkFGVw=; b=hqSz4jO81Ax9SxrDWq91p7XSvLYjR/iZnoocn11ME1xGx+Bwmn/qNFXinALi8LVkFP aPg8A0DxGwb9K6NM3xMTW1p0kARwNUsE5Nm0JZFGlPamhuGZWTt3+91lkmUjWljtC+B6 qIJMmXMTNE0OeIbDds+h864BGpey8743wKSZSHRh2mTd7DFSO55U7ZG3fP3FzmCPMy/J PqOuVN2mBcEJH3WTZQnAMgTfSixiWS2C/sWlXdFruZgMYgwXqxvRQz70bVBC/6TxmU/z DxudD5Rep8Bv92BVDGMxq5/W4P3wurT2CFVtLopu76MljQN70R4tZE2Oy6hrun/1rg6E QymQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APzg51ANxXz1soFG3jkMlYivw2pAHfQyhhuOiiDUUxnr4Ays3UZD6Zo6 YOovskFW4jnMbWfLr5hV3IIFF+A8JH3qdmN9D8bC8N66CSXJY1Hr+nDx/LT3UI23s5lf2CaJshd XXVNvvYWX8u/7akO+75KOoOH8Bl0oQUQg47OoEeYoaJYb3fSXjcZgQvZ5EqenNgFEyg== X-Received: by 2002:a63:f966:: with SMTP id q38-v6mr16230134pgk.213.1537029287253; Sat, 15 Sep 2018 09:34:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaBUQI+l0eL4M53eOZK1GuyRNwm8SZ6sM9393vDVn3plb6N/xaVpzIn9llmqoAcMTim+buJ X-Received: by 2002:a63:f966:: with SMTP id q38-v6mr16230098pgk.213.1537029286158; Sat, 15 Sep 2018 09:34:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537029286; cv=none; d=google.com; s=arc-20160816; b=aPRvQBIyW3PhIAJFFtCu21zjLfWupzfI1i6HMhcZvt40EuQ80rCQ88hFqFhOQIoJ9X AzWIhYDgWfrFyA0gb67XATbBu710MPn+0PLHShY1MCPDSP0BSP1KUmEbeLTGE4l+taLG HAAwHzJ+uqJlhcDje6CdPV+4GpZG2Qz/fr7k0UWw/73DWmBSiWx1caWTt0UHxSjU3Rwu /W8yqOry7y7LZGNOwVrh7rzaBzA9nKVdPQA3xsLGVIAgie0CXayosHX3ZunEZSQyTP+f TWX1aZIi0/vfXhQc0jIUtWKnavVmkK6QrI4hhjqfAmy1NgIgfMCftSnjqXJT/8b1nWje UNlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:message-id:date :cc:to:from:subject; bh=apwCu8bcW8ZzHHhvjThvgAikQbB/aKtAwSqUCwkFGVw=; b=rYSA8D0tdpCOTMJ7zJu04US9v6O2SR32hQ7XPSOxxNPRe7qKnSK6m0lW069bDmduRH YaKyMQXbwee5ssOiH02x+K+6McNmB8WbWiG8f3mH4hmT5CZ2NoACE2SmtJc+BiobFUwT yMAMlC4jJdX0SMzdV4bRJt7JSw0A0E6uGdV/VMw50Iec6bN8SAgJk//i8Mdb1yC6dE5+ q2pxEDMb7VD2jHGcZMi3UAoByU3xeNimIcIv3X7+jvJfM5k8g+WOk+Dy5ieNGJScMPoH Iv9Xmk3VlMQZtw6DDxxjpnt5yXAdY+qiISpwzuB9aUDT6kWppqLo4ZNcvvrKHNXDP0Jw NVTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga06.intel.com (mga06.intel.com. [134.134.136.31]) by mx.google.com with ESMTPS id u10-v6si9862703plr.58.2018.09.15.09.34.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Sep 2018 09:34:46 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.31 as permitted sender) client-ip=134.134.136.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Sep 2018 09:34:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,377,1531810800"; d="scan'208";a="80702375" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by FMSMGA003.fm.intel.com with ESMTP; 15 Sep 2018 09:34:44 -0700 Subject: [PATCH 0/3] mm: Randomize free memory From: Dan Williams To: akpm@linux-foundation.org Cc: Michal Hocko , Dave Hansen , Kees Cook , linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Sat, 15 Sep 2018 09:23:02 -0700 Message-ID: <153702858249.1603922.12913911825267831671.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Data exfiltration attacks via speculative execution and return-oriented-programming attacks rely on the ability to infer the location of sensitive data objects. The kernel page allocator, has predictable first-in-first-out behavior for physical pages. Pages are freed in physical address order when first onlined. There are also mechanisms like CMA that can free large contiguous areas at once increasing the predictability of allocations in physical memory. In addition to the security implications this randomization also stabilizes the average performance of direct-mapped memory-side caches. This includes memory-side caches like the one on the Knights Landing processor and those generally described by the ACPI HMAT (Heterogeneous Memory Attributes Table [1]). Cache conflicts are spread over a random distribution rather than localized. Given the performance sensitivity of the page allocator this randomization is only performed for MAX_ORDER (4MB by default) pages. A kernel parameter, page_alloc.shuffle_page_order, is included to change the page size where randomization occurs. [1]: See ACPI 6.2 Section 5.2.27.5 Memory Side Cache Information Structure --- Dan Williams (3): mm: Shuffle initial free memory mm: Move buddy list manipulations into helpers mm: Maintain randomization of page free lists include/linux/list.h | 17 +++ include/linux/mm.h | 5 - include/linux/mm_types.h | 3 + include/linux/mmzone.h | 57 ++++++++++ mm/bootmem.c | 9 +- mm/compaction.c | 4 - mm/nobootmem.c | 7 + mm/page_alloc.c | 267 +++++++++++++++++++++++++++++++++++++++------- 8 files changed, 317 insertions(+), 52 deletions(-)