wangyan
d4a2dbaa11
ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans()
...
[ Upstream commit 9f16ca48fc818a17de8be1f75d08e7f4addc4497 ]
I found a NULL pointer dereference in ocfs2_update_inode_fsync_trans(),
handle->h_transaction may be NULL in this situation:
ocfs2_file_write_iter
->__generic_file_write_iter
->generic_perform_write
->ocfs2_write_begin
->ocfs2_write_begin_nolock
->ocfs2_write_cluster_by_desc
->ocfs2_write_cluster
->ocfs2_mark_extent_written
->ocfs2_change_extent_flag
->ocfs2_split_extent
->ocfs2_try_to_merge_extent
->ocfs2_extend_rotate_transaction
->ocfs2_extend_trans
->jbd2_journal_restart
->jbd2__journal_restart
// handle->h_transaction is NULL here
->handle->h_transaction = NULL;
->start_this_handle
/* journal aborted due to storage
network disconnection, return error */
->return -EROFS;
/* line 3806 in ocfs2_try_to_merge_extent (),
it will ignore ret error. */
->ret = 0;
->...
->ocfs2_write_end
->ocfs2_write_end_nolock
->ocfs2_update_inode_fsync_trans
// NULL pointer dereference
->oi->i_sync_tid = handle->h_transaction->t_tid;
The information of NULL pointer dereference as follows:
JBD2: Detected IO errors while flushing file data on dm-11-45
Aborting journal on device dm-11-45.
JBD2: Error -5 detected when updating journal superblock for dm-11-45.
(dd,22081,3):ocfs2_extend_trans:474 ERROR: status = -30
(dd,22081,3):ocfs2_try_to_merge_extent:3877 ERROR: status = -30
Unable to handle kernel NULL pointer dereference at
virtual address 0000000000000008
Mem abort info:
ESR = 0x96000004
Exception class = DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
Data abort info:
ISV = 0, ISS = 0x00000004
CM = 0, WnR = 0
user pgtable: 4k pages, 48-bit VAs, pgdp = 00000000e74e1338
[0000000000000008] pgd=0000000000000000
Internal error: Oops: 96000004 [#1 ] SMP
Process dd (pid: 22081, stack limit = 0x00000000584f35a9)
CPU: 3 PID: 22081 Comm: dd Kdump: loaded
Hardware name: Huawei TaiShan 2280 V2/BC82AMDD, BIOS 0.98 08/25/2019
pstate: 60400009 (nZCv daif +PAN -UAO)
pc : ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
lr : ocfs2_write_end_nolock+0x2a0/0x550 [ocfs2]
sp : ffff0000459fba70
x29: ffff0000459fba70 x28: 0000000000000000
x27: ffff807ccf7f1000 x26: 0000000000000001
x25: ffff807bdff57970 x24: ffff807caf1d4000
x23: ffff807cc79e9000 x22: 0000000000001000
x21: 000000006c6cd000 x20: ffff0000091d9000
x19: ffff807ccb239db0 x18: ffffffffffffffff
x17: 000000000000000e x16: 0000000000000007
x15: ffff807c5e15bd78 x14: 0000000000000000
x13: 0000000000000000 x12: 0000000000000000
x11: 0000000000000000 x10: 0000000000000001
x9 : 0000000000000228 x8 : 000000000000000c
x7 : 0000000000000fff x6 : ffff807a308ed6b0
x5 : ffff7e01f10967c0 x4 : 0000000000000018
x3 : d0bc661572445600 x2 : 0000000000000000
x1 : 000000001b2e0200 x0 : 0000000000000000
Call trace:
ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
ocfs2_write_end+0x4c/0x80 [ocfs2]
generic_perform_write+0x108/0x1a8
__generic_file_write_iter+0x158/0x1c8
ocfs2_file_write_iter+0x668/0x950 [ocfs2]
__vfs_write+0x11c/0x190
vfs_write+0xac/0x1c0
ksys_write+0x6c/0xd8
__arm64_sys_write+0x24/0x30
el0_svc_common+0x78/0x130
el0_svc_handler+0x38/0x78
el0_svc+0x8/0xc
To prevent NULL pointer dereference in this situation, we use
is_handle_aborted() before using handle->h_transaction->t_tid.
Link: http://lkml.kernel.org/r/03e750ab-9ade-83aa-b000-b9e81e34e539@huawei.com
Signed-off-by: Yan Wang <wangyan122@huawei.com>
Reviewed-by: Jun Piao <piaojun@huawei.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-02-28 15:42:41 +01:00
..
2019-10-17 13:42:10 -07:00
2019-08-06 18:29:35 +02:00
2018-05-30 07:50:16 +02:00
2020-01-29 10:24:34 +01:00
2019-12-21 10:40:46 +01:00
2016-10-15 12:09:13 -07:00
2018-12-01 09:44:19 +01:00
2020-02-28 15:42:15 +01:00
2018-12-17 09:38:34 +01:00
2019-11-28 18:28:34 +01:00
2020-02-28 15:42:39 +01:00
2019-08-06 18:29:38 +02:00
2019-11-12 19:15:51 +01:00
2018-11-13 11:17:03 -08:00
2019-07-21 09:05:59 +02:00
2019-05-08 07:19:10 +02:00
2019-03-23 13:19:47 +01:00
2019-12-21 10:41:21 +01:00
2020-02-28 15:42:11 +01:00
2016-10-10 20:16:43 -07:00
2018-11-27 16:09:38 +01:00
2020-01-29 10:24:03 +01:00
2020-02-14 16:31:05 -05:00
2020-02-28 15:42:12 +01:00
2020-01-23 08:19:37 +01:00
2019-10-07 18:53:18 +02:00
2018-12-17 09:38:34 +01:00
2019-12-21 10:41:30 +01:00
2019-12-05 15:34:36 +01:00
2019-11-28 18:28:50 +01:00
2019-11-28 18:28:49 +01:00
2016-10-10 20:16:43 -07:00
2016-10-10 20:16:43 -07:00
2019-05-31 06:48:12 -07:00
2017-11-30 08:39:04 +00:00
2020-02-28 15:42:38 +01:00
2019-05-08 07:19:09 +02:00
2020-01-29 10:24:19 +01:00
2019-11-25 09:52:23 +01:00
2018-11-13 11:17:02 -08:00
2016-10-10 20:16:43 -07:00
2016-10-10 20:16:43 -07:00
2019-03-13 14:04:52 -07:00
2020-02-14 16:31:09 -05:00
2018-02-03 17:05:38 +01:00
2020-02-14 16:31:06 -05:00
2018-05-30 07:50:16 +02:00
2019-02-06 17:33:30 +01:00
2016-10-30 13:09:42 -04:00
2020-02-28 15:42:41 +01:00
2016-10-10 20:16:43 -07:00
2016-09-27 21:06:21 -04:00
2019-11-25 09:53:50 +01:00
2019-10-05 12:30:34 +02:00
2019-11-25 09:53:44 +01:00
2020-01-12 11:24:20 +01:00
2020-01-04 13:40:50 +01:00
2016-10-10 20:16:43 -07:00
2020-02-28 15:42:24 +01:00
2017-06-17 06:41:56 +02:00
2018-09-05 09:20:03 +02:00
2018-09-05 09:20:10 +02:00
2018-12-17 09:38:32 +01:00
2016-09-27 21:06:21 -04:00
2020-02-14 16:31:00 -05:00
2020-02-28 15:42:30 +01:00
2019-05-25 18:26:56 +02:00
2020-01-29 10:24:00 +01:00
2018-12-21 14:11:31 +01:00
2016-10-10 20:16:43 -07:00
2017-01-09 08:32:24 +01:00
2018-09-26 08:36:37 +02:00
2019-07-10 09:55:38 +02:00
2018-06-26 08:08:09 +08:00
2019-11-06 12:18:04 +01:00
2019-01-23 08:10:56 +01:00
2019-04-05 22:29:08 +02:00
2020-01-14 20:04:25 +01:00
2018-02-25 11:05:55 +01:00
2020-01-12 11:24:17 +01:00
2016-09-27 21:20:53 -04:00
2017-07-05 14:40:26 +02:00
2018-02-28 10:18:33 +01:00
2019-03-27 14:13:04 +09:00
2019-03-05 17:57:05 +01:00
2019-03-13 14:04:58 -07:00
2019-02-12 19:44:59 +01:00
2019-08-04 09:33:45 +02:00
2018-01-31 12:55:52 +01:00
2019-04-05 22:29:07 +02:00
2019-11-12 19:16:11 +01:00
2019-06-22 08:17:24 +02:00
2017-09-20 08:20:01 +02:00
2016-09-15 13:29:52 -07:00
2017-09-20 08:19:59 +02:00
2016-10-07 18:46:29 -07:00
2019-10-17 13:42:45 -07:00
2020-01-12 11:24:13 +01:00
2018-02-22 15:43:48 +01:00
2017-07-21 07:42:22 +02:00
2017-10-18 09:35:39 +02:00
2020-02-05 13:05:43 +00:00
2018-11-21 09:26:02 +01:00
2018-02-17 13:21:15 +01:00
2019-08-04 09:33:43 +02:00
2019-06-11 12:22:45 +02:00
2017-07-21 07:42:22 +02:00
2017-03-15 10:02:43 +08:00
2017-01-26 08:24:37 +01:00
2019-06-11 12:22:49 +02:00
2020-01-04 13:41:06 +01:00
2016-10-11 15:06:30 -07:00
2016-10-07 18:46:30 -07:00
2019-06-11 12:22:45 +02:00
2017-06-14 15:06:01 +02:00
2019-02-06 17:33:29 +01:00
2017-05-08 07:47:54 +02:00
2019-09-06 10:19:37 +02:00
2016-10-08 11:06:08 -04:00
2018-10-10 08:53:22 +02:00