From patchwork Tue Nov 6 21:44:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10671473 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 D94D114BD for ; Tue, 6 Nov 2018 21:44:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD0432A8C6 for ; Tue, 6 Nov 2018 21:44:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B67662A96F; Tue, 6 Nov 2018 21:44:29 +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 E98802A938 for ; Tue, 6 Nov 2018 21:44:28 +0000 (UTC) Received: (qmail 1261 invoked by uid 550); 6 Nov 2018 21:44:23 -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 1187 invoked from network); 6 Nov 2018 21:44:22 -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=QpFd6L3nkCDR+PwgVvpKTB3J6pzF27CmO5ztwKAykYM=; b=LT9xJ6J5yT/P+jF+0gUS/VLtbODJ9B7or5gofh+BFAEGozyoiGH9lBMSjfCVlvXbrc mvF4qbmtUM+iRjT08uCfMy7agGYx7BmFq0MPM7ZPASgFtAXpQ0RWSjCraDl/BwyxWWgW 8Sc+pTlNajLVDeQCP8MvNRReUgGPXfHaE8lT8= 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=QpFd6L3nkCDR+PwgVvpKTB3J6pzF27CmO5ztwKAykYM=; b=Ap0UiO6WMUEus/ORvU5qWM+pZVjm+sn39DDDOoG5dqZ9D7KnT2oOgJHAyGfVDWdY2R /3ZY3l0fcJCz9/JoehNDc2EqWtXvpPpBZHiruaK6CRA6PIfFv688ildlS7LHRzd4LKJK m9VWrbzjVCt08sdoYyPBVDnoE+dZyoG4FuU/HXzDDs6t1mpGca9ERCPiUrrm3KAikqz3 yraequYG2re4xGZ3ce7U6fF828DmdqNqxI+x47UJzZwGaGS3Sb2ALToSViB77yl/N4nn 2kP25/GKWPweN4TEyKRLDgmdvOj5Yw0+eid0qeF1Eu3qMfxdJqIAMH79crPiqQ/p22ft 2L8A== X-Gm-Message-State: AGRZ1gIeJvwygP+fjZPu+x/Y4kuIcNKRbYd41hYh0aWVdncDPFCieNP7 B4nPxocdPVgZSeO5fmt6AHDMeA== X-Google-Smtp-Source: AJdET5cpMundl/EAvT00n3hMK1IxDtdErS/VONNK8yTZuyq+ZdZRQ9s9xSdrMCB2Jig6rFszyNokfg== X-Received: by 2002:a1c:a607:: with SMTP id p7-v6mr3283975wme.107.1541540651073; Tue, 06 Nov 2018 13:44:11 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: keescook@chromium.org, kernel-hardening@lists.openwall.com, 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 v3 1/2] arm64: mm: purge lazily unmapped vm regions before changing permissions Date: Tue, 6 Nov 2018 22:44:03 +0100 Message-Id: <20181106214404.2497-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181106214404.2497-1-ard.biesheuvel@linaro.org> References: <20181106214404.2497-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. Signed-off-by: Ard Biesheuvel Acked-by: Will Deacon --- 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..f8cf5bc1d1f8 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); }