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 405D2C433F5 for ; Sat, 16 Oct 2021 06:41:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C4406611C3 for ; Sat, 16 Oct 2021 06:41:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C4406611C3 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 38D576B0071; Sat, 16 Oct 2021 02:41:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33C756B0072; Sat, 16 Oct 2021 02:41:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20A11900002; Sat, 16 Oct 2021 02:41:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 0C9E36B0071 for ; Sat, 16 Oct 2021 02:41:07 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B8C148249980 for ; Sat, 16 Oct 2021 06:41:06 +0000 (UTC) X-FDA: 78701353332.13.BED3315 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by imf18.hostedemail.com (Postfix) with ESMTP id B50A54002087 for ; Sat, 16 Oct 2021 06:41:04 +0000 (UTC) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4HWYSJ4Z1gz9sSL; Sat, 16 Oct 2021 08:41:04 +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 DgjsS_Egr1BK; Sat, 16 Oct 2021 08:41:04 +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 4HWYSJ3TH7z9sSH; Sat, 16 Oct 2021 08:41:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 5EEA88B765; Sat, 16 Oct 2021 08:41:04 +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 asovUeRSJBBo; Sat, 16 Oct 2021 08:41:04 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.203.36]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 388CC8B763; Sat, 16 Oct 2021 08:41:03 +0200 (CEST) Subject: Re: [PATCH v2 11/13] lkdtm: Fix lkdtm_EXEC_RODATA() 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> From: Christophe Leroy Message-ID: <61a3d2c4-4997-c221-3eef-d74aef5ba584@csgroup.eu> Date: Sat, 16 Oct 2021 08:41:03 +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: <202110151432.D8203C19@keescook> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr-FR Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: B50A54002087 X-Stat-Signature: z44538g7r8utf4nn8soot9a8rw4t4y7f X-HE-Tag: 1634366464-803996 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 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 >=20 > I still don't understand this -- it doesn't look needed at all given th= e > changes in patch 12. (i.e. everything is using > dereference_function_descriptor() now) dereference_function_descriptor() only deals with the function address,=20 not the function TOC. 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. 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. 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? 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 view=20 it is incorrect to call one function with the TOC from the descriptor of=20 another function. If you thing we can take the risk, then I'm happy to drop the patch and=20 replace it by execute_location(dereference_function_descriptor(lkdtm_rodata_do_nothing= ), CODE_AS_IS) Christophe