From patchwork Tue Nov 13 05:51:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 150903 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4005982ljp; Mon, 12 Nov 2018 21:51:58 -0800 (PST) X-Google-Smtp-Source: AJdET5f5i171dTx0mVkBzZH4aFkP722Hm6k21trJF8eMGWnezWED7aUO3KFsIAyPvSMcfBzubEtv X-Received: by 2002:a17:902:4c08:: with SMTP id a8-v6mr3740218ple.211.1542088318165; Mon, 12 Nov 2018 21:51:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542088318; cv=none; d=google.com; s=arc-20160816; b=C7uVznciRN7S5PirrOM5NP2EMYuPnaDPL2lVHzQHLeeX4ifiM2Pmx86Rx9g6SvjeF0 n4WQJXd0li0P3lImh6ViCHzfEepD822dkwQqEuY5ZtYj0JnZ37FZ8L2EUOun47MilKqo IPVV3eMlLmo/YBNC4wncn/Jyv1KBBtTXWjhwcVuQf1TheydHZ9jJ7v1RgkaULogGsJE2 EvcwmgHnav8nXv+KjMGivPQB+zWo3uPjziO9ylroIfnWF8DKAiDF67EKx19li7SvDYtZ gi5adc3SOmFrKMWDYilD0wpFtzP9HrL98uNcXu4CODkN8zONyYApwo0QL9RoZCuTd1Pl MtJQ== 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:dkim-signature; bh=V/Hf14E0djH/YjlBaULDxruH4V0FZx8Jz6lHdToWTPA=; b=Y+pNFQ0hQb9pILwY6Y7mttEuu08GoxkgcNz0T9jJdSr0SC7+Zx+W/9YoDDVUDMQEAd 9Vm7Du0aRDm1xOmKfETbMrjEGsuaZvsO91wD4l6NYONSKbv/I0IsEPmPqPRijChGMAgu zaIT2iw9Pu9L+MzRnC7qHOK4pZ8ZX3D6JQFf1r50avbxv2F86hI5L6s65j4U111giFTl 9VwYqVaw4BkUX8u5IH2DHDZLyF2WWp1OKvRgYZx8DjJEoNNYgc7WmDMwMOZeXkrTlwF3 hHAIv7CFzYMUegIus4F0bVZhf2x7eWRhJRjzcjNwOQ1UJo6vSFlyhXbnmgq8YsxzrDhc mU7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=onMEqoKK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 91-v6si20305107plc.409.2018.11.12.21.51.57; Mon, 12 Nov 2018 21:51:58 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=onMEqoKK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732546AbeKMPsW (ORCPT + 32 others); Tue, 13 Nov 2018 10:48:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:34630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732472AbeKMPsV (ORCPT ); Tue, 13 Nov 2018 10:48:21 -0500 Received: from sasha-vm.mshome.net (unknown [64.114.255.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1D51422510; Tue, 13 Nov 2018 05:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542088313; bh=kZJk8KKkOauxqg+TWbC34UDWKPQkg+YfNvw813Q4f7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=onMEqoKK5gHAQCYoRCdmfG3X67nvH4ULfjaI+Cl7/cpG6mqLjEe6lcdstpSdgDA+I lNvw0cnrMQKcNHYExc77WV1VfrDqUH66f+dIFWKoc4F9VyQX08XbL8bF2/faO2RngB 4BZ8/Xn3eZvEZNbp0wxBmd2HCX5YhNJuSF7zKFtA= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Anders Roxell , Catalin Marinas , Sasha Levin Subject: [PATCH AUTOSEL 4.14 04/26] arm64: kprobe: make page to RO mode when allocate it Date: Tue, 13 Nov 2018 00:51:28 -0500 Message-Id: <20181113055150.78773-4-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181113055150.78773-1-sashal@kernel.org> References: <20181113055150.78773-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anders Roxell [ Upstream commit 966866892cf89d606544bca22d584ba2ef9ec208 ] Commit 1404d6f13e47 ("arm64: dump: Add checking for writable and exectuable pages") has successfully identified code that leaves a page with W+X permissions. [ 3.245140] arm64/mm: Found insecure W+X mapping at address (____ptrval____)/0xffff000000d90000 [ 3.245771] WARNING: CPU: 0 PID: 1 at ../arch/arm64/mm/dump.c:232 note_page+0x410/0x420 [ 3.246141] Modules linked in: [ 3.246653] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.0-rc5-next-20180928-00001-ge70ae259b853-dirty #62 [ 3.247008] Hardware name: linux,dummy-virt (DT) [ 3.247347] pstate: 80000005 (Nzcv daif -PAN -UAO) [ 3.247623] pc : note_page+0x410/0x420 [ 3.247898] lr : note_page+0x410/0x420 [ 3.248071] sp : ffff00000804bcd0 [ 3.248254] x29: ffff00000804bcd0 x28: ffff000009274000 [ 3.248578] x27: ffff00000921a000 x26: ffff80007dfff000 [ 3.248845] x25: ffff0000093f5000 x24: ffff000009526f6a [ 3.249109] x23: 0000000000000004 x22: ffff000000d91000 [ 3.249396] x21: ffff000000d90000 x20: 0000000000000000 [ 3.249661] x19: ffff00000804bde8 x18: 0000000000000400 [ 3.249924] x17: 0000000000000000 x16: 0000000000000000 [ 3.250271] x15: ffffffffffffffff x14: 295f5f5f5f6c6176 [ 3.250594] x13: 7274705f5f5f5f28 x12: 2073736572646461 [ 3.250941] x11: 20746120676e6970 x10: 70616d20582b5720 [ 3.251252] x9 : 6572756365736e69 x8 : 3039643030303030 [ 3.251519] x7 : 306666666678302f x6 : ffff0000095467b2 [ 3.251802] x5 : 0000000000000000 x4 : 0000000000000000 [ 3.252060] x3 : 0000000000000000 x2 : ffffffffffffffff [ 3.252323] x1 : 4d151327adc50b00 x0 : 0000000000000000 [ 3.252664] Call trace: [ 3.252953] note_page+0x410/0x420 [ 3.253186] walk_pgd+0x12c/0x238 [ 3.253417] ptdump_check_wx+0x68/0xf8 [ 3.253637] mark_rodata_ro+0x68/0x98 [ 3.253847] kernel_init+0x38/0x160 [ 3.254103] ret_from_fork+0x10/0x18 kprobes allocates a writable executable page with module_alloc() in order to store executable code. Reworked to that when allocate a page it sets mode RO. Inspired by commit 63fef14fc98a ("kprobes/x86: Make insn buffer always ROX and use text_poke()"). Suggested-by: Arnd Bergmann Suggested-by: Ard Biesheuvel Acked-by: Will Deacon Acked-by: Masami Hiramatsu Reviewed-by: Laura Abbott Signed-off-by: Anders Roxell [catalin.marinas@arm.com: removed unnecessary casts] Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin --- arch/arm64/kernel/probes/kprobes.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index 22a5921562c7..0417c929d21a 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -23,7 +23,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -42,10 +44,21 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); static void __kprobes post_kprobe_handler(struct kprobe_ctlblk *, struct pt_regs *); +static int __kprobes patch_text(kprobe_opcode_t *addr, u32 opcode) +{ + void *addrs[1]; + u32 insns[1]; + + addrs[0] = addr; + insns[0] = opcode; + + return aarch64_insn_patch_text(addrs, insns, 1); +} + static void __kprobes arch_prepare_ss_slot(struct kprobe *p) { /* prepare insn slot */ - p->ainsn.api.insn[0] = cpu_to_le32(p->opcode); + patch_text(p->ainsn.api.insn, p->opcode); flush_icache_range((uintptr_t) (p->ainsn.api.insn), (uintptr_t) (p->ainsn.api.insn) + @@ -118,15 +131,15 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) return 0; } -static int __kprobes patch_text(kprobe_opcode_t *addr, u32 opcode) +void *alloc_insn_page(void) { - void *addrs[1]; - u32 insns[1]; + void *page; - addrs[0] = (void *)addr; - insns[0] = (u32)opcode; + page = vmalloc_exec(PAGE_SIZE); + if (page) + set_memory_ro((unsigned long)page, 1); - return aarch64_insn_patch_text(addrs, insns, 1); + return page; } /* arm kprobe: install breakpoint in text */ From patchwork Tue Nov 13 05:51:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 150916 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4009675ljp; Mon, 12 Nov 2018 21:56:55 -0800 (PST) X-Google-Smtp-Source: AJdET5dZQDJyvcLwAFQ1txvIJ80KhicoYpq5QJ9aSa9chfCC/ihx3sP/pEQuhUckZsZabAaNYVtb X-Received: by 2002:a17:902:7281:: with SMTP id d1-v6mr3733148pll.284.1542088615282; Mon, 12 Nov 2018 21:56:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542088615; cv=none; d=google.com; s=arc-20160816; b=UuEi5yxd0l4bLvmofvy8BhZtIUqkKYuClxtJU4hZtZrEdQpNOBTqdLYXkuGeJoamhn zR/I8NDkX8VhLUYxdTnTxUhWlTu+l37lDCbVCm3mmQ2ImXQIJ1hTItSuSaLk2Tl5jT56 abTTEluLs5NNs6Ygs5T8OWkz9EgjjUtlkzrB27YhecvZzxqFaCKdynyvL6eIBa6h4ZB0 DRNTOB3r3t9HmcnGVjl3zemCceepmZUBxdEtndpIarDVSwjZsttZYkfxxh6tPS0TfeP2 fs3W0GG1+V00WjB7C7kcOLcwB2tcHfe9D/E3A09rxvewanpmY/sbVyvO4CDrcx9CBNbh ztoQ== 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:dkim-signature; bh=KYMhOHolvSD+PVibd4OvsM5VTx1Pc/xcdG/vM9qmx7c=; b=hod0UL2Pdq9SpRUx0o7YQ9Uh0RrXZXX9JyT57qXAwN72FvXsV68U741Il1GCRrR+Lw XVvuNYgmAsQwxacoyH93hkUx/LVVMaYf98TSpzy9AGlAcp1f+WP1CJplr9/jVvrjhxXg IOzRfhOfQ2Me91MTR4i7zakNIt2E18tt+DZSB+aqi9DRALaiIm4ZoYBOxfWi9OLLnewP cGR25hSDUsl+bxbcsW/GhKGD4QnQacs8ZsOk+O8HOLsXoVAuQfOeNF8u+HaQ4Bv7HkwO KCyrlJW9OEo/E3rxcObN/sXwWjZ71Gu+CTav+4j3pJJx7K1jkTOTkEolUVHH85YXPxz/ v3aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eMWhUnKT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si1986885pll.58.2018.11.12.21.56.55; Mon, 12 Nov 2018 21:56:55 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=eMWhUnKT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732712AbeKMPsk (ORCPT + 32 others); Tue, 13 Nov 2018 10:48:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:35224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732690AbeKMPsj (ORCPT ); Tue, 13 Nov 2018 10:48:39 -0500 Received: from sasha-vm.mshome.net (unknown [64.114.255.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 850CB2251E; Tue, 13 Nov 2018 05:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542088331; bh=tNXc48GvDdhx8zxUMQBaxoGIvFOFCM5ACrDGB1MelxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eMWhUnKTSk8MsQeIEw/OLF6W1GOkZMYKV6MVeT8XMPtZxDdauvMuayB6GdGGs+5+v L69Qgfhywht1qMB0W6uYSgecyM0y0ad+LgsdFZvt/Aeo4Yn3dB6c2LzWmKZpnwFbee 4CCpozTenbWUkGeBgVnB1MvFr4NAO3Dwws6pT59I= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Sasha Levin , linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 18/26] clk: samsung: exynos5420: Enable PERIS clocks for suspend Date: Tue, 13 Nov 2018 00:51:42 -0500 Message-Id: <20181113055150.78773-18-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181113055150.78773-1-sashal@kernel.org> References: <20181113055150.78773-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marek Szyprowski [ Upstream commit b33228029d842269e17bba591609e83ed422005d ] Ensure that clocks for core SoC modules (including TZPC0..9 modules) are enabled for suspend/resume cycle. This fixes suspend/resume support on Exynos5422-based Odroid XU3/XU4 boards. Suggested-by: Joonyoung Shim Signed-off-by: Marek Szyprowski Signed-off-by: Sylwester Nawrocki Signed-off-by: Sasha Levin --- drivers/clk/samsung/clk-exynos5420.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c index 25601967d1cd..500a55415e90 100644 --- a/drivers/clk/samsung/clk-exynos5420.c +++ b/drivers/clk/samsung/clk-exynos5420.c @@ -280,6 +280,7 @@ static const struct samsung_clk_reg_dump exynos5420_set_clksrc[] = { { .offset = GATE_BUS_TOP, .value = 0xffffffff, }, { .offset = GATE_BUS_DISP1, .value = 0xffffffff, }, { .offset = GATE_IP_PERIC, .value = 0xffffffff, }, + { .offset = GATE_IP_PERIS, .value = 0xffffffff, }, }; static int exynos5420_clk_suspend(void)