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: 10672135 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 34A0D13BF for ; Wed, 7 Nov 2018 10:36:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 253732B7BC for ; Wed, 7 Nov 2018 10:36:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 190432B7CE; Wed, 7 Nov 2018 10:36:48 +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=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 52D1E2B7BC for ; Wed, 7 Nov 2018 10:36:47 +0000 (UTC) Received: (qmail 9916 invoked by uid 550); 7 Nov 2018 10:36:39 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 9825 invoked from network); 7 Nov 2018 10:36:39 -0000 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=CJzPaI+MAqFC7nsXe4xz0ks5gYUqo8FlRn0Ar5t6Uy/kAW+SUJaNS91zWhSNeeIKee 9KpDWLTr2OfkzJtO/AV2lN7so/YYQEvEG+wA9jGx/lSAGSDU6wpD0Th4V3Nec+hh/Ur3 SA8OqHBQNMHB8mzmXCnrnt3nVhoEACfx0mUez7B9WP3s093xreIqt/U2ja+NLoHzLh5u goxMlCGEDZZIRBJWE1Y6epVfzItEsTspTdJglsb8L2xezQhB5wPMFYQ6kwbw9ZvVLyaj uhViTXxqKWtbkL5ZcX0JJtDcH1KHWJ1cEnBy9muR09J2YBjnYnFmsgjQBzXJAzi8ecjJ 24nw== X-Gm-Message-State: AGRZ1gL3GbjWAApj9p2XMJHGbwgXg0l5w1bPalBQMeJEL2XMEkztzh5a eJdjdYo8nOoXDF0TbKeU+uT5BQ== 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) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: kernel-hardening@lists.openwall.com, keescook@chromium.org, labbott@redhat.com, will.deacon@arm.com, jannh@google.com, mark.rutland@arm.com, james.morse@arm.com, catalin.marinas@arm.com, Ard Biesheuvel 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-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); }