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=1796379777; b=ZM73nHoKQzDSprv9bkZdsnF5TizEcSO5BfWP/FobUFwRUrSLS6tLpye6bL5+9il97jSA ZjLDLu3b14s82BmKCcHfMzoImYBzbP75fBoQVsyJhrDYbwkbRHgj1MY21nPv1avFCGCdr FWQ0EQ5AA+QRJ2ZOrLHLGTxgxlOZeY2cU2j9YqS6bCW+NpA/jpJKbng5XJm7ey/ehzPji hqP5GL65VPXD6vxajTftCo3aRZkNHxNwuBKrEBdVgpsU9Cey5c8ozUA5lVB8pV4rQKrxd 80yMf+vuhlGUHTPp7Hy2rwH+Ge5F/SA3un1tTTIE1l/QLhqYcKdTO2sid80MMvTDgXw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379777; 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=NZuV8Ck+wDK9ericIXbNWCmPLgn3+kRr1c752y3Z0AE=; b=NMVRTFt8dFgQW/E4ZVocxyC2k/c3RpuOwQuGuXMK6ghPR55K4jsJqf1BFIBqvuaMjAHk nE7pMd8TP0+RotGE+CW/2EJrQxHtKkm5t7ZX32mMTlYkOl5lYZVioIMfiLejibOaW6grA xIBuqr6Ihm/sLYz8xput5K4O8GaG/YoS2GabGh748NxHOggujSJyFdl9WbScMAJY0l6kZ j4mg8VZnRGOe4MBwpsDIWlpsPNS/p3NIvGMx0XRJO9CUTSWCcnHjDxxP+t/6L9ob36gsW 02tsmXnvBPQvSE5BubG0pErPKt+T8LDg+o+bH8eHeOcoxLywWcuA6m/zJI/USWA5xCQ== 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=exjsgSJT; 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 7A9EB606A322; Fri, 4 Dec 2026 10:22:57 +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=exjsgSJT Received: by smtp.kernel.org (Postfix) with ESMTPSA id E953A1F000CE; Fri, 4 Dec 2026 10:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379777; bh=NZuV8Ck+wDK9ericIXbNWCmPLgn3+kRr1c752y3Z0AE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=exjsgSJTB1wTzFKZWdTS8h7dckodw47RuO7yGMAxizgPjegoOUMm/eSBSZbY4sQBr VybnYDc+XFAcVpRkd+9Ad+Y4NTcZLENzBfZxlxT5MRgH3SdreP+VOfuBYx3qANX0rL Ka3exzlidn3i4XOYtTOKlqh25bITIbBsEXkmCTo0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Howells , Eric Biggers , Jarkko Sakkinen , Sasha Levin Subject: [PATCH 6.12 056/555] KEYS: Expand key->{datalen,quotalen} to unsigned int Date: Fri, 4 Dec 2026 19:01:39 +0900 Message-ID: <20261204100608.662330110@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jarkko Sakkinen [ Upstream commit 4a65eaf146f0d10ebaa88cfaef9c3b24f93766d9 ] In key_alloc() and key_payload_reserve(), key->quotalen and key->datalen can receive values larger than USHRT_MAX. Example: keyctl new_session >/dev/null owner=$(keyctl newring owner @s) keeper=$(keyctl newring keeper @s) for ((i=0; i<16384; i++)); do key=$(keyctl add user "k$i" x "$keeper") keyctl link "$key" "$owner" done awk -v uid="$(id -u):" '$1 == uid {print $NF}' /proc/key-users keyctl clear "$owner" awk -v uid="$(id -u):" '$1 == uid {print $NF}' /proc/key-users Because key->datalen wraps around 65535, the quota refunded upon clearing is truncated, causing quota bytes to leak in /proc/key-users. Change the types of key->datalen and key->quotalen from unsigned short to unsigned int so that they can carry the full payload length without truncation. Cc: stable@vger.kernel.org Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reviewed-by: David Howells Reviewed-by: Eric Biggers Link: https://lore.kernel.org/r/20261020174325.2229448-2-jarkko@kernel.org Signed-off-by: Jarkko Sakkinen [ sashal: Replaced the smb_EIO1/smb_EIO2 trace helper calls with plain rc = -EIO in the cifsacl.c hunks, since those helpers are missing here. ] Signed-off-by: Sasha Levin --- fs/smb/client/cifsacl.c | 6 +++--- include/linux/key.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c index ac2e09eacabc7..eace735190c63 100644 --- a/fs/smb/client/cifsacl.c +++ b/fs/smb/client/cifsacl.c @@ -319,7 +319,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid) goto out_revert_creds; } else if (sidkey->datalen < CIFS_SID_BASE_SIZE) { rc = -EIO; - cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu)\n", + cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%u)\n", __func__, sidkey->datalen); goto invalidate_key; } @@ -336,7 +336,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid) ksid_size = CIFS_SID_BASE_SIZE + (ksid->num_subauth * sizeof(__le32)); if (ksid_size > sidkey->datalen) { rc = -EIO; - cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu, ksid_size=%u)\n", + cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%u, ksid_size=%u)\n", __func__, sidkey->datalen, ksid_size); goto invalidate_key; } @@ -431,7 +431,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid, */ BUILD_BUG_ON(sizeof(uid_t) != sizeof(gid_t)); if (sidkey->datalen != sizeof(uid_t)) { - cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu)\n", + cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%u)\n", __func__, sidkey->datalen); key_invalidate(sidkey); goto out_key_put; diff --git a/include/linux/key.h b/include/linux/key.h index 9b4d3e7e71025..eebc3fe9c5b9b 100644 --- a/include/linux/key.h +++ b/include/linux/key.h @@ -219,8 +219,8 @@ struct key { kuid_t uid; kgid_t gid; key_perm_t perm; /* access permissions */ - unsigned short quotalen; /* length added to quota */ - unsigned short datalen; /* payload data length + unsigned int quotalen; /* length added to quota */ + unsigned int datalen; /* payload data length * - may not match RCU dereferenced payload * - payload should contain own length */ -- 2.53.0