Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp889254pxf; Thu, 25 Mar 2021 17:06:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0bJJ6m+aY2ncqgdlg2vJleyO1V2KHiFi35i5e2KrqtACQPq/NUAxGaZrjesup1EaW+IaP X-Received: by 2002:a17:906:d8d3:: with SMTP id re19mr12547376ejb.440.1616717188120; Thu, 25 Mar 2021 17:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616717188; cv=none; d=google.com; s=arc-20160816; b=bq5jM3DAauVmj8aFgh9H7XBgV9afQ17RP6viSiFHCBtH6hI06Xb1NtdwJO+235MRcy dqKrDIZ1XvcMAUzWx/DflKuiEA9bR3OH4Em11SaJhgvF0/OOh2LC7GNtH4BY79BnJGzg 35ZYqE1CZijq6+K7PtK3T8yOh8k3b/ZB2UvcOOd/BKqff9Op+/Jcek+FykvhATMpAa86 ET7TF+Rj3Y41oivvtg3eRHqb/7N8UcTH62Ny9xVH6HnndgSDa3bxQE86QSoxAj8ebnAd k3OLsUgu0JAjAZOhoy4gK6abM2DIphDmL/9t8crflGOQRj6lhPRNEh9geQbqehjpbeRG ddJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nAYo0kerZLUN7BkJOSM9MDyMbtqlP2Ebf5RZ2YCWYvE=; b=S9iV7CRFXvVy4l1TvmObedYRQmCgM/k6bNk8DvlNgDfWiVbNHQKtPjPFfNGiBOe7Gf /+sYVXAZT8swEA+E0LeoNSWSs75TEgageFbf81mVlxBa/zIQQhwoUdjO9d8tpa4001mu jZaceEAsf+/n5rmDFn9DsXugF6Bl+dlGBCaitXtzErRZynuGkpSEHg7ioMh+aRQn8i1M VCdHo9J9IgZp8rMPV3oULZKwHyF2PlK0dopJn6ewNLlNl6FGKKDcgzFvoIN/FV4A+VrL R4ibgEKtZZkaObZkZ1LDD3F9Li9HkucupQjBoT/blKa5QH+GWw3PtlV7up5UGTnE/1fG wJFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qn2P1c8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m24si5317958edp.422.2021.03.25.17.06.05; Thu, 25 Mar 2021 17:06:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qn2P1c8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230018AbhCZAD5 (ORCPT + 99 others); Thu, 25 Mar 2021 20:03:57 -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-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