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=1793208372; b=yMJQW9iijiw4RpscegfHb0ok6dNbixIjM54jGSZwFOVKWXjKMN6OSEeK+EJ8FNqp4/fT Ganhoq/zowpgRVoDj+2iagg0KhubTOiAjW2nTlIdU+Hn6BbDbet5q+qDaCJfRYu7zx3/m I/KPwlcZTvIH/8C+qSjb3ufkacZRziC3lEzwMivMD7RP2FDr/8tQRbqS0cTr3SeuitnKA gyupaJ7jZWIyQoa1pPseP/QNpIWl9kTSTiqACZtmjVoxGG2WgM15YIqslqcoFxxVTMl8s UZmQW9NM53Z5OFsTEb3IAxaeptjrUV4Xpot4OQgtevoUlFFizKOglWFq7sqkf0OUAHg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793208372; 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=sgWNatajBUM2VG4B07TN3Gvpw8Ax6ViP/SH92YfkgZk=; b=zdBxKso+xBhAiB/UIzbIZ6tbgocjIqr1KLpC+3M+a6ULIZueXViuHn1FglwPhinh9dGK 87SI8Bl3bganAojhAy+cZ06LRA1jvxGPOhQt+djarbYnlrXblHhvv+B5E2wnwYadR2ZQS p+nDWq9UfLA2O9FrJbu9g3vHQdP3rgt9jPysHDN4C/x/BMzxzHQnRjr1rCf0PrbfTP5gA LCHwSqxR+Mq/QZeXESje70lI+nj1icQd/FgUNPOsPdP2ao/KaxkpOoBpvKUr9smmBnqSn ZVnPYRALBvT+GqZcTHXtoRg6hU3c+WBm9a58ELW5J81FgKRlNZLwiTf+3dNFNT4SVqA== 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=V7qbS6Ro; 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 1EF16606A31A; Wed, 28 Oct 2026 17:26:11 +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=V7qbS6Ro Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D5B01F01825; Wed, 28 Oct 2026 17:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793208371; bh=sgWNatajBUM2VG4B07TN3Gvpw8Ax6ViP/SH92YfkgZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V7qbS6RoxObjqnpF4IwSHCXweiYw2wyvQA5TG5T9V0SWapmGZ5juk/807VTBk9HtE 37jYG8P01QlZr68Y+Sa9wpWhkvzlSBvN3cp4tyM38eW6gmKfo+FZWRhLfWXnYunA6v snKddyGsS4v1atl958rkbrxRQ+ZeEcQlbhmqt+6o= 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 5.10 094/516] f2fs: limit recovery filename logging to stored length Date: Wed, 28 Oct 2026 17:54:06 +0100 Message-ID: <20261028170005.749674616@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170003.522232767@linuxfoundation.org> References: <20261028170003.522232767@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 5.10-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 320553b45ee9c..63bea9eb4031d 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -156,7 +156,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) { @@ -215,12 +216,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; } @@ -267,7 +272,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); @@ -317,13 +323,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