From patchwork Wed Nov 7 10:36:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10672137 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 8978A13A4 for ; Wed, 7 Nov 2018 10:36:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74F462B7C4 for ; Wed, 7 Nov 2018 10:36:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6615F2B7BC; Wed, 7 Nov 2018 10:36:50 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 198362B7BC for ; Wed, 7 Nov 2018 10:36:49 +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:References:In-Reply-To: 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: List-Owner; bh=yFB5I+7Qs/S+sjSQkBLgqu+Y5WZuj9tL+yVnniwjUUc=; b=c6z3qGNnlPs4MH rC9VAE2+R3Z1Bj0lO5jwgYC1opSHBSq3Y4c8DmRHvTOtqxeWPAqE6c8gFYaKrQzGKXgu/cG9T8KeJ 3rVTjZhHU1rYXB6myjz9xFStd0oWSTmfcLS65ogxU0Vnlz0XsDE5SkbozyjACIYx3rKFtY7NIH/H6 HN7GfskEFnDr7W2W2SJB05hdL5xg/jrqdivtasDw3LPNUCJuuOT7R5hL1r2xmxekM8VkPOcRgWn+s /fJUoq5dvAk1KNA2/IkTnqhZYf6dUxrXdUQwK6jwOA5sN7z2ZVqMCh1YhRWn/Aor0d2n6DVQzrtQF +ERH9YwFfjIF2uDhB9Ww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKLCa-00078V-9O; Wed, 07 Nov 2018 10:36:48 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKLCR-0006zx-CC for linux-arm-kernel@lists.infradead.org; Wed, 07 Nov 2018 10:36:40 +0000 Received: by mail-wr1-x442.google.com with SMTP id z16-v6so16835310wrv.2 for ; Wed, 07 Nov 2018 02:36:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U7OEJlVhIZDISv9Zi2qsSLfjSJ1jD2lTvAoXgGG2pP0=; b=VYQRSTzGuG8Iu4ZIPw0xOybhxgCxhUT1ljVkHkVEKfDttG3aXlw2rijGgBf56dM8Rk eQdkCMXeLoS7Go6LlNqx0J2wvwS9HuBsqi1mGxChKMDd35DuDKuM6isJg0gLwI+Ce6Mk qmz8XyDdyQHpVyLfHMeQWrhekSno9GhK/4gAA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U7OEJlVhIZDISv9Zi2qsSLfjSJ1jD2lTvAoXgGG2pP0=; b=Jm6J9ZUvv3pqzQG9Ype89ACX3MWfwz+CaexREXbzWaI/O11Mqno5SJaDcdkusWGETC DQccbFs5CORufBcdvDU1ckubXAcvyXgw1Syyx7RLQmUXKLlwmTkBKycowrAJPxazT0Cj M6JjACjEAaWDtIPI8MYRn3aKH4s/crpROillfmEr5fDtmT0hh+ysJBJZujUZRRUvgc5M Img90jddkvjB/iJz6/KF2DoR4Oy4D0c9GMU60hGZVwgV846S9M26dtRJ3/87XO4DTnKT PBdyrimE7ZzAeaTu+K+z05c7ii2RkQ5B17QZCClwoTaI4zE7ZUtfrj1VOQLiFXShWKMC TcWA== X-Gm-Message-State: AGRZ1gIePqQoFSZFpmGAvDDZaQoNjguK/7kGc/KfwCtlIO4dD1ZdKgcY 8peX1jwX2la11/tmbZmUKQLQVJzHsjY= X-Google-Smtp-Source: AJdET5dF0virhes/qmJKHM2Ikdp1l/ExRtBxLheh/qDuP/2yfhFZ37qoK4GY3IbdGdM94ZWH/fE3UQ== X-Received: by 2002:adf:d1c6:: with SMTP id m6-v6mr1338695wri.138.1541586987637; Wed, 07 Nov 2018 02:36:27 -0800 (PST) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id o9-v6sm346648wra.42.2018.11.07.02.36.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 02:36:26 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 1/2] arm64: mm: purge lazily unmapped vm regions before changing permissions Date: Wed, 7 Nov 2018 11:36:19 +0100 Message-Id: <20181107103620.16054-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181107103620.16054-1-ard.biesheuvel@linaro.org> References: <20181107103620.16054-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181107_023639_408781_D4D43F25 X-CRM114-Status: GOOD ( 11.63 ) 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: mark.rutland@arm.com, Ard Biesheuvel , keescook@chromium.org, jannh@google.com, catalin.marinas@arm.com, kernel-hardening@lists.openwall.com, will.deacon@arm.com, james.morse@arm.com, labbott@redhat.com 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 Call vm_unmap_aliases() every time we apply any changes to permission attributes of mappings in the vmalloc region. This avoids any potential issues resulting from lingering writable or executable aliases of mappings that should be read-only or non-executable, respectively. Acked-by: Will Deacon Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/pageattr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c index a56359373d8b..787f9e385e6d 100644 --- a/arch/arm64/mm/pageattr.c +++ b/arch/arm64/mm/pageattr.c @@ -93,6 +93,12 @@ static int change_memory_common(unsigned long addr, int numpages, if (!numpages) return 0; + /* + * Get rid of potentially aliasing lazily unmapped vm areas that may + * have permissions set that deviate from the ones we are setting here. + */ + vm_unmap_aliases(); + return __change_memory_common(start, size, set_mask, clear_mask); }