Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp609359pxh; Tue, 9 Nov 2021 16:07:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTuyxr7gadkIbo0FuPLo5kC1TnynmX9obNnszV+POJucKYm7oodUxrKOV+y/dGCmUKnIy9 X-Received: by 2002:a05:6e02:1846:: with SMTP id b6mr8158415ilv.164.1636502869763; Tue, 09 Nov 2021 16:07:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636502869; cv=none; d=google.com; s=arc-20160816; b=Ly6umX91OxbVbSvYn4GQzoXCE2/DMvL28HAT6npYeuAb+qzdhUopVNe8y3JvEQhlAN QEDZk99/auqv9mh5Uw7AeDUjJ/OhxHIGfcmvJ3aCJoA0H+5COvgHOR344K51sqT2wTH5 94O1mMDAxxkTiWANMIobZHMyV/2903oAMq+DW3tDtkAFgnh1pkyN368qCxNMN/r7DcMQ 5/+GSoyR0n1VGnoAI+T+w3fIO46S3IcguWckLAPHhgd26h5UqhFS/FughLAxIzrWWubk mf56x7ScE4AK4kHz/TbWW9/o/kDDHCwEr3ECHBGUv8qcBtEpmNK5ZgQerMmOxb3yTWrB fLtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Teu6GrVNQwTfwVFDVxxSzU/C+46ysul+TyK6elXaqno=; b=Qm/Uk25aK7kgakXHIP1f5YNaW/+oTNSMFxsDHHTNBZtZ14uLeuKPlHV9ffLHAbYXoa fqG6fH+GiiLemCjtsCXFUDJBbPqJx9H6w1GD/G/NaL63lP9SAYKLm6T6ump0vPOphrFW GCQbri36jiV2uwqCqIXBr/E2KLOfS8D0SQ9a47WymkYenD1q8O32kzIedKd3dab9gYSc 1UZu/ntRZYFlocnU7nMGEWAokqc0+WnlJCVXuKO1k3FvTvhLYedLrEhR3ZY0/1+xBlsC e8ctSCxFrnjuUyfyQ6+2SP9J8zGGuSormrRu4Hn64TUmNS2styFZXctlarHQNB6lvgmK d6IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lHyJTqTQ; 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 1si27799675ilz.178.2021.11.09.16.07.37; Tue, 09 Nov 2021 16:07:49 -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=lHyJTqTQ; 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 S240379AbhKIQtV (ORCPT + 97 others); Tue, 9 Nov 2021 11:49:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:60010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240128AbhKIQtL (ORCPT ); Tue, 9 Nov 2021 11:49:11 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 59BAD613B3; Tue, 9 Nov 2021 16:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636476385; bh=mY8bQKVatIszIv/ojyP72DOn1RLYXG4EALo/OHrynUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lHyJTqTQkDngAJxRYvXD0JlehrGzG7P4ullWuV9cAqOooyTPo/zOWU+3vIG986wIp YSIisS8p3TOhYHdgRk4+Vm+F0Y+2Ffq4uG/pqbPOoOwhpvqZ9NBKcaLgMTgEagAbrW 0HRpBeJjbKZR/phmVNfEqTpIct8wMp0oQ7RKO4k5i1pdK9WKbVUpt0tSCyWpgve7tA nmel1ezTYxKVX3XP+Rz6iFNxpiwt2zuVFmwwZKOoAfpZNMXyvjb9JiyPbaZws2AfFf xIROEoIfEk3pdoJhVNVXI8wi3zgvrMIZmjlpE3c+ZmGsGb+dT3yGk7wub6OtfCvkwW a4N2XyHnxNG8A== From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Mark Rutland , Kees Cook Subject: [RFC PATCH 7/7] static_call: add generic support for non-exported keys Date: Tue, 9 Nov 2021 17:45:49 +0100 Message-Id: <20211109164549.1724710-8-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211109164549.1724710-1-ardb@kernel.org> References: <20211109164549.1724710-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2665; h=from:subject; bh=mY8bQKVatIszIv/ojyP72DOn1RLYXG4EALo/OHrynUw=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBhiqW8pjJ/R8foOMwerUWPrX3XzSKG+oHwtotvxgmD jlbTXE6JAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYYqlvAAKCRDDTyI5ktmPJCMDC/ 9FwatngAQAnYKGvkkmD2MYoewjSD6/wA1JeRJcQMIaFhEk+0OOTV+45/5AmTWB3HtJ7GSirV3jE5Cz lzX5wx2O3Ng74NQ6oJUiwjCwfPOQfxpUxq+p+q/btb4/xTOFm6SgPnrosF9Su4onhUUNUuGNp5oMbp pM9qJp0OgYlpaG339kRtmeUo2eD/LCBClHdEpfiep5Sh9Zny+nXMaaVnPRc7X4BqLpIDjNuRmuMhs/ ttqDVai/4NOgNVdPKZGOZR/ghLycKbHGnfLHS0wK4ot8Eyq9l7cR4HjezL/4sMzZV+vgq5sbb7zYR5 TD5762B+LZX0LAcKJ3tG1oIwxf1nnPcg3PJlL/NODmvPc579nb/RBQ/od2i0D4gKw54p7rkk4Ub172 VUprcR8Tjj62klNJctpJbfZU0xTUBTlaLN2nwTHMpuCQwr6P94wzEUa1ScmX9OSy7jNehNvWIOjhbP kU8rLW5w0LWRXTFdsXq6zdcxpUQROXv1soj3rsp2AAimI= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The static_call feature where only the static call target is exposed to modules while access to the key is withheld is only implemented for the inline and out-of-line varieties, but not for the generic indirect call based variety. Let's use static_call_query() to obtain the call target address if the key is not exported. Note that this means we can do the converse as well, i.e., implement static_call_query() in terms of the key struct if the key is exported, so we only need to export one of the two. Note that this adds an additional load and potentially a direct call to the instantiations of static_call residing in module code. Signed-off-by: Ard Biesheuvel --- include/linux/static_call.h | 4 ++-- include/linux/static_call_types.h | 3 +-- tools/include/linux/static_call_types.h | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/linux/static_call.h b/include/linux/static_call.h index 21929147879a..d88fd613f06d 100644 --- a/include/linux/static_call.h +++ b/include/linux/static_call.h @@ -302,8 +302,8 @@ static inline int static_call_text_reserved(void *start, void *end) return 0; } -#define EXPORT_STATIC_CALL(name) EXPORT_SYMBOL(STATIC_CALL_KEY(name)) -#define EXPORT_STATIC_CALL_GPL(name) EXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name)) +#define EXPORT_STATIC_CALL(name) EXPORT_STATIC_CALL_QUERY(name,) +#define EXPORT_STATIC_CALL_GPL(name) EXPORT_STATIC_CALL_QUERY(name, _GPL) #define EXPORT_STATIC_CALL_FOR_UPDATE(name) EXPORT_SYMBOL(STATIC_CALL_KEY(name)) #define EXPORT_STATIC_CALL_FOR_UPDATE_GPL(name) EXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name)) diff --git a/include/linux/static_call_types.h b/include/linux/static_call_types.h index eae11c5b015d..920828ad1d69 100644 --- a/include/linux/static_call_types.h +++ b/include/linux/static_call_types.h @@ -106,8 +106,7 @@ struct static_call_key { void *func; }; -#define static_call(name) \ - ((typeof(STATIC_CALL_QUERY(name)()))(STATIC_CALL_KEY(name).func)) +#define static_call(name) static_call_query(name) #endif /* CONFIG_HAVE_STATIC_CALL */ diff --git a/tools/include/linux/static_call_types.h b/tools/include/linux/static_call_types.h index eae11c5b015d..920828ad1d69 100644 --- a/tools/include/linux/static_call_types.h +++ b/tools/include/linux/static_call_types.h @@ -106,8 +106,7 @@ struct static_call_key { void *func; }; -#define static_call(name) \ - ((typeof(STATIC_CALL_QUERY(name)()))(STATIC_CALL_KEY(name).func)) +#define static_call(name) static_call_query(name) #endif /* CONFIG_HAVE_STATIC_CALL */ -- 2.30.2