Skip to content

Commit ffcde4b

Browse files
gdhe55555Jaegeuk Kim
authored andcommitted
f2fs: remove write attribute of main_blkaddr sysfs node
Fuzzing main_blkaddr sysfs node will corrupt this field's value, causing kernel panic, remove its write attribute to avoid potential security risk. [Chao Yu: add description] Signed-off-by: Dehe Gu <[email protected]> Signed-off-by: Daiyue Zhang <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 0e5e811 commit ffcde4b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/f2fs/sysfs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ static ssize_t avg_vblocks_show(struct f2fs_attr *a,
223223
}
224224
#endif
225225

226+
static ssize_t main_blkaddr_show(struct f2fs_attr *a,
227+
struct f2fs_sb_info *sbi, char *buf)
228+
{
229+
return snprintf(buf, PAGE_SIZE, "%llu\n",
230+
(unsigned long long)MAIN_BLKADDR(sbi));
231+
}
232+
226233
static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
227234
struct f2fs_sb_info *sbi, char *buf)
228235
{
@@ -526,7 +533,6 @@ F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time);
526533
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_idle, gc_mode);
527534
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent, gc_mode);
528535
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments);
529-
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, main_blkaddr, main_blkaddr);
530536
F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards);
531537
F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_granularity, discard_granularity);
532538
F2FS_RW_ATTR(RESERVED_BLOCKS, f2fs_sb_info, reserved_blocks, reserved_blocks);
@@ -569,6 +575,7 @@ F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
569575
F2FS_GENERAL_RO_ATTR(unusable);
570576
F2FS_GENERAL_RO_ATTR(encoding);
571577
F2FS_GENERAL_RO_ATTR(mounted_time_sec);
578+
F2FS_GENERAL_RO_ATTR(main_blkaddr);
572579
#ifdef CONFIG_F2FS_STAT_FS
573580
F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count);
574581
F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count);

0 commit comments

Comments
 (0)