Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2120086imm; Sat, 15 Sep 2018 09:35:19 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZYAff7U6zR1UMVFSO5q59TUh+ehDcH40OgqBHff81bZ/AE/LAVw6naNVgK+ibsitX/2fT5 X-Received: by 2002:a63:8b44:: with SMTP id j65-v6mr16950579pge.325.1537029319091; Sat, 15 Sep 2018 09:35:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537029319; cv=none; d=google.com; s=arc-20160816; b=X2rhv6LYjiENGMA7aoCI3EBE18xVpNgaJTalnSo2+aOCc9/Ps7+MyMMaIAd9fF/4zg sPOQTAyDFN9yKOwnwaW63iJol6ZaOUuuV+iXWsXobaeC6Vvo6ULSfGxvAKR2NG9/jejI Nku16/am64khK3ULzWdV8py8DP47Ca5XC8oYpNhJz7PousCWch5gdpK13MJFyrHWu/d+ NeuyzYo707E4YKeNbSujQwcsUn5W5bQZpealQIkNGQvcT5qjjS2eyFHUL4senmaJsq31 mRfR2c3M2D4lFEttezzRw+UYl844jYhwRHq8YaeQHFbRevJB3Lrme0gmkY/k4oiWBtIG qzbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject; bh=apwCu8bcW8ZzHHhvjThvgAikQbB/aKtAwSqUCwkFGVw=; b=QcNqFHbj1vImhaDLBXzYcz0jfSzg08IPlFUa/1JxTX4T0XOQ7oCBbO58xCC3I8MY5h zLb+eCZKJhepMCSQNtR23FNLsEszmwNQKk0lW89VKAz6PaUV6QwywqxiuzxXe0dkO1aW 5h7dTRxoqI9BTDGbM5gHgsRr/uRdSEDSr7M8UUKMBYCclAKfXzkohP1sVw16g4ojgeW+ EPPMOayJiOki30R4IM4rMeh9ZmjKSv4Ex3/EyomawtSEEJ4O8Ch6d61RMfw9PWFVCEcN F42UGOihHr/Whk86ZiyMv2qPXTJEC5EA7dPLkmYGXxcU6NjFnyAjK1pUhV8kXcm7P99Q uvwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z187-v6si9140547pgd.2.2018.09.15.09.34.49; Sat, 15 Sep 2018 09:35:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727946AbeIOVyS (ORCPT + 99 others); Sat, 15 Sep 2018 17:54:18 -0400 Received: from mga17.intel.com ([192.55.52.151]:55758 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727674AbeIOVyR (ORCPT ); Sat, 15 Sep 2018 17:54:17 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-)