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 4A7EA3B7B7B; Fri, 4 Sep 2026 05:19:00 +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=1788499141; cv=none; b=J0oQQDaDwaq2V40JN+J/JnZYVAYU5QAkqJb9NgCLONszb+rVwymWv0ocDwbrsABTwu0OE/yGhvjU3K2rfDlgQQlBqUPWDO8x9djFIlRYWUyNdkJdcl2JFXgP+lQZRTXr8AqWl1sl75UzAynGthXkO2IAGg0EifDPkEpAVVH9ucU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788499141; c=relaxed/simple; bh=kzQwaFajECBF+gpJUXYDTG5OSRvPCRxzoIznqqmFKpw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iELKOEf2yRPhV1CiMLYwGt/f+t/JuSOpQu8dber36Y3Tp1OFltdgtaMT0nD2EDzlH3HlZVFbHCLnFO4iBii4npxh7V1saf2xpoUwEd9y5YA/znwSwjlkFwF2kKr84rlLkGWWgRrIMK+ix1g8272Y1V2xrBLU4R/z7sHmk0rwa+Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=w2gADo3f; 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="w2gADo3f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A46F41F00A3D; Fri, 4 Sep 2026 05:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788499140; bh=MIO1zwNXDLD5XOWivux3212sx+rfyj23hDlZ2A5PUXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=w2gADo3fGzOTueU1tjuPj4a9vr3TswEDSBp9AG2m3kCyofv2K+QxIonGYepM1q5k3 YZRahgFfDzbehWBkk24AabHN6Xv98FPuzu8smeESIFUyT4fuKp5maVAT/9enAnl5vd XnpX4LMsLp0C2tYu9GW0c6acHrU1Ud6xAz6KPK9M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pengpeng Hou , Tyler Hicks Subject: [PATCH 7.2 269/713] eCryptfs: bound the packet-length peek to the user buffer Date: Fri, 4 Sep 2026 06:53:57 +0200 Message-ID: <20260904045809.865777034@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045803.810145556@linuxfoundation.org> References: <20260904045803.810145556@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 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pengpeng Hou commit 95540462e630edbc8504e9537d16453d6942d143 upstream. ecryptfs_miscdev_write() accepts the minimum one-byte packet-length encoding, but always copies the maximum two-byte encoding from userspace before parsing it. A six-byte message therefore reads one byte beyond the submitted user buffer. Zero-initialize the peek buffer and copy only the packet-length bytes present. The existing exact packet-size check still rejects truncated two-byte encodings after the parser determines their encoded length. Fixes: 8bf2debd5f7b ("eCryptfs: introduce device handle for userspace daemon communications") Cc: Signed-off-by: Pengpeng Hou Signed-off-by: Tyler Hicks Signed-off-by: Greg Kroah-Hartman --- fs/ecryptfs/miscdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/ecryptfs/miscdev.c +++ b/fs/ecryptfs/miscdev.c @@ -360,7 +360,7 @@ ecryptfs_miscdev_write(struct file *file u32 seq; size_t packet_size, packet_size_length; char *data; - unsigned char packet_size_peek[ECRYPTFS_MAX_PKT_LEN_SIZE]; + unsigned char packet_size_peek[ECRYPTFS_MAX_PKT_LEN_SIZE] = { }; ssize_t rc; if (count == 0) { @@ -376,7 +376,8 @@ ecryptfs_miscdev_write(struct file *file } if (copy_from_user(packet_size_peek, &buf[PKT_LEN_OFFSET], - sizeof(packet_size_peek))) { + min_t(size_t, count - PKT_LEN_OFFSET, + sizeof(packet_size_peek)))) { printk(KERN_WARNING "%s: Error while inspecting packet size\n", __func__); return -EFAULT;