From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 24B866B0033 for ; Thu, 14 Dec 2017 06:43:37 -0500 (EST) Received: by mail-pf0-f199.google.com with SMTP id m9so4505983pff.0 for ; Thu, 14 Dec 2017 03:43:37 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id c1si2802632pge.239.2017.12.14.03.43.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 03:43:35 -0800 (PST) Message-Id: <20171214113851.547977641@infradead.org> Date: Thu, 14 Dec 2017 12:27:35 +0100 From: Peter Zijlstra Subject: [PATCH v2 09/17] mm: Provide vm_special_mapping::close References: <20171214112726.742649793@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=mm--Provide-vm_special_mapping--close.patch Sender: owner-linux-mm@kvack.org List-ID: To: linux-kernel@vger.kernel.org, tglx@linutronix.de Cc: x86@kernel.org, Linus Torvalds , Andy Lutomirsky , Peter Zijlstra , Dave Hansen , Borislav Petkov , Greg KH , keescook@google.com, hughd@google.com, Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , aliguori@amazon.com, Will Deacon , linux-mm@kvack.org, kirill.shutemov@linux.intel.com, dan.j.williams@intel.com From: Peter Zijlstra Userspace can (malisiously) munmap() the VMAs injected into its memory map through install_special_mapping(). In order to ensure there are no hardware resources tied to the mapping, we need a close callback. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner --- include/linux/mm_types.h | 3 +++ mm/mmap.c | 4 ++++ 2 files changed, 7 insertions(+) --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -644,6 +644,9 @@ struct vm_special_mapping { int (*mremap)(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma); + + void (*close)(const struct vm_special_mapping *sm, + struct vm_area_struct *vma); }; enum tlb_flush_reason { --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3206,6 +3206,10 @@ static int special_mapping_fault(struct */ static void special_mapping_close(struct vm_area_struct *vma) { + struct vm_special_mapping *sm = vma->vm_private_data; + + if (sm->close) + sm->close(sm, vma); } static const char *special_mapping_name(struct vm_area_struct *vma) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org