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 65DD5C433FE for ; Sun, 17 Oct 2021 07:50:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F6046103B for ; Sun, 17 Oct 2021 07:50:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241371AbhJQHwY (ORCPT ); Sun, 17 Oct 2021 03:52:24 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:60437 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233966AbhJQHwY (ORCPT ); Sun, 17 Oct 2021 03:52:24 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4HXBxd0Dp6z9sSg; Sun, 17 Oct 2021 09:50:13 +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 qE16lVPGMQXg; Sun, 17 Oct 2021 09:50:12 +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 4HXBxb1HWmz9sSf; Sun, 17 Oct 2021 09:50:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 1361A8B76C; Sun, 17 Oct 2021 09:50:11 +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 y2-boJOlu1zA; Sun, 17 Oct 2021 09:50:11 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.203.38]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E55898B763; Sun, 17 Oct 2021 09:50:09 +0200 (CEST) Subject: Re: [PATCH v2 11/13] lkdtm: Fix lkdtm_EXEC_RODATA() From: Christophe Leroy To: Kees Cook Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Andrew Morton , "James E.J. Bottomley" , Helge Deller , Arnd Bergmann , Greg Kroah-Hartman , 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 References: <44946ed0340013a52f8acdee7d6d0781f145cd6b.1634190022.git.christophe.leroy@csgroup.eu> <202110151432.D8203C19@keescook> <61a3d2c4-4997-c221-3eef-d74aef5ba584@csgroup.eu> Message-ID: <87927aa3-6414-adaa-44f7-b3bf1f664317@csgroup.eu> Date: Sun, 17 Oct 2021 09:50:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <61a3d2c4-4997-c221-3eef-d74aef5ba584@csgroup.eu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr-FR Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org Le 16/10/2021 à 08:41, Christophe Leroy a écrit : > > > Le 15/10/2021 à 23:32, Kees Cook a écrit : >> On Thu, Oct 14, 2021 at 07:50:00AM +0200, Christophe Leroy wrote: >>> Behind its location, lkdtm_EXEC_RODATA() executes >>> lkdtm_rodata_do_nothing() which is a real function, >>> not a copy of do_nothing(). >>> >>> So executes it directly instead of using execute_location(). >>> >>> This is necessary because following patch will fix execute_location() >>> to use a copy of the function descriptor of do_nothing() and >>> function descriptor of lkdtm_rodata_do_nothing() might be different. >>> >>> And fix displayed addresses by dereferencing the function descriptors. >>> >>> Signed-off-by: Christophe Leroy >> >> I still don't understand this -- it doesn't look needed at all given the >> changes in patch 12. (i.e. everything is using >> dereference_function_descriptor() now) > > dereference_function_descriptor() only deals with the function address, > not the function TOC. > > do_nothing() is a function. It has a function descriptor with a given > address (address of .do_nothing) and a given TOC, say TOC1. > > lkdtm_rodata_do_nothing() is another function. It has its own function > descriptor with a given address (address of .lkdtm_rodata_do_nothing) > and a given TOC, say TOC2. > > If we use execute_location(), it will copy do_nothing() function > descriptor and change the function address to the address of > lkdtm_rodata_do_nothing(). So it will call lkdtm_rodata_do_nothing() > with TOC1 instead of calling it with TOC2. > >> >> Can't this patch be dropped? > > It is likely that the TOC will be the same for both functions, and > anyway those functions are so simple that they don't use the TOC at all, > so yes it would likely work without this patch but from my point of view > it is incorrect to call one function with the TOC from the descriptor of > another function. > > If you thing we can take the risk, then I'm happy to drop the patch and > replace it by > >     execute_location(dereference_function_descriptor(lkdtm_rodata_do_nothing), CODE_AS_IS) > Once we have patch 12 EXEC_RODATA works well on powerpc without this patch so I will drop this patch for now and will propose something else as a follow-up to my series. Christophe