Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp899162yba; Thu, 18 Apr 2019 11:26:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNTKEmbXEzunzscxfvpRmZT3S0l+gXjWziYCEJUlzy8+F5S4B4OSzcjL4fQaKeQ1BAv4m7 X-Received: by 2002:a65:5687:: with SMTP id v7mr11318547pgs.299.1555611987423; Thu, 18 Apr 2019 11:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611987; cv=none; d=google.com; s=arc-20160816; b=DHVXlyRrQXeI3+pUrDLjO0Hl6ZpAAF9moSA9okF4BNTLhagPsfXLga1SouFO7fna9u WnNTgF8AC1NgyC2rzicDL2dcUUPX5V4g8wnvAdMqLm8/33H6r+kSirmfntZSx/Rb52P0 bqQ1ph3sWVajcfhpN5TCi6vQQWKvdxMI41EeihE566KAdGVfdwgqMbQ9nfwyZHLsa/6N q/rvLbaIVHfM56lwmPFWJiXJWOnCZidsEBiffyIPmsKVimMdcw0ZLXPt1omj1KnbPs3p nhg/squ0OYTzA3+33Ts5y/UVagkMwEa+VLtGG3SAIpwq8VLH50x3BJsXiJnMgpLGdQ2A easg== 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=KopqsYGn7aCpqe4Le8JYG4K92sldn4BJ4nOxEuiXhaU=; b=wBF9jXhCSaz8jQOCurW093wX9/fEvzKfSQ6MP14A3L5mCKIIEYjrRubxeH+yRrxl/C /aOmpgeIIoNfVfEv627FIJ0eb3m2mrx+C3i/vxzHGyjg7Q8vAPz38c54zCKis2q8d+H4 ro9afyR68/owXHYYr3jnPFBuU9IzOHdohMuM8csb/cnKL8jydATd4X2KmUSN1l3F1mMQ jDbtfHTbyc/AizznpjRbv2/xiTvUSUczJAbTQ57DcehhvuT5e3PXhoEDV4w1LB/XaiM1 6w2QJLoaDXX5ZuE0FPcdnf064ZAyssOK1JWCbpIbRoASaUk5u8q40OpSk1BlFPlNj2GW XLRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=edjY3Wbx; 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 e14si2842259pfn.203.2019.04.18.11.26.12; Thu, 18 Apr 2019 11:26:27 -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=edjY3Wbx; 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 S2389950AbfDRSFY (ORCPT + 99 others); Thu, 18 Apr 2019 14:05:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:34702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390878AbfDRSFX (ORCPT ); Thu, 18 Apr 2019 14:05:23 -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 BE89321872; Thu, 18 Apr 2019 18:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610722; bh=BLyzED7awgBi08MKSPvqPYgiOMhD5m1Y2llpYUa5/0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=edjY3Wbx9543lKs+lLxvvHmMYLlkqAzY2XbvgZPD1SUowq+RRl/92c1WuUIeoa8yc 7P7NHMPbG8pCxzAWbQ5inGCKqPVTpO6uoqaOZeg2PJXWQh0VTstuPFFsyjEopUyvC2 OysslbrlB7RiDTo0yNXyQ9Jxr8B7J3fqn3hHCVYg= 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 4.14 59/92] lkdtm: Print real addresses Date: Thu, 18 Apr 2019 19:57:17 +0200 Message-Id: <20190418160435.284207448@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160430.325165109@linuxfoundation.org> References: <20190418160430.325165109@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