Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp888838yba; Thu, 18 Apr 2019 11:15:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxt8+WtaKe+AfY1DKzWVhXA/duahOScmDN4IKN7ZmxBLyQVengc17+4CC0Bl/Oa/4ZSJetV X-Received: by 2002:a62:1881:: with SMTP id 123mr97287701pfy.25.1555611313464; Thu, 18 Apr 2019 11:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611313; cv=none; d=google.com; s=arc-20160816; b=qahKT6NqBNY0Evov9C1uidW1dNGQ/r8PxOP+EhtBofYqE+INvM5PBNo6PO7FCoGFDn ooZ1WNc0foiy3STfF2i8M9P6WSqo0UxgLtxPWBzHrwYamw00vKKLsqGz9ZM2DYthLBgS KE0CJgBIfGmNSdFED3P+r4aOd4meGFg5jQUiZVw5EcIsE78apeRmgLUBkkeSXYbWqPIm MX3qKl0V0wsClXm9aeZ3URNhl7+yKe8NhqdZBWcbO1sUMyfaZk3lL8EMhXvkEMF3VfaR rJMSibOwijmtkn4E+qO+xeSUyvvR9KqyqrlvgtmOM9kcF5nYfPM8Qjppwt2HPhLoZUrf OPxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4whcw4Sutder0/Pa/WjG3O5JDaIi303RSHFUTnJIIzY=; b=nejnk7skv87+LXREeLQnH1IQJ3/YLyQiZQrK6aWe0VzPvhyIupd9ep+nKLIYqU+PGc KfxD3/eTHK+JIElSA59swXSWYxt+4Ave35GyNqxDY+jiQOo4chcL8Q6S3WZr743Pck9Q w/8mW94jybVzX2e3v6VTMzyjFg2At4FeVo3nKA8l28/xSWKCS+7St835W7BLYwjilfRM IkO4nAhqzozpeVjiik4koNRRKT/ZUoQnYlJEK+DweEHF5qWYsbyf5UthemFGpigMu+ri YNd1Pg37hJPEakUSXHldhDrlvt5Q2a55GP4vtYDD9pEbBixqrMcKt4ddAT9x15ASNKoR XjKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PPQzCyrn; 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 61si2729244plq.2.2019.04.18.11.14.58; Thu, 18 Apr 2019 11:15:13 -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; dkim=pass header.i=@kernel.org header.s=default header.b=PPQzCyrn; 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 S2404438AbfDRSNY (ORCPT + 99 others); Thu, 18 Apr 2019 14:13:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:46086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404420AbfDRSNV (ORCPT ); Thu, 18 Apr 2019 14:13:21 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B7FB121872; Thu, 18 Apr 2019 18:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611200; bh=xF0TOWc7e2J8vc50T1ggSAbby129Zq08vr5bk8ecc7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PPQzCyrnLwUKrllm94L23Mgq9bVMJ72z5POoEqASfSGC474MwjiakU7SVvn8ceFN6 NnqDnnKeVeyWlyDeTn/lsbHN8y/DvyEgvOJOhShEH9GDWhZ3iFh2TvHQPy6BOn2jj2 L7mZzrGrQVzEoXidq+BA6XpcOu5XueAGoyBQAR0U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Kees Cook , Sasha Levin Subject: [PATCH 5.0 68/93] lkdtm: Print real addresses Date: Thu, 18 Apr 2019 19:57:46 +0200 Message-Id: <20190418160444.145327991@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 4c411157a42f122051ae3469bee0b5cabe89e139 ] Today, when doing a lkdtm test before the readiness of the random generator, (ptrval) is printed instead of the address at which it perform the fault: [ 1597.337030] lkdtm: Performing direct entry EXEC_USERSPACE [ 1597.337142] lkdtm: attempting ok execution at (ptrval) [ 1597.337398] lkdtm: attempting bad execution at (ptrval) [ 1597.337460] kernel tried to execute user page (77858000) -exploit attempt? (uid: 0) [ 1597.344769] Unable to handle kernel paging request for instruction fetch [ 1597.351392] Faulting instruction address: 0x77858000 [ 1597.356312] Oops: Kernel access of bad area, sig: 11 [#1] If the lkdtm test is done later on, it prints an hashed address. In both cases this is pointless. The purpose of the test is to ensure the kernel generates an Oops at the expected address, so real addresses needs to be printed. This patch fixes that. Signed-off-by: Christophe Leroy Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- drivers/misc/lkdtm/perms.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/misc/lkdtm/perms.c b/drivers/misc/lkdtm/perms.c index 53b85c9d16b8..fa54add6375a 100644 --- a/drivers/misc/lkdtm/perms.c +++ b/drivers/misc/lkdtm/perms.c @@ -47,7 +47,7 @@ static noinline void execute_location(void *dst, bool write) { void (*func)(void) = dst; - pr_info("attempting ok execution at %p\n", do_nothing); + pr_info("attempting ok execution at %px\n", do_nothing); do_nothing(); if (write == CODE_WRITE) { @@ -55,7 +55,7 @@ static noinline void execute_location(void *dst, bool write) flush_icache_range((unsigned long)dst, (unsigned long)dst + EXEC_SIZE); } - pr_info("attempting bad execution at %p\n", func); + pr_info("attempting bad execution at %px\n", func); func(); } @@ -66,14 +66,14 @@ static void execute_user_location(void *dst) /* Intentionally crossing kernel/user memory boundary. */ void (*func)(void) = dst; - pr_info("attempting ok execution at %p\n", do_nothing); + pr_info("attempting ok execution at %px\n", do_nothing); do_nothing(); copied = access_process_vm(current, (unsigned long)dst, do_nothing, EXEC_SIZE, FOLL_WRITE); if (copied < EXEC_SIZE) return; - pr_info("attempting bad execution at %p\n", func); + pr_info("attempting bad execution at %px\n", func); func(); } @@ -82,7 +82,7 @@ void lkdtm_WRITE_RO(void) /* Explicitly cast away "const" for the test. */ unsigned long *ptr = (unsigned long *)&rodata; - pr_info("attempting bad rodata write at %p\n", ptr); + pr_info("attempting bad rodata write at %px\n", ptr); *ptr ^= 0xabcd1234; } @@ -100,7 +100,7 @@ void lkdtm_WRITE_RO_AFTER_INIT(void) return; } - pr_info("attempting bad ro_after_init write at %p\n", ptr); + pr_info("attempting bad ro_after_init write at %px\n", ptr); *ptr ^= 0xabcd1234; } @@ -112,7 +112,7 @@ void lkdtm_WRITE_KERN(void) size = (unsigned long)do_overwritten - (unsigned long)do_nothing; ptr = (unsigned char *)do_overwritten; - pr_info("attempting bad %zu byte write at %p\n", size, ptr); + pr_info("attempting bad %zu byte write at %px\n", size, ptr); memcpy(ptr, (unsigned char *)do_nothing, size); flush_icache_range((unsigned long)ptr, (unsigned long)(ptr + size)); @@ -185,11 +185,11 @@ void lkdtm_ACCESS_USERSPACE(void) ptr = (unsigned long *)user_addr; - pr_info("attempting bad read at %p\n", ptr); + pr_info("attempting bad read at %px\n", ptr); tmp = *ptr; tmp += 0xc0dec0de; - pr_info("attempting bad write at %p\n", ptr); + pr_info("attempting bad write at %px\n", ptr); *ptr = tmp; vm_munmap(user_addr, PAGE_SIZE); -- 2.19.1