From patchwork Thu Nov 5 01:00:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 7556441 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1012BBEEA4 for ; Thu, 5 Nov 2015 01:03:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 185EF207D8 for ; Thu, 5 Nov 2015 01:03:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4DAA2207D1 for ; Thu, 5 Nov 2015 01:03:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zu8vZ-0002e5-4l; Thu, 05 Nov 2015 01:01:21 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zu8vU-0002bK-S3 for linux-arm-kernel@lists.infradead.org; Thu, 05 Nov 2015 01:01:18 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 7BD79469; Thu, 5 Nov 2015 01:00:55 +0000 (UTC) Received: from labbott-redhat-machine.redhat.com ([10.3.112.7]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA510riO017524; Wed, 4 Nov 2015 20:00:54 -0500 From: Laura Abbott To: Russell King , Kees Cook Subject: [PATCH] arm: Use kernel mm when updating section permissions Date: Wed, 4 Nov 2015 17:00:39 -0800 Message-Id: <1446685239-28522-1-git-send-email-labbott@fedoraproject.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151104_170117_313833_C7F052EE X-CRM114-Status: GOOD ( 13.56 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Laura Abbott MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, read only permissions are not being applied even when CONFIG_DEBUG_RODATA is set. This is because section_update uses current->mm for adjusting the page tables. current->mm need not be equivalent to the kernel version. Use pgd_offset_k to get the proper page directory for updating. Signed-off-by: Laura Abbott --- I found this while trying to convince myself of something. Dumping the page table via debugfs and writing to kernel text were both showing the lack of mappings. This was observed on QEMU. Maybe it's just a QEMUism but if not it probably should go to stable. --- arch/arm/mm/init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 8a63b4c..4bb936a 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -629,11 +629,9 @@ static struct section_perm ro_perms[] = { static inline void section_update(unsigned long addr, pmdval_t mask, pmdval_t prot) { - struct mm_struct *mm; pmd_t *pmd; - mm = current->active_mm; - pmd = pmd_offset(pud_offset(pgd_offset(mm, addr), addr), addr); + pmd = pmd_offset(pud_offset(pgd_offset_k(addr), addr), addr); #ifdef CONFIG_ARM_LPAE pmd[0] = __pmd((pmd_val(pmd[0]) & mask) | prot);