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 D2B91C43217 for ; Sun, 17 Oct 2021 07:50:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E118561179 for ; Sun, 17 Oct 2021 07:50:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E118561179 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0E42A6B006C; Sun, 17 Oct 2021 03:50:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0940B6B0072; Sun, 17 Oct 2021 03:50:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC5B8900002; Sun, 17 Oct 2021 03:50:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id DE60D6B006C for ; Sun, 17 Oct 2021 03:50:15 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 93BDC2DD93 for ; Sun, 17 Oct 2021 07:50:15 +0000 (UTC) X-FDA: 78705156390.19.ED88E7A Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by imf26.hostedemail.com (Postfix) with ESMTP id D921320019C6 for ; Sun, 17 Oct 2021 07:50:15 +0000 (UTC) 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 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D921320019C6 X-Stat-Signature: uixs86wm7humwu1xnpzi54umt9qg7593 Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-HE-Tag: 1634457015-121970 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Le 16/10/2021 =C3=A0 08:41, Christophe Leroy a =C3=A9crit=C2=A0: >=20 >=20 > Le 15/10/2021 =C3=A0 23:32, Kees Cook a =C3=A9crit=C2=A0: >> 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 t= he >> changes in patch 12. (i.e. everything is using >> dereference_function_descriptor() now) >=20 > dereference_function_descriptor() only deals with the function address,= =20 > not the function TOC. >=20 > do_nothing() is a function. It has a function descriptor with a given=20 > address (address of .do_nothing) and a given TOC, say TOC1. >=20 > lkdtm_rodata_do_nothing() is another function. It has its own function=20 > descriptor with a given address (address of .lkdtm_rodata_do_nothing)=20 > and a given TOC, say TOC2. >=20 > If we use execute_location(), it will copy do_nothing() function=20 > descriptor and change the function address to the address of=20 > lkdtm_rodata_do_nothing(). So it will call lkdtm_rodata_do_nothing()=20 > with TOC1 instead of calling it with TOC2. >=20 >> >> Can't this patch be dropped? >=20 > It is likely that the TOC will be the same for both functions, and=20 > anyway those functions are so simple that they don't use the TOC at all= ,=20 > so yes it would likely work without this patch but from my point of vie= w=20 > it is incorrect to call one function with the TOC from the descriptor o= f=20 > another function. >=20 > If you thing we can take the risk, then I'm happy to drop the patch and= =20 > replace it by >=20 > =C2=A0=C2=A0=C2=A0=C2=A0execute_location(dereference_function_descript= or(lkdtm_rodata_do_nothing), CODE_AS_IS) >=20 Once we have patch 12 EXEC_RODATA works well on powerpc without this=20 patch so I will drop this patch for now and will propose something else=20 as a follow-up to my series. Christophe