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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,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 105C6C433E1 for ; Fri, 26 Mar 2021 00:04:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D796B61A3F for ; Fri, 26 Mar 2021 00:04:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbhCZAD6 (ORCPT ); Thu, 25 Mar 2021 20:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230016AbhCZADW (ORCPT ); Thu, 25 Mar 2021 20:03:22 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED44EC06175F for ; Thu, 25 Mar 2021 17:03:20 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id c17so3644430ilj.7 for ; Thu, 25 Mar 2021 17:03:20 -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=nAYo0kerZLUN7BkJOSM9MDyMbtqlP2Ebf5RZ2YCWYvE=; b=qn2P1c8qwafkNgsglrLTaTm7bLzpkRkiTLfJLGK8xTN4luzvlgNlv3PnwABJDfQ0NQ 0MhNPSvMVr/plOe7Ep+dLmsOihehu2nGgPeyN2RbdvbPnZIvwEVVJSD7Nqa3+VU1CMVY o0FIODwO5enxaMXKwVTKlaroVBH0Jd861DVZ+KwZREziKZ3yaXyPNMBRw9A0ISQLY71R Pf8Dh4rEOPxN5r4WJCLgXkn7/y7WaU61B7NFXh3k6r4x5m2glFuCmtObmLcXH3tWXWOo wGSDfwu16SSwuzkoCrSQNFJxIa/kJ+sWs/QkDY0ZXFD1my/Q9T6i/h0IveTFSozVTfeM J7jQ== 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=nAYo0kerZLUN7BkJOSM9MDyMbtqlP2Ebf5RZ2YCWYvE=; b=niIuUYdpcnC6KHVrmFWubeC0UMFJ2t+Bk8AiBZlER1rPy2iDYpXzc6QkHWk0jj1kU8 Edxcn1Alm5/5XfeBiukcMa5ej4TqYEzupmp2yqOYZZ+R6Ie4LvbdfJkYY/bM+O9adOd6 LPihjQi1x6bU7jFNVlG/6hsmLSN4FW3+1biNqETvy0nLJWH5Z6SuPdgAuD8YCIx+k/Et bIwO7Urhhd/iDO3UCUzZlZizT5DAVLCq1BfdsZ0shHA2P3K7B/w6MBJ9AEOIAb/N33SN Fih03na9SoZDvgCCl6J39Eiiaqk1JfkVoAKjxghuiNtdUD6X7jwcRPoRfWCHeaUhepjk GUqQ== X-Gm-Message-State: AOAM530DuWzRa+8B1bJMvY4+SPLi1CDsW8U1FRhURAFLEd9z+cXWPOuQ gJ+my1ZdCyNsgp4I2fcSkLzg5cd3EFn7T0UQt/etPw== X-Google-Smtp-Source: ABdhPJycYy1zKxJCALDiO9Ar9NLQb0Bxbm3WLrp/be6z8zC2ySSZc6pZUvOHR+zeKlLowgV0ewAnXJs41sU7Cs8VIoE= X-Received: by 2002:a05:6e02:1b86:: with SMTP id h6mr8191233ili.145.1616717000105; Thu, 25 Mar 2021 17:03:20 -0700 (PDT) MIME-Version: 1.0 References: <20210323203946.2159693-1-samitolvanen@google.com> <20210323203946.2159693-13-samitolvanen@google.com> <20210325103757.GD36570@C02TD0UTHF1T.local> In-Reply-To: From: Peter Collingbourne Date: Thu, 25 Mar 2021 17:03:08 -0700 Message-ID: Subject: Re: [PATCH v3 12/17] arm64: implement __va_function To: Sami Tolvanen Cc: Mark Rutland , Kees Cook , Nathan Chancellor , Nick Desaulniers , Masahiro Yamada , Will Deacon , Jessica Yu , Arnd Bergmann , Tejun Heo , "Paul E. McKenney" , Christoph Hellwig , Peter Zijlstra , bpf , linux-hardening@vger.kernel.org, linux-arch , linux-arm-kernel , linux-kbuild , PCI , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 25, 2021 at 4:28 PM Sami Tolvanen wrote: > > On Thu, Mar 25, 2021 at 3:38 AM Mark Rutland wrote: > > > > On Tue, Mar 23, 2021 at 01:39:41PM -0700, Sami Tolvanen wrote: > > > With CONFIG_CFI_CLANG, the compiler replaces function addresses in > > > instrumented C code with jump table addresses. This change implements > > > the __va_function() macro, which returns the actual function address > > > instead. > > > > > > Signed-off-by: Sami Tolvanen > > > Reviewed-by: Kees Cook > > > > Is there really no attribute or builtin that can be used to do this > > without assembly? > > I don't think the compiler currently offers anything that could help > us here. Peter, can you think of another way to avoid the function > address to jump table address conversion with > -fno-sanitize-cfi-canonical-jump-tables? No, the assembly seems like the best way at the moment. > > IIUC from other patches the symbol tables will contain the "real" > > non-cfi entry points (unless we explciitly asked to make the jump table > > address canonical), so AFAICT here the compiler should have all the > > necessary information to generate either the CFI or non-CFI entry point > > addresses, even if it doesn't expose an interface for that today. > > > > It'd be a lot nicer if we could get the compiler to do this for us. > > I agree, that would be quite useful in the kernel. Maybe. The kernel's requirements seem quite specialized here though. A normal C or C++ program has little need for the actual entry point, so if you need it you are probably doing something low level enough to require assembly anyway. Peter