Received: by 10.223.185.116 with SMTP id b49csp2775666wrg; Mon, 5 Mar 2018 08:30:17 -0800 (PST) X-Google-Smtp-Source: AG47ELu22r4nLxKrPz8xsfC9CbL+hNzellTCaw3mCmzyecTraNzG5ekTRL2wEGvmq+ibCScg4n5e X-Received: by 10.101.92.6 with SMTP id u6mr12664738pgr.440.1520267417139; Mon, 05 Mar 2018 08:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520267417; cv=none; d=google.com; s=arc-20160816; b=HotmohShh5RHREhxgLNPtdJBhGokvFLWLea15G866h/y7YQ1Wd6jUPuHuygopKnCXN MMkoMLrPTOvvC/q5rP9uzksDsusQgj3W783A6MxAyRoTkGYcnAUbgUdHekmVy0mOo82K 85u4C91zTvirk/uG75OfnkIbR5EpJ9/8oaRIgV5qwicUWQeLgczNMgooIGGOqYvBAYxI oz66P6Zk5y28skalRE3Va0Jh37S50bGrIVfN/jfDwh2ZDlrp8qir2LA1AC6c4E/nHIVm UxHslD21HEnn3rkvwdmYahmAnmoKJU2Q7NYus9yn0yOC5oyhzccIx2LE6b/TPcgSrmd2 N0EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zC9RO6YKTDfUgXtirpMaWFDzNQewsxaU5ANGTOanNGo=; b=l+x7youBkU166qdNVgIVgbuyKYeRiwDjtcOePSIoRlLvIcofu+57fwa2xXqDNzpX4w kMxEZCO5WoyeNB6HeEzUDSIF/77lpk9/9soh9EOVA/SfhIyZlRKFU+2O2siPa2aCXwR0 ekSplvEl8KzhCVh09Zsn92kpjMWI9NmwR96fD4OVx0NU1MGm6/GzCRzUlhvcAagykURV YTYRe+g10DpYZ0hyyT1//09K99QY9VDq7xjgsZWuyVNGoJFDs3hiM4YIlZfZDhECmIGS zSegKW2ZieFLgSXgrL7j16Y8aO0NMdGvQ2xl6j5tKCFUZRr09G6RoPEIZ7PLXkgpo+PU Htgw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i124si7757490pgd.576.2018.03.05.08.30.02; Mon, 05 Mar 2018 08:30:17 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752942AbeCEQ2W (ORCPT + 99 others); Mon, 5 Mar 2018 11:28:22 -0500 Received: from mga05.intel.com ([192.55.52.43]:31637 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752623AbeCEQ0a (ORCPT ); Mon, 5 Mar 2018 11:26:30 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2018 08:26:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,427,1515484800"; d="scan'208";a="180031741" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 05 Mar 2018 08:26:24 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 6DA4F440; Mon, 5 Mar 2018 18:26:20 +0200 (EET) From: "Kirill A. Shutemov" To: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky Cc: Dave Hansen , Kai Huang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: [RFC, PATCH 12/22] mm: Do no merge vma with different encryption KeyIDs Date: Mon, 5 Mar 2018 19:26:00 +0300 Message-Id: <20180305162610.37510-13-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180305162610.37510-1-kirill.shutemov@linux.intel.com> References: <20180305162610.37510-1-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org VMAs with different KeyID do not mix together. Only VMAs with the same KeyID are compatible. Signed-off-by: Kirill A. Shutemov --- include/linux/mm.h | 7 +++++++ mm/mmap.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index bc7b32d0189b..7a4285f09c99 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1486,6 +1486,13 @@ static inline bool vma_is_encrypted(struct vm_area_struct *vma) } #endif +#ifndef vma_keyid +static inline int vma_keyid(struct vm_area_struct *vma) +{ + return 0; +} +#endif + #ifdef CONFIG_SHMEM /* * The vma_is_shmem is not inline because it is used only by slow diff --git a/mm/mmap.c b/mm/mmap.c index 9efdc021ad22..fa218d1c6bfa 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1208,7 +1208,8 @@ static int anon_vma_compatible(struct vm_area_struct *a, struct vm_area_struct * mpol_equal(vma_policy(a), vma_policy(b)) && a->vm_file == b->vm_file && !((a->vm_flags ^ b->vm_flags) & ~(VM_READ|VM_WRITE|VM_EXEC|VM_SOFTDIRTY)) && - b->vm_pgoff == a->vm_pgoff + ((b->vm_start - a->vm_start) >> PAGE_SHIFT); + b->vm_pgoff == a->vm_pgoff + ((b->vm_start - a->vm_start) >> PAGE_SHIFT) && + vma_keyid(a) == vma_keyid(b); } /* -- 2.16.1