Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp615484pxh; Tue, 9 Nov 2021 16:13:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzerdln0e202Jz2WUIS4xQVfyOwuyF8nnXCyEXkGl6YpaeasddEtt6XJ2OjX3fSkP07EN2V X-Received: by 2002:a92:b110:: with SMTP id t16mr8211833ilh.38.1636503218308; Tue, 09 Nov 2021 16:13:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636503218; cv=none; d=google.com; s=arc-20160816; b=LQwthHYw6kuLtkXvAno6IvUcJalCrcyIrH9RPOs6XqcnsnNf9391m0aS1eEbXeYbxk k1nKXAymOgg3FBWw0d3M1QlZQOswO88atMaUSVNDSXLYLW3uLzDI/mJIb+Gsorq/QRJt Vk1hLcbgQ0fduOI8mVeVbxpBpo5SXXrKy+oZzbtK4i6n0HzCyaMRG/0OPBw30hhYWkZs Lw1Yq//koBkL2PSX5aCbwDipWNGEPukY3eYzPmalntQycgfJj5Fg4rFAs8LqrkNWMjUO vZCiDNLlNIr0NJPfsWTaSrCMHzdqOOByztMmVrPq8G5gb3XRUBXRykOhPo8KUA0RrTpZ ZSmw== 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=ufK/uFrkdhKluOiKNHXQUA/DNuH8gVteHB9X7v0eI20=; b=y2CJpMvQvpGQekubWpvGDIpDMOzyZzDAgAywcsE5Uwb1Tgsi4m5HS086CpDBhteTok F/wwKimToaWJoGAUjf4oqSbbyuhS19DC5FSdUVpOmvN7ALYDPhStMruJjK0YdE5bB69F CQuMcgSHwMjCp+ru0GFpamx5e+FdfB+9lUctIR1vmR/GAs9/QPIuYkufv8P6/8AOVtPG l1duB4sFvYfN2kzJSeSmJ6lw/TXWeKRRZ35wnIKMRi8fwDAjItgijiZaSkp5AxyvtxMH gt242I7yXWb8EVBKQWJ1wq3/vT4NK+qaW32AKgedeTn7csDjl7otCgGVMCWakHDDj5eh o5ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pDF/ngHA"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si33501573iok.86.2021.11.09.16.13.26; Tue, 09 Nov 2021 16:13:38 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b="pDF/ngHA"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242821AbhKIS5W (ORCPT + 97 others); Tue, 9 Nov 2021 13:57:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:34372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242481AbhKIS5V (ORCPT ); Tue, 9 Nov 2021 13:57:21 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6DCE9611AF for ; Tue, 9 Nov 2021 18:54:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636484075; bh=PhYXgD2L6/ysPXkKNuVrDzH7xz+6jYYzXhmSA6THCdo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=pDF/ngHAkWReWpzVv+qvNEwQQIDqLJpoHHrroVwA5QDck58B1+Eak2fSfvsYwJ4n+ wnPQwlLoHelNhodWC+if2iwutHdmWwd+vW8Q0KTm7klURSjSGXucttd3Pq/ou3akra K36j8xSNavwCaCZDp2xpMyBmB08vaKnG4L5EGwM/Sy4+d64xKfnZLF9Ccg4jitekAJ Ha4ww/MHkxmHKLpg4RqEIgjQv+TGN0d7EkoCLBU576EIPHLEzanv/1GdNbce0iiZ81 VYed0+gdn2K/tzzTKT2ENKl3uAULQvzXruPPV4+qrF4R4Ar7iY6zkh1Qa+85bmzGFl Bjwmhrdul2i1A== Received: by mail-ot1-f47.google.com with SMTP id o15-20020a9d410f000000b0055c942cc7a0so96663ote.8 for ; Tue, 09 Nov 2021 10:54:35 -0800 (PST) X-Gm-Message-State: AOAM530MN++JS2LlPaVdNJx2zCEPemA4BUEWLiWynr+P2YyKvS/O9Ty6 k2fWR+5H7kXGAnI9pCCQudBwbOfFV68RFwodklk= X-Received: by 2002:a05:6830:1514:: with SMTP id k20mr7667802otp.147.1636484074714; Tue, 09 Nov 2021 10:54:34 -0800 (PST) MIME-Version: 1.0 References: <20211109164549.1724710-1-ardb@kernel.org> <20211109164549.1724710-4-ardb@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Tue, 9 Nov 2021 19:54:23 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 3/7] static_call: use helper to access non-exported key To: Peter Zijlstra Cc: Linux Kernel Mailing List , Linux ARM , Josh Poimboeuf , Jason Baron , Steven Rostedt , Mark Rutland , Kees Cook Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 9 Nov 2021 at 19:53, Peter Zijlstra wrote: > > On Tue, Nov 09, 2021 at 05:45:45PM +0100, Ard Biesheuvel wrote: > > @@ -196,13 +190,21 @@ extern long __static_call_return0(void); > > EXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name)); \ > > EXPORT_SYMBOL_GPL(STATIC_CALL_TRAMP(name)) > > > > +#define EXPORT_STATIC_CALL_GETKEY_HELPER(name) \ > > + struct static_call_key *STATIC_CALL_GETKEY(name)(void) { \ > > + BUG_ON(!core_kernel_text( \ > > + (unsigned long)__builtin_return_address(0))); \ > > + return &STATIC_CALL_KEY(name); \ > > + } \ > > + EXPORT_SYMBOL_GPL(STATIC_CALL_GETKEY(name)) > > So if I were a nevarious module, I would look up the above symbol from > kallsyms (it is exported and easily obtainable) and then simply > read the text to discover the key address and we're in business. > Yeah I realised that. So would you prefer to have a .static_call_tramp_key section in each module and look up the keys in the module loader?