FAILED: patch "[PATCH] f2fs: limit recovery filename logging to stored length" failed to apply to 6.6-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 01027b2fcb74dade59fb833b51023f6593b6a9a2
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090932-used-copartner-4981@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 01027b2fcb74dade59fb833b51023f6593b6a9a2 Mon Sep 17 00:00:00 2001
From: Wenjie Qi <[email protected]>
Date: Tue, 30 Jun 2026 16:23:30 +0800
Subject: [PATCH] f2fs: limit recovery filename logging to stored length
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.
fs/f2fs/recovery.c +27 -14
@@ -158,6 +158,22 @@ static int init_recovered_filename(const struct inode *dir,return 0 ; } +static const char *recover_printable_name (struct inode *inode, +struct f2fs_inode *raw, +int *name_len) +{ +static const char encrypted_name[] ="<encrypted>" ; + +if (file_enc_name (inode)) { + *name_len =sizeof (encrypted_name) -1 ; +return encrypted_name; + } + + *name_len = min_t(unsigned int, le32_to_cpu(raw->i_namelen), +F2FS_NAME_LEN ); +return raw->i_name; +} +static int recover_dentry (struct inode *inode,struct folio *ifolio,struct list_head *dir_list) {
@@ -170,7 +186,8 @@ static int recover_dentry(struct inode *inode, struct folio *ifolio,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) {
@@ -229,12 +246,9 @@ static int recover_dentry(struct inode *inode, struct folio *ifolio, out_put:f2fs_folio_put (folio, false); out: -if (file_enc_name (inode)) - name ="<encrypted>" ; -else - name = raw_inode->i_name; -f2fs_notice (F2FS_I_SB (inode),"%s: ino = %x, name = %s, dir = %llu, err = %d" , - __func__,ino_of_node (ifolio), name, + name =recover_printable_name (inode, raw_inode, &name_len); +f2fs_notice (F2FS_I_SB (inode),"%s: ino = %x, name = %.*s, dir = %llu, err = %d" , + __func__,ino_of_node (ifolio), name_len, name,IS_ERR (dir) ?0 : dir->i_ino, err);return err; }
@@ -282,7 +296,8 @@ static int recover_inode(struct inode *inode, struct folio *folio) {struct f2fs_inode *raw =F2FS_INODE (folio);struct f2fs_inode_info *fi =F2FS_I (inode); -char *name; +const char *name; +int name_len;int err; inode->i_mode =le16_to_cpu (raw->i_mode);
@@ -331,13 +346,11 @@ static int recover_inode(struct inode *inode, struct folio *folio)f2fs_mark_inode_dirty_sync (inode, true); -if (file_enc_name (inode)) - name ="<encrypted>" ; -else - name =F2FS_INODE (folio)->i_name; + name =recover_printable_name (inode, raw, &name_len); -f2fs_notice (F2FS_I_SB (inode),"recover_inode: ino = %x, name = %s, inline = %x" , -ino_of_node (folio), name, raw->i_inline); +f2fs_notice (F2FS_I_SB (inode),"%s: ino = %x, name = %.*s, inline = %x" , + __func__,ino_of_node (folio), name_len, name, + raw->i_inline);return 0 ; }
Sasha Levin
maintainerPATCH 1/1 f2fs: limit recovery filename logging to stored length
From: Wenjie Qi <[email protected]>
[ 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.
--- fs/f2fs/recovery.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
fs/f2fs/recovery.c +22 -11
@@ -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 ="<encrypted>" ; -else + name_len =sizeof ("<encrypted>" ) -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 ="<encrypted>" ; -else - name =F2FS_INODE (page)->i_name; + name_len =sizeof ("<encrypted>" ) -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 ; }
Signature · 1 line
2.53.0