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=1793212444; b=xWnsCXRG1TSWqy2n0cP11we6sPINbEj60Vqy8RZN8GEmYYsUs55p0ELQtQnEHOca481+ kCm3r8PdM1QYqCKaqzumNQQcvNZCCJpiWuJ32mD7ILFm9vboV0+50khDv8bFvoDOkjQQL VWu7dHpZVa6r3kO3SwSqL7B5kb5/S+Xth1ln/tb1FwLpOrhxv78yZtY03wTgvZHfBm2+I SJY59k1fxyS0htzfF2D0HLDL9G8XSDfmLuosj5w/0Fv5I7MFvywZ6mAbmy87YEf9ct45Z w6ifC6vK9Nwpwene3o3Q9W8DeNvIVvkm0R0Ct7hkYkhJlmf9uFjrdSG19ZxhDduH9fQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793212444; 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=8Sh+n5yGf6PcpSFiR+fB7RqzISvu5Xb3MFlCMTJoktc=; b=2BLUHf+zNTWBlwOlPwLA4u5586i23NNwoQEP/vFGlBltLtDwZ9GRChL2b7n9Zb/5YusH aeaDjafJAgjPi09iepg72ARRVG9RflxnxJMsoc42FlxtFi4HqFf/KIJIV6+38f4hm6m7X hKio/li39Rnp7gz8J/4lzDkmVJM93LgJ0xQE9THaTflrbWRsbki7Wt6OV5TKuYKbgzrEZ cQC+WRemgBixXy9EuOEOYv8pyAqW5bNxMi9e0zgDp02O/Ffp1wAh7YXCIs+3rYxQHYijD 5EYpiUf7K62v1yQzyMKmXifHK3+Ona4IikIf+cJxxYbefljRK1xyE02NEpGl4XgFFdw== 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=fh2V36EN; 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 7A8BF606A31E; Wed, 28 Oct 2026 18:34:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fh2V36EN Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB9531F01825; Wed, 28 Oct 2026 18:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793212444; bh=8Sh+n5yGf6PcpSFiR+fB7RqzISvu5Xb3MFlCMTJoktc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fh2V36ENK5e7XbEX6ky0+SS5Kp8TDB/scBfFnSAIpZXvxbEm4duh4I9I+PSckSoYm gSafgX+wD05K8OiEks63tmYeeNGgXeV1jtKqUqaLdIh60tUwmGUHEwkZQrIpSZyje/ e1fVTdRFU0k/KLj5LORVP1dtVSuHgRmqdWrLB8fQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Wenjie Qi , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 6.1 0113/1887] f2fs: limit recovery filename logging to stored length Date: Wed, 28 Oct 2026 17:36:49 +0100 Message-ID: <20261028170501.806919589@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170459.200466217@linuxfoundation.org> References: <20261028170459.200466217@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wenjie Qi [ Upstream commit 01027b2fcb74dade59fb833b51023f6593b6a9a2 ] F2FS stores recovery filenames as a length plus a fixed-size i_name buffer. The buffer is not NUL-terminated, but recover_inode() and recover_dentry() print it with %s. For a 255-byte filename, recovery logging can read past i_name into the following raw inode fields. Print the name with a precision bounded by i_namelen and F2FS_NAME_LEN. Fixes: f356fe0cba0e ("f2fs: add debug msgs in the recovery routine") Cc: stable@kernel.org Assisted-by: Codex:gpt-5.5 Signed-off-by: Wenjie Qi Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim [ inlined recover_printable_name() logic into the existing page-based recovery functions. ] Signed-off-by: Sasha Levin --- fs/f2fs/recovery.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index b33e5220aa187..45572d1d2d4ee 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -176,7 +176,8 @@ static int recover_dentry(struct inode *inode, struct page *ipage, struct inode *dir, *einode; struct fsync_inode_entry *entry; int err = 0; - char *name; + const char *name; + int name_len; entry = get_fsync_inode(dir_list, pino); if (!entry) { @@ -235,12 +236,16 @@ static int recover_dentry(struct inode *inode, struct page *ipage, out_put: f2fs_put_page(page, 0); out: - if (file_enc_name(inode)) + if (file_enc_name(inode)) { name = ""; - else + name_len = sizeof("") - 1; + } else { name = raw_inode->i_name; - f2fs_notice(F2FS_I_SB(inode), "%s: ino = %x, name = %s, dir = %lx, err = %d", - __func__, ino_of_node(ipage), name, + name_len = min_t(unsigned int, le32_to_cpu(raw_inode->i_namelen), + F2FS_NAME_LEN); + } + f2fs_notice(F2FS_I_SB(inode), "%s: ino = %x, name = %.*s, dir = %lx, err = %d", + __func__, ino_of_node(ipage), name_len, name, IS_ERR(dir) ? 0 : dir->i_ino, err); return err; } @@ -287,7 +292,8 @@ static void recover_inline_flags(struct inode *inode, struct f2fs_inode *ri) static int recover_inode(struct inode *inode, struct page *page) { struct f2fs_inode *raw = F2FS_INODE(page); - char *name; + const char *name; + int name_len; int err; inode->i_mode = le16_to_cpu(raw->i_mode); @@ -336,13 +342,18 @@ static int recover_inode(struct inode *inode, struct page *page) f2fs_mark_inode_dirty_sync(inode, true); - if (file_enc_name(inode)) + if (file_enc_name(inode)) { name = ""; - else - name = F2FS_INODE(page)->i_name; + name_len = sizeof("") - 1; + } else { + name = raw->i_name; + name_len = min_t(unsigned int, le32_to_cpu(raw->i_namelen), + F2FS_NAME_LEN); + } - f2fs_notice(F2FS_I_SB(inode), "recover_inode: ino = %x, name = %s, inline = %x", - ino_of_node(page), name, raw->i_inline); + f2fs_notice(F2FS_I_SB(inode), "%s: ino = %x, name = %.*s, inline = %x", + __func__, ino_of_node(page), name_len, name, + raw->i_inline); return 0; } -- 2.53.0