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 CE68A320CB1; Fri, 7 Aug 2026 14:43:26 +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=1786113824; cv=none; b=RR+iIj+J73aivj9fuJowBXYNkK90agN5P8PPD/CN2+wGIHvSN7ZQT7mnaC57hT47ZqDeuBCbD2MfQsPp6FO1t8EudYNz3SaScWoYGMr6YqpzykaK9kgLlxRrAXRNjOx0UZtwkiec9ULEU6NEkrDmFsgbmboyWeSlU1qZTkYjE/Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786113824; c=relaxed/simple; bh=yoA24DqvfGT6b8hkW/yxhur3g6WY5vRqsB3mdaNyKJk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NKwDsn4p4/YrlrTfu6A6YNYTqdoqpjc0zxFzBE0UmPWPAkpBBxxYkAweIWhVIjP1WmVocNMjttCHXqNO4vVM7P37Gz/LeOxeU+3n+4MNp2n+H/FajphbgzTwA4C4hUM2qEPG90V8uf6M1HaqkZEbUP4ujCQbsx5rupGeOcW3OYE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2poVME4X; 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="2poVME4X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C6101F00A3A; Fri, 7 Aug 2026 14:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786113805; bh=6c54+XqF/z44fh+EJPjJuuKPsP9JS4FLGgzOv41+bRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2poVME4Xdvsb3VsYk1Xd2t8a+AEVLKB0GlhofpIhZxDCwIuzX8E50euAROA0vxzQ2 1NZFs4BTH8zyO3rwJ3cSL+hrDFyEMcsl3brLh/H0IpLvOd/JQHltzUk4kFWdT5AbsB w3WA4FpZ1mnIpgA7A3fwHJ7kCfobgdeV0ftm6zEQ= 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 6.12 042/337] keys: fix out-of-bounds read in keyring_get_key_chunk() Date: Fri, 7 Aug 2026 16:34:05 +0200 Message-ID: <20260807143419.426990808@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143418.516897842@linuxfoundation.org> References: <20260807143418.516897842@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Bommarito [ Upstream commit 63918731f9ae25b5deb022f118e941e6dddfcef4 ] For description-level chunks keyring_get_key_chunk() advances the read pointer by level * sizeof(long) past the inline prefix but only bounds-checks the prefix, so a long enough key description is read past its kmemdup(desc, desc_len + 1) allocation. Compute the full byte offset and bounds-check the description against it before reading. The walk only reaches a description-level chunk when two keys collide through the hash, x, type and domain_tag chunks, so this is reached from an unprivileged add_key(2) with a crafted pair of same-type keys whose index hashes collide; KASAN reports a slab-out-of-bounds read. 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-2-michael.bommarito@gmail.com Signed-off-by: Jarkko Sakkinen Signed-off-by: Sasha Levin --- security/keys/keyring.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/security/keys/keyring.c b/security/keys/keyring.c index e105349794f23..b9ca9dc9b0c3f 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c @@ -271,6 +271,7 @@ static unsigned long keyring_get_key_chunk(const void *data, int level) unsigned long chunk = 0; const u8 *d; int desc_len = index_key->desc_len, n = sizeof(chunk); + unsigned int offset; level /= ASSOC_ARRAY_KEY_CHUNK_SIZE; switch (level) { @@ -284,12 +285,12 @@ static unsigned long keyring_get_key_chunk(const void *data, int level) return (unsigned long)index_key->domain_tag; default: level -= 4; - if (desc_len <= sizeof(index_key->desc)) + offset = sizeof(index_key->desc) + level * sizeof(long); + if (desc_len <= offset) return 0; - d = index_key->description + sizeof(index_key->desc); - d += level * sizeof(long); - desc_len -= sizeof(index_key->desc); + d = index_key->description + offset; + desc_len -= offset; if (desc_len > n) desc_len = n; do { -- 2.53.0