Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport fix for f2fs NULL pointer dereference in f2fs_issue_flush() #5599

Merged
merged 1 commit into from
Sep 10, 2023

Conversation

pelwell
Copy link
Contributor

@pelwell pelwell commented Sep 9, 2023

Backport of commit b3d8306 ("f2fs: fix to avoid NULL pointer dereference in f2fs_issue_flush()").

See #5598

commit b3d8306 upstream.

With below two cases, it will cause NULL pointer dereference when
accessing SM_I(sbi)->fcc_info in f2fs_issue_flush().

a) If kthread_run() fails in f2fs_create_flush_cmd_control(), it will
release SM_I(sbi)->fcc_info,

- mount -o noflush_merge /dev/vda /mnt/f2fs
- mount -o remount,flush_merge /dev/vda /mnt/f2fs  -- kthread_run() fails
- dd if=/dev/zero of=/mnt/f2fs/file bs=4k count=1 conv=fsync

b) we will never allocate memory for SM_I(sbi)->fcc_info w/ below
testcase,

- mount -o ro /dev/vda /mnt/f2fs
- mount -o rw,remount /dev/vda /mnt/f2fs
- dd if=/dev/zero of=/mnt/f2fs/file bs=4k count=1 conv=fsync

In order to fix this issue, let change as below:
- fix error path handling in f2fs_create_flush_cmd_control().
- allocate SM_I(sbi)->fcc_info even if readonly is on.

Signed-off-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
@pelwell pelwell merged commit bf9fb25 into raspberrypi:rpi-6.1.y Sep 10, 2023
@pelwell pelwell deleted the f2fsfix branch September 10, 2023 08:32
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Sep 14, 2023
kernel: ASoC: hdmi-codec: Fix broken channel map reporting
See: raspberrypi/linux#5597

kernel: Backport fix for f2fs NULL pointer dereference in f2fs_issue_flush()
See: raspberrypi/linux#5599
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Sep 14, 2023
kernel: ASoC: hdmi-codec: Fix broken channel map reporting
See: raspberrypi/linux#5597

kernel: Backport fix for f2fs NULL pointer dereference in f2fs_issue_flush()
See: raspberrypi/linux#5599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants