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=1796380050; b=o2pDx9w5wIouMvykEdiAqEjfXCcOuMsPsMBzv089KkxzTjWF6LOxQazWTUMPAIwqt/hM l3ues9y3ITHczdZ2VB+NSGi28uKi1UjikzgYGTy9XuhGCzJD217PFDVWdbslxEmCfVUpx CuTuAzvKhTZOuBiPrZKxC4KOm7MafmfROsRy+1UPWQiHcfkGVmGQ5HwRA4NrcWfGUalYT D+gOlzfH77g6ysnz8Pb6Ft6r5exCEvCdXe76PYyiitbPuZLDAhxj1VwmJddkull5Tb+7P UV4VIV5URCA04z9jJM8lgcNn2B3sKArawcsxHcRRHu96exoGdRyz+H7WKq8pZCawgFw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380050; 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=heA54zhzxmN7qmI/6mGACSdTAPjvl/VDfVOcvsNSv2k=; b=s71M+3LH1UL65WFtfbkQAnwX9ATT/aM/Mbao06IssCuodIdQQ5ZLg5pWR/Tpq1JCIeyM a/hEWZKaDWNgIpPvqTWXNU31xjbZ8cGhMc7S6EHJxiATXGIa81QB27UjsP36h3SxlyyU1 S7y1pw9U71JN5ocBj3pmC7bWUg+tED2HANHjsQxdM7MwugLTDb67wmNWXqAeaW3mFMWv/ LKyOG22mRnTSWtbB7H1B1YtrjHX6o2w7h3LSa/nxbvN1e5Xi3XnrjyN8oBsTNorXWFyjZ 4P+DT/IkIqKU7GnwPSLymU7w9VgEI0yWBvuxeAPCvcHc36qOFDoYk5HCE4iT46BopEw== 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=QKWMwh71; 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 B52ED606A32C; Fri, 4 Dec 2026 10:27:30 +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=QKWMwh71 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3132A1F000C2; Fri, 4 Dec 2026 10:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380050; bh=heA54zhzxmN7qmI/6mGACSdTAPjvl/VDfVOcvsNSv2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QKWMwh71f6Cyn1tuGjy9oPl444lwLwhEVrFMljQZ+qmRQ+EGXbtf/xPHecU+ffIbo AukXukYTehDtbwKAzSK20pPu2W277bYF6npFxMZ3WxFdvrMFsjoqZvhow1WlDFwBI1 eb/K15kNSDkcWPzh1pZCrj1Ee5o54AXDhNj552L0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Heiko Carstens , Jarkko Sakkinen , Alexander Gordeev , Sasha Levin Subject: [PATCH 7.3 107/742] s390/cert_store: Unlink before invalidate in invalidate_keyring_keys() Date: Fri, 4 Dec 2026 18:59:31 +0900 Message-ID: <20261204100637.980210192@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Heiko Carstens [ Upstream commit a1e3a45cac3d847e8ae81cc7e9db1b7b2c547a0e ] If a key is invalidated, the key garbage collector may remove its link from the keyring at any time. If that happens the subsequent key_unlink() fails. invalidate_keyring_keys() would then incorrectly return an error, which would lead to unregistering the cert_store key type. Unlink the key first and invalidate it afterwards to avoid this race. Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates") Signed-off-by: Heiko Carstens Reviewed-by: Jarkko Sakkinen Signed-off-by: Alexander Gordeev Signed-off-by: Sasha Levin --- arch/s390/kernel/cert_store.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c index 87aced367a61f..a142f46cc82b8 100644 --- a/arch/s390/kernel/cert_store.c +++ b/arch/s390/kernel/cert_store.c @@ -346,10 +346,10 @@ static int invalidate_keyring_keys(struct key *keyring) continue; pr_dbf_msg("Invalidating key %08x", current_key->serial); - key_invalidate(current_key); rc = key_unlink(keyring, current_key); if (rc) pr_dbf_msg("Couldn't unlink key %08x: %ld", current_key->serial, rc); + key_invalidate(current_key); key_put(current_key); if (rc) break; -- 2.53.0