From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB4DEC433EF for ; Mon, 11 Oct 2021 15:26:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99E1C60F6E for ; Mon, 11 Oct 2021 15:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233815AbhJKP2l (ORCPT ); Mon, 11 Oct 2021 11:28:41 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:48591 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233441AbhJKP2l (ORCPT ); Mon, 11 Oct 2021 11:28:41 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4HSjM30nYCz9sV0; Mon, 11 Oct 2021 17:26:39 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kfJrJzoe33Ot; Mon, 11 Oct 2021 17:26:39 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4HSjM26P7jz9sTq; Mon, 11 Oct 2021 17:26:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C3CE48B77C; Mon, 11 Oct 2021 17:26:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id o_-xmTCGhVEE; Mon, 11 Oct 2021 17:26:38 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [172.25.230.103]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3802B8B773; Mon, 11 Oct 2021 17:26:38 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.16.1/8.16.1) with ESMTPS id 19BFQWmS1585039 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 17:26:32 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.16.1/8.16.1/Submit) id 19BFQW0I1585038; Mon, 11 Oct 2021 17:26:32 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Andrew Morton , "James E.J. Bottomley" , Helge Deller , Arnd Bergmann , Kees Cook , Greg Kroah-Hartman Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v1 09/10] lkdtm: Fix lkdtm_EXEC_RODATA() Date: Mon, 11 Oct 2021 17:25:36 +0200 Message-Id: <7da92e59e148bd23564d63bdd8bcfaba0ba6d1f1.1633964380.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1633965929; l=1062; s=20211009; h=from:subject:message-id; bh=+g9YP744c7bsVBNv8JSbJAOACSKefkN6gEMRtuguhFQ=; b=OJtsbOKhvP8yiMMxjyj+ls1H3JCLJJR5fyCB0L0ZNnRKeroYkZDzqkgCo7jAmoGfibEgEw6Fwm9g 3d3D8A/kCjW5VuVqCFU0NuPC6oJTXF5EWDJbG9dFbb3ba4uK2nRq X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org Behind a location, lkdtm_EXEC_RODATA() executes a real function, not a copy of do_nothing(). So do it directly instead of using execute_location(). And fix displayed addresses by dereferencing the function descriptors. Signed-off-by: Christophe Leroy --- drivers/misc/lkdtm/perms.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/misc/lkdtm/perms.c b/drivers/misc/lkdtm/perms.c index 442d60ed25ef..da16564e1ecd 100644 --- a/drivers/misc/lkdtm/perms.c +++ b/drivers/misc/lkdtm/perms.c @@ -153,7 +153,14 @@ void lkdtm_EXEC_VMALLOC(void) void lkdtm_EXEC_RODATA(void) { - execute_location(lkdtm_rodata_do_nothing, CODE_AS_IS); + pr_info("attempting ok execution at %px\n", + dereference_symbol_descriptor(do_nothing)); + do_nothing(); + + pr_info("attempting bad execution at %px\n", + dereference_symbol_descriptor(lkdtm_rodata_do_nothing)); + lkdtm_rodata_do_nothing(); + pr_err("FAIL: func returned\n"); } void lkdtm_EXEC_USERSPACE(void) -- 2.31.1