Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp615246pxh; Tue, 9 Nov 2021 16:13:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqn4dHcAMsdZ4YRre34kRM2CMDJGstNXFFGIGKJM39V6ayHnKms8PzHqcFLDgXjylsg2J3 X-Received: by 2002:a92:c241:: with SMTP id k1mr8013736ilo.207.1636503202785; Tue, 09 Nov 2021 16:13:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636503202; cv=none; d=google.com; s=arc-20160816; b=j+Mj0ruVnbEqFIYZqxhA1oXH0dKsqY/iWvUMI0Y3ihb/Ey0haC1tDrzuoIDp0TheyZ xzRPFBoGbSHb/13LyLPdOOxZTtFLJYFxbiL+CIHpIV6N0pUyqNmDu5AVwJjXu4BBPeKG 0F4DBF0Z1GqawlRRead3+RPt9lEOp0TLevremHi/AuZ+PB2VbiUWiHMk2OO+vc65dCMr YOLrFEPDJHhgydrwp3Z/xNGI0R928sDN0fwZULAi52XV8/uW2F55m23IfkcMH1Wo0l40 qiTHfgaUVvYNMel48XaqnqHFLFieZrSHrVs0eFCpASSefbFObpeM1JyQ73C1t3IXTtTw hOAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8iCLiLBN5Xl0oh6P9wFFDC6J3HOu+dEV+gfu75yUkRU=; b=il1QlSB+vBPN3DaJX4HIitOjPBkqWB+yn0HZ307psrCkuubsXbdz8OWpvzEoPjrVDZ KOnDvB7EvioE8K1vQnQudiKdvx027G3nf0n8CZdHBxw8QHd38H90A1SJ+MUNkmU+1eB2 qoMtNZIN+2ghz9a+aX1FbUsBuD1DzEdPp4m101p55lkgUMbiYKf7ymbQaE3f+y2AO6iT Q/RXbfwPpOSfa1SDn2XWgQU6nOQT0el6wyhLHI4f4uwwzqhOiQByfe8WXcb6PqiKyXWA yqT9/Z7y7NCbqt4DHaWTTxrnS1GWnmH+EcDG4hb8dI7Lu3dwAyPk7BHQVlS1vxutFQ6g TadA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=glI9A+Yb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si46491449jat.54.2021.11.09.16.13.10; Tue, 09 Nov 2021 16:13:22 -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=@infradead.org header.s=desiato.20200630 header.b=glI9A+Yb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242769AbhKIS4C (ORCPT + 97 others); Tue, 9 Nov 2021 13:56:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242667AbhKIS4B (ORCPT ); Tue, 9 Nov 2021 13:56:01 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9EC5C061764 for ; Tue, 9 Nov 2021 10:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=8iCLiLBN5Xl0oh6P9wFFDC6J3HOu+dEV+gfu75yUkRU=; b=glI9A+YbXxeP7aTXB5FSORb8sj x5fa1qgHtI54Fk/tFGb355mhXOT4wPyD94aUM7HAG6PVqjFf8qFxu/4hWRTjKizux3OFlzkKQqaRH uaBlMxwp4vPom7mnR7lPVz9A7dAQN1FKTKTFrUpO4gR9tf6AOzWWj7MGsDBF/Gpqf9i9PiauRL19F ID8ycUBo09dEZ0ZxXmoiHUO3A9zcJAdMzCwux3MKV8eyGW4xfFHfvfdJQSuNHp6bOowFLyi2e8GmP 6uV1buJR4byykdQM5MVM4q9E5EzJj0uUKBsDttJ2ttm+PQBEOVMd2wMuRudC8gCkE4Z8ZeggOAZyV oFoC1aRQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkWEz-00F74y-IF; Tue, 09 Nov 2021 18:53:05 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 32A173000DD; Tue, 9 Nov 2021 19:53:05 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 20119212EE599; Tue, 9 Nov 2021 19:53:05 +0100 (CET) Date: Tue, 9 Nov 2021 19:53:05 +0100 From: Peter Zijlstra To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Josh Poimboeuf , Jason Baron , Steven Rostedt , Mark Rutland , Kees Cook Subject: Re: [RFC PATCH 3/7] static_call: use helper to access non-exported key Message-ID: References: <20211109164549.1724710-1-ardb@kernel.org> <20211109164549.1724710-4-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211109164549.1724710-4-ardb@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.