From patchwork Fri Apr 14 13:25:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 9681273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3920360132 for ; Fri, 14 Apr 2017 13:30:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A0E52864D for ; Fri, 14 Apr 2017 13:30:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DD3F28663; Fri, 14 Apr 2017 13:30:25 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A9DD32864D for ; Fri, 14 Apr 2017 13:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=kJ22EwQarWFB6BIZ+qCPpuVUT3wQXLLMuhqT/GbOZmc=; b=r/25+oZidGFcRX 43DlVZ2bpsJZHBuLoYteDG4feRebAYeZdBQxZsqtDxddYdDGB2xmzZlcYwtLUBcYjpqwHoMX5GzP6 nUQ/4wet7a7rOZ9HjtNe/M/M86fyUsaxgrNlYW3cPyTXifxgBHGiOf0U4Rpo59gmIz8IZGC7oU9Uq n7xihSijWCXEfvF0xW8qZ8VcsU+4/hb21+XiiOPywDpgV6x8Gek7Jl3B8ZVNqe2y4503AK4v/ve1j fsOG28VsGECe3CxtOROKy45xk5Nst6Mnirjq1j8rggUdwhgXYOL5MfNQRTooFXyOe4F4n6DVPZIft tJiujf5AeO8HdaJNmIYw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cz1Iu-0004nk-Ch; Fri, 14 Apr 2017 13:30:24 +0000 Received: from mail-ve1eur01on0139.outbound.protection.outlook.com ([104.47.1.139] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cz1Io-0003a5-JM for linux-arm-kernel@lists.infradead.org; Fri, 14 Apr 2017 13:30:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Qqd96kwXMHH+4mUWni8WS7wviLdbuYTV41SNv97694M=; b=PlL74f+T3OedWHBQFUtrqbenuMIHfiNJ07yLKmdOCtVJ6LeAfuMdC3hDOJvljTn7mvPI+0XAaVe8hfzS6s5c+KtkEat8DF3GU93j6xTdNgInMsGc4kSTNPpJ1pcCPF5FPpe7q7O42OFfXiNfgWQu1+SigeKvxPUDsc6nJZ3aHqY= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=virtuozzo.com; Received: from dsafonov.sw.ru (195.214.232.6) by VI1PR0801MB1743.eurprd08.prod.outlook.com (10.168.67.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Fri, 14 Apr 2017 13:29:52 +0000 From: Dmitry Safonov To: Subject: [PATCHv2] ARM32: Support mremap() for sigpage/vDSO Date: Fri, 14 Apr 2017 16:25:29 +0300 Message-ID: <20170414132529.8337-1-dsafonov@virtuozzo.com> X-Mailer: git-send-email 2.12.2 MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR0501CA0027.eurprd05.prod.outlook.com (10.168.78.141) To VI1PR0801MB1743.eurprd08.prod.outlook.com (10.168.67.21) X-MS-Office365-Filtering-Correlation-Id: f2c7523b-da68-44f1-ed88-08d4833a561b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:VI1PR0801MB1743; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1743; 3:R6Bpq3nxfYy8RFdpJCU11YJReYYyOasFHQoeaIY+3jE7HwF6w29lvKZvIFnPvI9tjybQj7ssQ2xmnPtn5Wb/VR0Hn/P+yMt9AlLBFi9fgsXnDAOEIDIPMeWBTNDJImWebiKqZCqI8tHGTmTamUTFwPkqgmQfaoPXlAMERa0JaTVE/sWrXApjAxDgmwPPty1SpDTBHY+sHdKxt7dMyZ8ch53a/g/scJGyB1CJXsqJNjrRDsBRInShYU1rByrriCYzRsEqb6Kltp6CUm1AQ2mGXsXRfBlm9K/PHaRAWuUAKWRTrppDMetjDjVS2sHKPpdVhNpVUC/f9PHx5yQBEpk8iw==; 25:mmz2z4chSf1oBWCkbebehXShLFSWXgCm0FVVkn2eKHoJcCR78Q9QCpL1a5ovT1+caNPP6kybfh2kw7PSl/HdqN37YbGjoL4ndwDR6PbIYa9JU4JHG9QWRCYMqb2qfU90hJyFGIi24XkvPiIHpxzyTR6QWCkGi/4nPs2yjYrH0tE9iaYEszC6YjtDonvK2E3IhKQcH2Z20avbI0aZHmNqJGtvQNkYnALtlIGY+wwCK9+aVz2SnundWh83DHcbm8nwXYLTFfHsKA88lCBz4SMLrXErT/7AsJcJEu2+vxxkxCWkwWDh3OKyzgNMtlfYH7yQzWYj+QI0DzMutISNHjkIynZg2bKij1aI5R5zaljH3dsVO7euWNph8T2CoXL8ZZ7rzWzLajWg0ARgh0DvPakU1ZXrjTGFoWoSpKbku/OKgDlwoENTOLjXo3fOC36yQtR6G87XW5zFi0xFqgwaasC+2Q== X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1743; 31:oeC9nfnbUwfd7/HjyIkhYbjzGRpepK5e5yrkjCQsgfyd9lJgW1n0M1Lik8ZS/ToBSi2h4zOF7LSGABrmocaq26CTAdeeH0JRQjf82j/P78IyTMbo0/T1Xd4kDZNCKRC+TcXuLwE9fjl/kr3ksPHfFM9Tq9595hKJC3k/A6bdBLbGu+4k2XkKudRlc068zbVYHEuFhtVbb/6Te2KiDefQN8Z4AeAcNMWWhbbm6YTgl0/lyeoo1NdyKzB0Y88aH3Dd; 20:by27muUs4gI1u73fIP8TtYZgKrJNHhMBqf3Prc82JdhHhaxyKljO4mF7LRhGy5q+00OReV+vk0fEATq26gG+Il7YaFs1aMdROj9MElqK5wMlePrKH6cGDAsy5qouV9I2TkPDRxCyGUwyK4Y8qxRZnLH7JjHkBFGISWp25YhmnnG0kXC0nAGyaVHOzRU7pE4aCk6Btofm5gDVw8R1Dbxr9dUJI4oPe+mTn9o8qogVy4vbUrThkVyPaZC4OBhQxesEgwxtpFv2LHodRamCVDhLiM1lUW3X45QaC6oXwC7eYRrQ+d8drOuarqPuw89zqji3DodkR6oljFloPK5hAWemaktPp2uVNPvxbA2XtVzuCR7B9mG14VuU7YHZCUzSTgcqyBci1wrDTZ6G1A418jNXJm7u+u2NXk8YZNfEu8TTO+I= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(258649278758335); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(20161123555025)(20161123564025)(20161123562025)(6072148); SRVR:VI1PR0801MB1743; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1743; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1743; 4:Viql2z+Omp70zGe5nvLucmnChUVA6NpE+cuSBhKF/+drZxwAZv6cTzssqEKm/B8ukyKL3QZGgEeVV8qCKRmQn3/1VfGWr4AqoEJD+gXnregjp9kdUzltPG5gzRf7rEXNMBwvE2qnEcIs+9yW2LzsEnmP2saPT1F/NxNzHkhMMvUld1U6wCXZO72R+TdZjsu9oiOKEweawMH1IIZVej/SuuTaVC3E6pLsUCDK/ujnmecktlH4nIvb4bOv8hx+VE9XGd23OE8h5UQUhNVK9zOBjPxVzhBerYGEhbAKufK4g1s3ukvcE1m1bZ1ks4b7E8BwOgZ7R8o8p//YtYGptfM/Kf4IYLMnia6hM16SgN8jKHPiKg5IveNZkbD9pC537Utjj02qAkqhGkmvdjwojZd/PnzwjtqQ9hWieOphQyupNWe3TO+Yg5lj6hb4LWCmezOJ0c3HAZBsY+dNR40dfzCzY/4n3idPynbmmEm0DQli6NdP8j8+6VchWkgiMu98QCdZ96IxNnl5lcVPUZxhcetE9/Lu8pmt8/13mZKltAAjqNEPrE+JjWo7PB0UqMNf2rw9Fp0YfQzHjTCav+dYeejp2VaMGFsxDoSsRhjFNIgSC3D1G+eSiK8vRiDMca37aouLLpgp75yXZNqdjrsf3VNWRG/xKHRm3m0t0NFHWPmF5BYn2WgElxsjn7N+0ZC47pD8TxpAmUf7r97SnPS8lfZHgFmVwS5K/+61DVGdyAfi1GWApiyZZyWT4yelIHnp9LtPSV9ZsfTzQ/dPMcOcZd5fbgAFl7Dn6m7k1i1P4JIf2Ow= X-Forefront-PRVS: 02778BF158 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39410400002)(39830400002)(39400400002)(39450400003)(25786009)(6506006)(50226002)(50466002)(81166006)(8676002)(6486002)(50986999)(53936002)(110136004)(5660300001)(2351001)(38730400002)(4326008)(54906002)(48376002)(6512007)(2906002)(6666003)(36756003)(33646002)(6916009)(1076002)(305945005)(5003940100001)(7736002)(42186005)(3846002)(53416004)(6116002)(47776003)(189998001)(86362001)(575784001)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0801MB1743; H:dsafonov.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1743; 23:9uKULbHP6Atm/yxkwMMEjDvJz4rkH+1q4EulQdq?= =?us-ascii?Q?FcAGG7ZMPs9jUmDyF4H7W4hzxCYB2iQKxX6PJSO/95uE9MMTr/NRZ1zxXeGA?= =?us-ascii?Q?HpZ7iA7lCwTGYuKANKtuUnKGkmotptLsZ5rtMuMVqTtYO6gldccW7N9SKjzm?= =?us-ascii?Q?f0GrcWlUHZUA1+kPVcfpgu4KXzEtHwS+JMAioIFE8AKNdZ7dDKyhqwFIGT9O?= =?us-ascii?Q?/Df4Y+k0Xh6Mex4fQ/n9oRKjokVkRZQtbc8QFE/g8fiMWOLb35pGc0ZtqDqe?= =?us-ascii?Q?S64uHtWDMhwARdWfz1Na/ELE1mzEl5hzx3V+UNJRTN/RLwOSNxGQk8pMXnAn?= =?us-ascii?Q?rOtgyO9qcb9brYN9Y0IjzkeIeYMKlScL97Shc6vcwSSeOUOzAdhurpIuMnY1?= =?us-ascii?Q?sGbOZwqbFyaHVC25OfqmwgV4G0dfF5+E4VpK94mJIW8j/fIPvZioxmY2rMKE?= =?us-ascii?Q?yMQYtq8uO8Q+FiR/vuG1+C4KyFwR8UPklgMRpZJoEdEFo/fX/XTtj3uXqUcz?= =?us-ascii?Q?WLsWWQ/ggvof4uEgBqbh0AQPrwoUTwkH/tM+fXwkXbVJmAk2ZRF5LVpclCuK?= =?us-ascii?Q?8qXFdZdPsz/f3uy78M5gftvtkeXvdlC01K7YOexxnwzX1+sdZDqhz6CaT6SH?= =?us-ascii?Q?4PBWmBwwKsOi25mD1g/DM5Ro2Xnl/OT782m8fQmWSjnpBf3WHKlWRFb/0nEn?= =?us-ascii?Q?KnfX3dqbErOz5BoWvenYQZA/ejDfuOr0u4BgEk6Ua82d1euNE8xdnzQgCerQ?= =?us-ascii?Q?LExotSLFRKJJDsdfqSL4+qMZdEVWFo+tDOYLwx7++uDH1WLRpbvyESmMLEUG?= =?us-ascii?Q?OJbDneMGHIcYhY41e/eernau1G2CUXdfUQi7uQEghAArp6cMDW9dlsuI3R1r?= =?us-ascii?Q?fqAjuKvF9w5H1kNsnIBknv9/re/ePnsVyHnY7f0z4Vn3krIAAo6Y1iU6IGwS?= =?us-ascii?Q?cNDllawuEabiPNp8ZhfPAm5BeiVi4CMmSaLAcHyZ4qWAJS0OkePqwwC3tE+c?= =?us-ascii?Q?50P0k3AnOW+1Gx8s+OtjVQGswG8hsF5OJ5BND2sKVik4cRA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1743; 6:7MiSe5mnNyOAKRkrGypsk16WqI2XqVphXIIJgnGcg9CMIeFRKTm7tKcfa7U8AbbuYE3h5XjASWFE7WGwsycZEQAbQc8SXFBLA+ra28apUZckH5luRPHZ4JoiFTwdYa3JlYVTp82vNv64eG8y2Au+ZJ4VvuYjcS5F3QSPHk0EyCQFhT9/PxFylZA9ty3cNgk9sS0f7bKMj7XaqVUH1ZYlSpejvCuvyd7yPhTGRvE0Ne0g7d1Rx+V47phpuNe28X50CF1XbCG2p+LSDblN6TTho7FJ5lZeElNawHh3BEbyGpdSBb/pb/f4GgV2JnCBk3NRbAFpu9C6qUKPKy8q47jm7uxRnqbgmZ191rDaa9JyFfPOizaldK3fYr/Sv7mbWSrB66IR9ZVqHsFdDgjSZoAdFVEXd0g+vGEr/9A8H2ZhwObDGGHvTdRj8mwtFRUCTPBwnvKcfUkkYqWxhOG9hAEy/w==; 5:Qo71TAnRq3V1fCQAKWRXKpitJcqPZIpfK5XBSawaSbPgsNXuS1NN+3lUwqdrFmKYiy5Rr4FDzaFjhxg5mxoma9qR2KC6H0/lqUQKaCx9WgU3ejxrH/jmCs3ZjuhzUOzOOL6JDwqu88ndRqAGZL62lg==; 24:bDRgNdLwN5T4Jn4hmob4CbLEfPJX36BzcPEYFFiiy/dDUgVBdDR6hibQMPxhqsRVsl9fQXOPVR+MUJnCDZc2hXtyk6yX8DtkSSP3SIopi4Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1743; 7:qH4mcGbQ97L8bUps7SKAfjTg9hMB17G9WzqEjtl654KCSVS/YeLPgBliMTXW/B9x08o10uLt8o9AXORv/FvTaJWDw398h5SaU1t42F9qi/fM6MU0We/LysMxntneSqqtFgdVpRP7mgMjQFm4L4SkQEsVOoS2oi8qiuW3ETylsDOBQM4l42sl6zZsMN7IbJIUUL1mfC8f/X7DswvRdQq3EX1EAGQLBBlfnnIpemoLeqanyawVo3RTaeFibaKz0RvRM0d3SNUOPIvtYoONiOJdbN8Aa+KHp2jNSRxw6ZIUf+RvXuMo1uL2Ezy0DLnxik2/hXQddOMaqRUhMGrye1KZlw==; 20:wVIHkpAU3larmS0WYiOjMNYqg0tUjGUYBiNQ84GVvSwgUQbuJ/YBl6lhmXSnSh4uJtoF6J4/0wk8AAWH+MO1IPiP0adCTIysVDA6riprRy2CEoDbdluxIV3Tii0mEFtKmmWqwPSaM7NjgEhH6ZeFlpeg2p1xK+bYL4XtvTXQB+Q= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2017 13:29:52.9264 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1743 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170414_063018_968565_28EE6462 X-CRM114-Status: GOOD ( 13.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Safonov , Will Deacon , Russell King , Andy Lutomirski , Christopher Covington , 0x7f454c46@gmail.com, Cyrill Gorcunov , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Pavel Emelyanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP CRIU restores application mappings on the same place where they were before Checkpoint. That means, that we need to move vDSO and sigpage during restore on exactly the same place where they were before C/R. Make mremap() code update mm->context.{sigpage,vdso} pointers during VMA move. Sigpage is used for landing after handling a signal - if the pointer is not updated during moving, the application might crash on any signal after mremap(). vDSO pointer on ARM32 is used only for setting auxv at this moment, update it during mremap() in case of future usage. Without those updates, current work of CRIU on ARM32 is not reliable. Historically, we error Checkpointing if we find vDSO page on ARM32 and suggest user to disable CONFIG_VDSO. But that's not correct - it goes from x86 where signal processing is ended in vDSO blob. For arm32 it's sigpage, which is not disabled with `CONFIG_VDSO=n'. Looks like C/R was working by luck - because userspace on ARM32 at this moment always sets SA_RESTORER. Cc: linux-arm-kernel@lists.infradead.org Cc: Russell King Cc: Will Deacon Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Cyrill Gorcunov Cc: Pavel Emelyanov Cc: Christopher Covington Signed-off-by: Dmitry Safonov Acked-by: Andy Lutomirski # For the x86 bit --- v2: (buildbot) Fix (unsinged long) to (void*) cast warning. arch/arm/kernel/process.c | 8 ++++++++ arch/arm/kernel/vdso.c | 18 ++++++++++++++++++ arch/x86/entry/vdso/vma.c | 3 --- mm/mmap.c | 4 ++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 939e8b58c59d..1e6039cac68d 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -404,9 +404,17 @@ static unsigned long sigpage_addr(const struct mm_struct *mm, static struct page *signal_page; extern struct page *get_signal_page(void); +static int sigpage_mremap(const struct vm_special_mapping *sm, + struct vm_area_struct *new_vma) +{ + current->mm->context.sigpage = new_vma->vm_start; + return 0; +} + static const struct vm_special_mapping sigpage_mapping = { .name = "[sigpage]", .pages = &signal_page, + .mremap = sigpage_mremap, }; int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c index 53cf86cf2d1a..a4d6dc0f2427 100644 --- a/arch/arm/kernel/vdso.c +++ b/arch/arm/kernel/vdso.c @@ -54,8 +54,26 @@ static const struct vm_special_mapping vdso_data_mapping = { .pages = &vdso_data_page, }; +static int vdso_mremap(const struct vm_special_mapping *sm, + struct vm_area_struct *new_vma) +{ + unsigned long new_size = new_vma->vm_end - new_vma->vm_start; + unsigned long vdso_size; + + /* without VVAR page */ + vdso_size = (vdso_total_pages - 1) << PAGE_SHIFT; + + if (vdso_size != new_size) + return -EINVAL; + + current->mm->context.vdso = new_vma->vm_start; + + return 0; +} + static struct vm_special_mapping vdso_text_mapping __ro_after_init = { .name = "[vdso]", + .mremap = vdso_mremap, }; struct elfinfo { diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 226ca70dc6bd..363730caa60e 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -77,9 +77,6 @@ static int vdso_mremap(const struct vm_special_mapping *sm, if (image->size != new_size) return -EINVAL; - if (WARN_ON_ONCE(current->mm != new_vma->vm_mm)) - return -EFAULT; - vdso_fix_landing(image, new_vma); current->mm->context.vdso = (void __user *)new_vma->vm_start; diff --git a/mm/mmap.c b/mm/mmap.c index bfbe8856d134..534aef99cfe9 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3152,8 +3152,12 @@ static int special_mapping_mremap(struct vm_area_struct *new_vma) { struct vm_special_mapping *sm = new_vma->vm_private_data; + if (WARN_ON_ONCE(current->mm != new_vma->vm_mm)) + return -EFAULT; + if (sm->mremap) return sm->mremap(sm, new_vma); + return 0; }