Skip to content

Commit 62f63ee

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix NULL pointer dereference in f2fs_write_begin()
BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:f2fs_write_begin+0x823/0xb90 [f2fs] Call Trace: f2fs_quota_write+0x139/0x1d0 [f2fs] write_blk+0x36/0x80 [quota_tree] get_free_dqblk+0x42/0xa0 [quota_tree] do_insert_tree+0x235/0x4a0 [quota_tree] do_insert_tree+0x26e/0x4a0 [quota_tree] do_insert_tree+0x26e/0x4a0 [quota_tree] do_insert_tree+0x26e/0x4a0 [quota_tree] qtree_write_dquot+0x70/0x190 [quota_tree] v2_write_dquot+0x43/0x90 [quota_v2] dquot_acquire+0x77/0x100 f2fs_dquot_acquire+0x2f/0x60 [f2fs] dqget+0x310/0x450 dquot_transfer+0x7e/0x120 f2fs_setattr+0x11a/0x4a0 [f2fs] notify_change+0x349/0x480 chown_common+0x168/0x1c0 do_fchownat+0xbc/0xf0 __x64_sys_fchownat+0x20/0x30 do_syscall_64+0x5f/0x220 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Passing fsdata parameter to .write_{begin,end} in f2fs_quota_write(), so that if quota file is compressed one, we can avoid above NULL pointer dereference when updating quota content. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 8c7d4b5 commit 62f63ee

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/f2fs/super.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,7 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,
19291929
int offset = off & (sb->s_blocksize - 1);
19301930
size_t towrite = len;
19311931
struct page *page;
1932+
void *fsdata = NULL;
19321933
char *kaddr;
19331934
int err = 0;
19341935
int tocopy;
@@ -1938,7 +1939,7 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,
19381939
towrite);
19391940
retry:
19401941
err = a_ops->write_begin(NULL, mapping, off, tocopy, 0,
1941-
&page, NULL);
1942+
&page, &fsdata);
19421943
if (unlikely(err)) {
19431944
if (err == -ENOMEM) {
19441945
congestion_wait(BLK_RW_ASYNC,
@@ -1955,7 +1956,7 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,
19551956
flush_dcache_page(page);
19561957

19571958
a_ops->write_end(NULL, mapping, off, tocopy, tocopy,
1958-
page, NULL);
1959+
page, fsdata);
19591960
offset = 0;
19601961
towrite -= tocopy;
19611962
off += tocopy;

0 commit comments

Comments
 (0)