From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382979; b=Ayl37d2iXi0NbH16DTcOYQ9w9mO5J6LIfM+vojc0Y3ET0/ZxQeAf6meBC+cNzN1DuhUG TTgYljtKPEMluehUZTpW/C2OsufuIW8UuzOH2aBN4gSL9G1oWCZt6b53stVZXpQxMcBhD uvKttwU9NNx+LI/qgIGJ8pmZra30LH18u3n3Ksa0OiPfgMP6dCT4XVLylwH/rqqlF9Snr gCEEHmPC0rPZ74ge1UR7zwtEll31SA6awRS+RuQOTQuoua2QTMCRzPrXt5Bo9Ujmc4Zm9 AF+lkI3ub3iM7m6QZojEPpN6p1rSklreHWYrryVbRGsTFzKxE5vSKvcO9V+H9K/nI4g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382979; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=IhQSOtSR2CjNIeMF9G2cDuKhyCvVvreNNPHHbwd864E=; b=V3FDq6KKKgjcY9sRa12mFDF2Duz6wcYhupR/DwPDKoArBkvxU/L1/SmG9lWdOQwpe21w HsVziZIouTbvHncs/78+7ghMMLe3WNcl/TCU7xGnKuMQA5Xg1vvFJAbRsVapfRP8VGzyE GqDQ/ztzSrzdSt3a/Ja3vRUNIr2B37EHqc+6mzxln7PBcl6FPzr27aDzuf/RWiOOve8RG b4T+CF4SlU/5+9+CCxuJuMclPU71Cyr2LUCkMDotR2gdCgOt0jb4atquEUxC4e2ZGcfcv KinKaJVRr56LGdSPvRvl3a9Fzxcj+tsumMhlXk6c5J4RWPZMv2Q0ayIPoGRFMhXqeow== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=f08UsiFd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1553C606A32C; Fri, 4 Dec 2026 11:16:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=f08UsiFd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D20E1F000CE; Fri, 4 Dec 2026 11:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382978; bh=IhQSOtSR2CjNIeMF9G2cDuKhyCvVvreNNPHHbwd864E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f08UsiFd18EgRJ/791QDFTMaKjcQEM+hs7RUiSYlv0InMUfTaHzJx06jyakrFSPAj UK1kKhn0wbia3Ofafxtd4r3JAtXsJnfky6dHCzxurha08lZaY1VWPCENrNORblpfea k0cuGkkFD3XRkXaBBUMtzcAdam5oFj9PrkAvrpCg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jarkko Sakkinen Subject: [PATCH 6.18 634/703] KEYS: trusted: Update static calls before init Date: Fri, 4 Dec 2026 19:08:53 +0900 Message-ID: <20261204100644.651014151@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jarkko Sakkinen commit f8b462c497549e9991299156ed0e019eae8524f1 upstream. Given that the static calls are updated only after ->init() returns, an added trusted key can race with the callback initializations. This can ultimately lead into null dereference as static_call() is used unchecked. Address the bug by updating the static calls before invoking ->init(), and roll back on failure. Cc: stable@vger.kernel.org # v5.15+ Fixes: 31de287345f4 ("KEYS: trusted: Rollback init_trusted() consistently") Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- security/keys/trusted-keys/trusted_core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- a/security/keys/trusted-keys/trusted_core.c +++ b/security/keys/trusted-keys/trusted_core.c @@ -362,14 +362,19 @@ static int __init init_trusted(void) if (!get_random) get_random = kernel_get_random; + static_call_update(trusted_key_seal, trusted_key_sources[i].ops->seal); + static_call_update(trusted_key_unseal, trusted_key_sources[i].ops->unseal); + static_call_update(trusted_key_get_random, get_random); + migratable = trusted_key_sources[i].ops->migratable; + ret = trusted_key_sources[i].ops->init(); if (!ret) { - static_call_update(trusted_key_seal, trusted_key_sources[i].ops->seal); - static_call_update(trusted_key_unseal, trusted_key_sources[i].ops->unseal); - static_call_update(trusted_key_get_random, get_random); - trusted_key_exit = trusted_key_sources[i].ops->exit; - migratable = trusted_key_sources[i].ops->migratable; + } else { + static_call_update(trusted_key_seal, NULL); + static_call_update(trusted_key_unseal, NULL); + static_call_update(trusted_key_get_random, NULL); + migratable = 0; } if (!ret || ret != -ENODEV)