From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC93143C07E; Mon, 17 Aug 2026 14:12:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786975957; cv=none; b=Ho0VQ9pFqsiVBEmjKCwmz4KfoNRE+n7MCn3g9QflMu3TI813pO/Fc4+uxnnZpGHAbZL7Fy+oDnp0IF+tKXUNc9I+0B2/OQg0X0qJIPBN8kGSnUUTgd0r6qHv3vGYMqZJfrkhb60gZIU8mnJJeu29/Fhaeq1Vh3g212bEPF0UQtw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786975957; c=relaxed/simple; bh=4cv+XyWIk26cHvUl2pz0vL9OIW7BKIb7pYimz7eFOqI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MZABmKpzIlmS/nTqIRDpjjzTNHRWx6svEB5Q8T79JwHaLVfDVDqmQiYcBSiORRX5cMd+OlNquTPOkX6JhzsM/nUvZgsbnSUZCDrz79Vkwl9PVCVVkcimZRVHpHpNkCBqPSBPOz7BKqfjxi2ZUYLxe1lDG06I6r3ACMpiWATimSU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hXZPjy1p; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hXZPjy1p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 227A61F000E9; Mon, 17 Aug 2026 14:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786975956; bh=BychF//+keSe0lE32X8/SV/5v8APmLUPAHb8W1TKG+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hXZPjy1p2vtB7bn4LYzxHs9wG26Huiwkkpm3g4Twen3Ka+D3+/yTgq27mMNMW8NiP 6qzULDtEnVDl1TDptdHpgQZu+wBCSaYsnYFyveQOaKwnORSdmYeOjCpD6OCuf1te/X wG30thWwwVmnM9/4jURKXdJc5+BT6oX57KnjNx6U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michael Bommarito , Jarkko Sakkinen , Sasha Levin Subject: [PATCH 5.10 208/389] keys: make keyring key-chunk byte order agree with keyring_diff_objects() Date: Mon, 17 Aug 2026 15:30:47 +0200 Message-ID: <20260817132547.331979994@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132538.796021292@linuxfoundation.org> References: <20260817132538.796021292@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Bommarito [ Upstream commit 58565eef0f8d861aae92abfb7658458d661cee17 ] keyring_get_key_chunk() loads description bytes into the index chunk low address first, while keyring_diff_objects() numbers the first differing bit from the low end and folds the absolute byte index into the level without removing the inline-prefix offset the level already carries. The two disagree on byte order and bit position, so the array can be told two keys first differ at a bit that does not differ in the chunk the walker uses, letting crafted descriptions collide into one node. Load the chunk in the order keyring_diff_objects() assumes and drop the inline-prefix length when folding the byte index into the level. This only changes the in-memory ordering used to place keys within a keyring; add, search and read of non-colliding keys are unaffected. Fixes: f771fde82051 ("keys: Simplify key description management") Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Michael Bommarito Reviewed-by: Jarkko Sakkinen Tested-by: Jarkko Sakkinen Link: https://lore.kernel.org/r/20260719161505.2423935-3-michael.bommarito@gmail.com Signed-off-by: Jarkko Sakkinen Signed-off-by: Sasha Levin --- security/keys/keyring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/security/keys/keyring.c b/security/keys/keyring.c index 165ac0d38bcfc..8b938e61ecd8d 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c @@ -293,9 +293,10 @@ static unsigned long keyring_get_key_chunk(const void *data, int level) desc_len -= offset; if (desc_len > n) desc_len = n; + d += desc_len; do { chunk <<= 8; - chunk |= *d++; + chunk |= *--d; } while (--desc_len > 0); return chunk; } @@ -376,7 +377,7 @@ static int keyring_diff_objects(const void *object, const void *data) return -1; differ_plus_i: - level += i; + level += i - (int)sizeof(a->desc); differ: i = level * 8 + __ffs(seg_a ^ seg_b); return i; -- 2.53.0