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 X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE067C4332D for ; Thu, 18 Mar 2021 18:46:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A38CB64F79 for ; Thu, 18 Mar 2021 18:46:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232661AbhCRSpy (ORCPT ); Thu, 18 Mar 2021 14:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232642AbhCRSpl (ORCPT ); Thu, 18 Mar 2021 14:45:41 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A559C06174A for ; Thu, 18 Mar 2021 11:45:41 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id j11so6173045lfg.12 for ; Thu, 18 Mar 2021 11:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FXJ1Kpw2oRWiOPlZvmgzPqNpjS+OST6GpCVGaYkcfjU=; b=KVhzG/Xt0d2tzVy7gn9DeiCmjSKqLb+wM+t8KT/0yYxikiuuU7zFmWYcGH7rBKFF2b AtHQOK1YfGzGRBG0KZ4thwg0+JZusdpXujSogBcYD6D0hMB/V73nccM2C6cWPSHOEUQU a1mayCuYUN57wUJaEJfG9UApRea4LPqYff1TlxP6DG3qTXu7cW9ElW4rVEx+PacKVcM4 1ObbqRp1qWL2rwPmFRQgVM7VmPubsIbfCjOIIgk5xp14ryEBC3GPnUcfaEyo/ZkGvVMu jDzsbdtLYDpL+BtsNICkUJ0UHfPoPDJ1i7+u6wbVW+hhoK4xDwxigkc/8xNcpzwV8JYt uF2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FXJ1Kpw2oRWiOPlZvmgzPqNpjS+OST6GpCVGaYkcfjU=; b=ElM9oL42BlxgV6wdTt2RjcWZ/SGB0wpcqJXXYferEYj2+9LD4klpU3eGg9l7ubK4Ra T0v0xOYKvI4ZKXe7tYjoAoJtKD94F2IVm8eLwKD/yXCL/z4K0weg/R7Tcp8aWvTBJstY TgVQL/Sq9Xn1GlRV9Gev425kBhS7USOem52GfcMZb9PNuUHZBaCUfD9kuE5qhD0h6Q3L gQzSq1MaacrGheBTm8EqgC/XKfUN0QvBthYEZz+OdA4oyUaX/GZ0aynIYIGDdjVuvqin wENQPUddGJoB6hro9DG4TCjBTOwIUsgQ26TaP75wI0hK/gePL8HbvDCkxzGzCIGtGMUT V2tA== X-Gm-Message-State: AOAM533pUGAkR0D1+W3aNl+//y1JN0t4gYCwqHRHe3BXTMEMVxoFxsh9 +tvLDLBRg/GSpez3CXT87xVqY6F7HZKROuPvpC/9og== X-Google-Smtp-Source: ABdhPJzI/cXQgUy2RSLmNuSxvjB8uEjk+GLf2aUWomqyxgvUmHefmj8Y6oB/C1sojY9blIJSTxDq0p15b1fs89u6VoM= X-Received: by 2002:ac2:538e:: with SMTP id g14mr6055632lfh.543.1616093139630; Thu, 18 Mar 2021 11:45:39 -0700 (PDT) MIME-Version: 1.0 References: <20210318171111.706303-1-samitolvanen@google.com> <20210318171111.706303-11-samitolvanen@google.com> In-Reply-To: From: Nick Desaulniers Date: Thu, 18 Mar 2021 11:45:28 -0700 Message-ID: Subject: Re: [PATCH v2 10/17] lkdtm: use __va_function To: Sami Tolvanen Cc: Kees Cook , Nathan Chancellor , Masahiro Yamada , Will Deacon , Jessica Yu , Arnd Bergmann , Tejun Heo , "Paul E. McKenney" , Christoph Hellwig , bpf , linux-hardening@vger.kernel.org, linux-arch , Linux ARM , Linux Kbuild mailing list , PCI , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 18, 2021 at 11:43 AM Nick Desaulniers wrote: > > On Thu, Mar 18, 2021 at 10:11 AM Sami Tolvanen wrote: > > > > To ensure we take the actual address of a function in kernel text, use > > __va_function. Otherwise, with CONFIG_CFI_CLANG, the compiler replaces > > the address with a pointer to the CFI jump table, which is actually in > > the module when compiled with CONFIG_LKDTM=m. > > Should patch 10 and 12 be reordered against one another? Otherwise it > looks like 12 defines __va_function while 10 uses it? Ah, nvm patch 3 defines a generic version, I see. > > > > > > Signed-off-by: Sami Tolvanen > > Acked-by: Kees Cook > > --- > > drivers/misc/lkdtm/usercopy.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/misc/lkdtm/usercopy.c b/drivers/misc/lkdtm/usercopy.c > > index 109e8d4302c1..d173d6175c87 100644 > > --- a/drivers/misc/lkdtm/usercopy.c > > +++ b/drivers/misc/lkdtm/usercopy.c > > @@ -314,7 +314,7 @@ void lkdtm_USERCOPY_KERNEL(void) > > > > pr_info("attempting bad copy_to_user from kernel text: %px\n", > > vm_mmap); > > - if (copy_to_user((void __user *)user_addr, vm_mmap, > > + if (copy_to_user((void __user *)user_addr, __va_function(vm_mmap), > > unconst + PAGE_SIZE)) { > > pr_warn("copy_to_user failed, but lacked Oops\n"); > > goto free_user; > > -- > > 2.31.0.291.g576ba9dcdaf-goog > > > > > -- > Thanks, > ~Nick Desaulniers -- Thanks, ~Nick Desaulniers