Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1574943ybm; Thu, 23 May 2019 03:26:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqworoCFlM7vRby6WA2Ay9U/i3Em+rwKGOA9VxQHYC6vfP0OjO7xRM11qX2E/vaDsFHCt+fk X-Received: by 2002:a17:902:1347:: with SMTP id r7mr52796283ple.45.1558607180015; Thu, 23 May 2019 03:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558607180; cv=none; d=google.com; s=arc-20160816; b=j95kk2S4avnNCsX3HQiX1BRZQ6uzr8nutv3i0C02G3heHrVoZlwpAwdFyXjQw1Dlmo 9lfVVYITe1YDDT3RyWPJmo85afnZCvRO1MT1Ji389cURbWZP/6DGot3mpAwrnnCEqnbb 7/CnFrtLE3f140VHCo1MTwpsakpzDIuPOp23wVhfKyEaHm2R3H9n5U53xcdQW33efSoN 2sXT+kOXda0xGRPc5KiCOxkPQ39SjCF87k7pto6mi45XSRkurLh0qkMBOUHYeGd6/lPb sRlRyyRgaoxObavnM3rIzZ8mdFnDOYUYhZvBbA3Kw6o6wCsdjrm5nyFVtsz3pj3KI97s go/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=fiW/Nm+ZgvlOJ79FPiOXwL3L6V4oz5CApWACfhgzYV0=; b=l7ZPKDQ2CKQMAVm9fhyjA6j3yyxIFnNvMkL3Eu4hxN8wxTi8OJz2t521GP5TCDDk6d qqwp45mpz5PWeOFSmJHq+3ZMZlpFrydIf0P/cvrxoqgh97HfK/80RKQ8ZNgZdqfZcPCG cg7tWbKKhj4K0nSWlWPqtKQwFC/m+0euP7cWz2lZMdgrWSYCDjvzVtVUcQ6BSSd1rJac MfhKeNq2udVKfkJk4L+tedFtIDtFFdQlghvu8S+fi25+A+6ai6tnKhCmPIkVSG2i7fS+ SqIyzSdY4+Ghg9VJ4t3YWTzNIqwIw1F23VYzI+wqfYj4ih94tISdDzvnUkA+2wnAORW1 V33w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x28si32369216pfr.289.2019.05.23.03.26.04; Thu, 23 May 2019 03:26:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730493AbfEWKYh (ORCPT + 99 others); Thu, 23 May 2019 06:24:37 -0400 Received: from foss.arm.com ([217.140.101.70]:42688 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727434AbfEWKYg (ORCPT ); Thu, 23 May 2019 06:24:36 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 15B3BA78; Thu, 23 May 2019 03:24:36 -0700 (PDT) Received: from e111045-lin.cambridge.arm.com (unknown [10.1.39.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E8F623F718; Thu, 23 May 2019 03:24:33 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: marc.zyngier@arm.com, mark.rutland@arm.com, linux-kernel@vger.kernel.org, Ard Biesheuvel , Nadav Amit , Rick Edgecombe , Peter Zijlstra , Andrew Morton , Will Deacon , Masami Hiramatsu , James Morse Subject: [PATCH 3/4] arm64/kprobes: set VM_FLUSH_RESET_PERMS on kprobe instruction pages Date: Thu, 23 May 2019 11:22:55 +0100 Message-Id: <20190523102256.29168-4-ard.biesheuvel@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190523102256.29168-1-ard.biesheuvel@arm.com> References: <20190523102256.29168-1-ard.biesheuvel@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to avoid transient inconsistencies where freed code pages are remapped writable while stale TLB entries still exist on other cores, mark the kprobes text pages with the VM_FLUSH_RESET_PERMS attribute. This instructs the core vmalloc code not to defer the TLB flush when this region is unmapped and returned to the page allocator. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/probes/kprobes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index 2509fcb6d404..036cfbf9682a 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -131,8 +131,10 @@ void *alloc_insn_page(void) void *page; page = vmalloc_exec(PAGE_SIZE); - if (page) + if (page) { set_memory_ro((unsigned long)page, 1); + set_vm_flush_reset_perms(page); + } return page; } -- 2.17.1