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 0B8C3C433EF for ; Fri, 15 Oct 2021 21:33:42 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5372660EE2 for ; Fri, 15 Oct 2021 21:33:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5372660EE2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4HWKJg6PW7z3cKv for ; Sat, 16 Oct 2021 08:33:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=f8kTQ/Y/; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=chromium.org (client-ip=2607:f8b0:4864:20::52b; helo=mail-pg1-x52b.google.com; envelope-from=keescook@chromium.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=f8kTQ/Y/; dkim-atps=neutral Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4HWKHx5DVYz2xt6 for ; Sat, 16 Oct 2021 08:33:01 +1100 (AEDT) Received: by mail-pg1-x52b.google.com with SMTP id 75so9730705pga.3 for ; Fri, 15 Oct 2021 14:33:01 -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=OeZMkWR5uFQN9HNdUAVJ3Ab7n7Nqfc8UJFtD6aoaM/khMgxmjQyYPGOikt0dIFq+T1 wtabYsYfod4YqkccGfI/W3bOkdY4i3sex6h1lWK6KqrNNdrlZaDAIxlrKQ+jsYSC/y6S wrvXB9YPjo6MG/euqwJprBRgnK3wuXL+CXHa4B+eQV6kfH0K57xhshYOc4wDdZ/Ah8he PAH1VOusc6FgyecLfdJQOV8e6UDiFmk9F8tDHdt0O9ZLVapshOXpOtYz8ggLL5JbgvvB aeRyOkbpLplVLy93vprP3bbnNgWk2CHlQhg56B324y7dVCzfHAcLh19VdaIJpnXan3Zh j1jw== X-Gm-Message-State: AOAM533Ntq0Z1oSMu68y4pRH9n+UHOTx1+UXolAgBD2P9Hn5hFDgZq4W JYSQnZbMIemFkpK8XFumRm6Lcg== 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 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-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org, Arnd Bergmann , Greg Kroah-Hartman , Helge Deller , linux-kernel@vger.kernel.org, "James E.J. Bottomley" , linux-mm@kvack.org, Paul Mackerras , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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