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 2D020C433FE for ; Fri, 15 Oct 2021 21:33:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BCB4861151 for ; Fri, 15 Oct 2021 21:33:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BCB4861151 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 4478E6B0072; Fri, 15 Oct 2021 17:33:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F6E26B0073; Fri, 15 Oct 2021 17:33:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BEB4900002; Fri, 15 Oct 2021 17:33:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id 1D9486B0072 for ; Fri, 15 Oct 2021 17:33:01 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C03A53A8C9 for ; Fri, 15 Oct 2021 21:33:00 +0000 (UTC) X-FDA: 78699972120.14.31193FF Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf07.hostedemail.com (Postfix) with ESMTP id AA53D10000AE for ; Fri, 15 Oct 2021 21:33:01 +0000 (UTC) Received: by mail-pg1-f174.google.com with SMTP id j190so2969520pgd.0 for ; Fri, 15 Oct 2021 14:33:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=YNBNEYisZ+541asH+L6t1hZlJ/Xn9d3ughoW3yhbnMY=; b=f8kTQ/Y/ACr3yL4eMWtqbWU2xm18S+76EHKyee4Vqqv4SV8J6qk5BuskJbEb6Ql/TJ c9EbbOivEp4/Vy74Zv5n8MvM1vLyBEeJPN8m+5olTn2ub0SZO8xZlaRygBBGEjyk6s6j dW6pUEjVARu6NrsLidMTQLR5wt2C5k6t+XvQQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YNBNEYisZ+541asH+L6t1hZlJ/Xn9d3ughoW3yhbnMY=; b=Q9EGcyJTuEF/ubDe502YsuLvnFv0l1kP/y48U9v4tX8YHRV5WTN1nI7qCwqJU7SxJh Lu+cpCdXKh11muYkdGgoZAGusOMa9/TE2bsHrbptvguXiXENKHg/WBOvHpmKQyxj3MF1 PCv3Awp1d714MOAVFReFWYMX0ilxOcXw3ESbbOH3d9w+ZIHaC+/MvNyEuMiDO4Ulwxlh EC54YNvXZOiEpCXVQEWiSlZijMSovO/xQ0UrxiHmjM903UvdqPUotrhV9I7XZIf4zTRC F22F73+y2/ll0cvJ8xsVeBGsLS01gHhyV+pOpQbJUl4ITOGo2O/ioWKCpIiod/8ujc7C 3zKA== X-Gm-Message-State: AOAM531l0kAmSvBx+GXurYS2kcg4fJYv7Hpe24Ggr7mewrbd7qUluOIE bTvYPoYgE56TBLa0lwJjipMF3w== X-Google-Smtp-Source: ABdhPJzAyN+K8Hifn5n3pJa0D9tsRyoaRMolZRmu5TyHtvN6ydh9MAL1iJXdAj5PTEgi34yjsZ8kvg== X-Received: by 2002:a63:ef58:: with SMTP id c24mr10773001pgk.299.1634333579455; Fri, 15 Oct 2021 14:32:59 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id t126sm5787900pfc.80.2021.10.15.14.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 14:32:59 -0700 (PDT) Date: Fri, 15 Oct 2021 14:32:58 -0700 From: Kees Cook To: Christophe Leroy 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 Subject: Re: [PATCH v2 11/13] lkdtm: Fix lkdtm_EXEC_RODATA() Message-ID: <202110151432.D8203C19@keescook> References: <44946ed0340013a52f8acdee7d6d0781f145cd6b.1634190022.git.christophe.leroy@csgroup.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44946ed0340013a52f8acdee7d6d0781f145cd6b.1634190022.git.christophe.leroy@csgroup.eu> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: AA53D10000AE X-Stat-Signature: p47msqqjcbkpjkewt76jxs1gh34hszna Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="f8kTQ/Y/"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf07.hostedemail.com: domain of keescook@chromium.org designates 209.85.215.174 as permitted sender) smtp.mailfrom=keescook@chromium.org X-HE-Tag: 1634333581-743085 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: 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) Can't this patch be dropped? -Kees > --- > 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 035fcca441f0..5266dc28df6e 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_function_descriptor(do_nothing)); > + do_nothing(); > + > + pr_info("attempting bad execution at %px\n", > + dereference_function_descriptor(lkdtm_rodata_do_nothing)); > + lkdtm_rodata_do_nothing(); > + pr_err("FAIL: func returned\n"); > } > > void lkdtm_EXEC_USERSPACE(void) > -- > 2.31.1 > -- Kees Cook