Skip to content

Commit 0145eed

Browse files
Yongpeng YangJaegeuk Kim
authored andcommitted
f2fs: Constrain the modification range of dir_level in the sysfs
The {struct f2fs_sb_info}->dir_level can be modified through the sysfs interface, but its value range is not limited. If the value exceeds MAX_DIR_HASH_DEPTH and the mount options include "noinline_dentry", the following error will occur: [root@fedora ~]# mount -o noinline_dentry /dev/sdb /mnt/sdb/ [root@fedora ~]# echo 128 > /sys/fs/f2fs/sdb/dir_level [root@fedora ~]# cd /mnt/sdb/ [root@fedora sdb]# mkdir test [root@fedora sdb]# cd test/ [root@fedora test]# mkdir test mkdir: cannot create directory 'test': Argument list too long Signed-off-by: Yongpeng Yang <yangyongpeng1@oppo.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 94e7eb4 commit 0145eed

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

fs/f2fs/sysfs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
741741
return count;
742742
}
743743

744+
if (!strcmp(a->attr.name, "dir_level")) {
745+
if (t > MAX_DIR_HASH_DEPTH)
746+
return -EINVAL;
747+
sbi->dir_level = t;
748+
return count;
749+
}
750+
744751
*ui = (unsigned int)t;
745752

746753
return count;

0 commit comments

Comments
 (0)