* [PATCH RESEND] btrfs: fix error handling in free_log_tree
@ 2018-09-06 20:59 jeffm
2018-09-07 12:00 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: jeffm @ 2018-09-06 20:59 UTC (permalink / raw)
To: linux-btrfs; +Cc: Jeff Mahoney, stable
From: Jeff Mahoney <jeffm@suse.com>
When we hit an I/O error in free_log_tree->walk_log_tree during file system
shutdown we can crash due to there not being a valid transaction handle.
Use btrfs_handle_fs_error when there's no transaction handle to use.
BUG: unable to handle kernel NULL pointer dereference at 0000000000000060
IP: free_log_tree+0xd2/0x140 [btrfs]
PGD 0 P4D 0
Oops: 0000 [#1] SMP DEBUG_PAGEALLOC PTI
Modules linked in: <modules>
CPU: 2 PID: 23544 Comm: umount Tainted: G W 4.12.14-kvmsmall #9 SLE15 (unreleased)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
task: ffff96bfd3478880 task.stack: ffffa7cf40d78000
RIP: 0010:free_log_tree+0xd2/0x140 [btrfs]
RSP: 0018:ffffa7cf40d7bd10 EFLAGS: 00010282
RAX: 00000000fffffffb RBX: 00000000fffffffb RCX: 0000000000000002
RDX: 0000000000000000 RSI: ffff96c02f07d4c8 RDI: 0000000000000282
RBP: ffff96c013cf1000 R08: ffff96c02f07d4c8 R09: ffff96c02f07d4d0
R10: 0000000000000000 R11: 0000000000000002 R12: 0000000000000000
R13: ffff96c005e800c0 R14: ffffa7cf40d7bdb8 R15: 0000000000000000
FS: 00007f17856bcfc0(0000) GS:ffff96c03f600000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000060 CR3: 0000000045ed6002 CR4: 00000000003606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
? wait_for_writer+0xb0/0xb0 [btrfs]
btrfs_free_log+0x17/0x30 [btrfs]
btrfs_drop_and_free_fs_root+0x9a/0xe0 [btrfs]
btrfs_free_fs_roots+0xc0/0x130 [btrfs]
? wait_for_completion+0xf2/0x100
close_ctree+0xea/0x2e0 [btrfs]
? kthread_stop+0x161/0x260
generic_shutdown_super+0x6c/0x120
kill_anon_super+0xe/0x20
btrfs_kill_super+0x13/0x100 [btrfs]
deactivate_locked_super+0x3f/0x70
cleanup_mnt+0x3b/0x70
task_work_run+0x78/0x90
exit_to_usermode_loop+0x77/0xa6
do_syscall_64+0x1c5/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x7f1784f90827
RSP: 002b:00007ffdeeb03118 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 0000556a60c62970 RCX: 00007f1784f90827
RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000556a60c62b50
RBP: 0000000000000000 R08: 0000000000000005 R09: 00000000ffffffff
R10: 0000556a60c63900 R11: 0000000000000246 R12: 0000556a60c62b50
R13: 00007f17854a81c4 R14: 0000000000000000 R15: 0000000000000000
Code: 65 a1 fd ff be 01 00 00 00 48 89 ef e8 58 a1 fd ff 48 8b 7d 00 e8 9f 33 fe ff 48 89 ef e8 17 6c d3 ed 48 83 c4 50 5b 5d 41 5c c3 <49> 8b 44 24 60 f0 0f ba a8 80 65 01 00 02 72 23 83 fb fb 75 39
RIP: free_log_tree+0xd2/0x140 [btrfs] RSP: ffffa7cf40d7bd10
CR2: 0000000000000060
---[ end trace 3bc199fbf8fb4977 ]---
Cc: <stable@vger.kernel.org> # v3.13
Fixes: 681ae50917df9 (Btrfs: cleanup reserved space when freeing tree log on error)
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/btrfs/tree-log.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index f8220ec02036..a5f6971a125f 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3143,9 +3143,12 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
};
ret = walk_log_tree(trans, log, &wc);
- /* I don't think this can happen but just in case */
- if (ret)
- btrfs_abort_transaction(trans, ret);
+ if (ret) {
+ if (trans)
+ btrfs_abort_transaction(trans, ret);
+ else
+ btrfs_handle_fs_error(log->fs_info, ret, NULL);
+ }
while (1) {
ret = find_first_extent_bit(&log->dirty_log_pages,
--
2.12.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] btrfs: fix error handling in free_log_tree
2018-09-06 20:59 [PATCH RESEND] btrfs: fix error handling in free_log_tree jeffm
@ 2018-09-07 12:00 ` David Sterba
2018-09-07 13:00 ` Jeff Mahoney
0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2018-09-07 12:00 UTC (permalink / raw)
To: jeffm; +Cc: linux-btrfs, stable
On Thu, Sep 06, 2018 at 04:59:33PM -0400, jeffm@suse.com wrote:
> From: Jeff Mahoney <jeffm@suse.com>
If this is a resend, I can't find the previous postings, same or similar
subject.
> When we hit an I/O error in free_log_tree->walk_log_tree during file system
> shutdown we can crash due to there not being a valid transaction handle.
>
> Use btrfs_handle_fs_error when there's no transaction handle to use.
>
> BUG: unable to handle kernel NULL pointer dereference at 0000000000000060
> IP: free_log_tree+0xd2/0x140 [btrfs]
> PGD 0 P4D 0
> Oops: 0000 [#1] SMP DEBUG_PAGEALLOC PTI
> Modules linked in: <modules>
> CPU: 2 PID: 23544 Comm: umount Tainted: G W 4.12.14-kvmsmall #9 SLE15 (unreleased)
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
> task: ffff96bfd3478880 task.stack: ffffa7cf40d78000
> RIP: 0010:free_log_tree+0xd2/0x140 [btrfs]
> RSP: 0018:ffffa7cf40d7bd10 EFLAGS: 00010282
> RAX: 00000000fffffffb RBX: 00000000fffffffb RCX: 0000000000000002
> RDX: 0000000000000000 RSI: ffff96c02f07d4c8 RDI: 0000000000000282
> RBP: ffff96c013cf1000 R08: ffff96c02f07d4c8 R09: ffff96c02f07d4d0
> R10: 0000000000000000 R11: 0000000000000002 R12: 0000000000000000
> R13: ffff96c005e800c0 R14: ffffa7cf40d7bdb8 R15: 0000000000000000
> FS: 00007f17856bcfc0(0000) GS:ffff96c03f600000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 0000000000000060 CR3: 0000000045ed6002 CR4: 00000000003606e0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> ? wait_for_writer+0xb0/0xb0 [btrfs]
> btrfs_free_log+0x17/0x30 [btrfs]
> btrfs_drop_and_free_fs_root+0x9a/0xe0 [btrfs]
> btrfs_free_fs_roots+0xc0/0x130 [btrfs]
> ? wait_for_completion+0xf2/0x100
> close_ctree+0xea/0x2e0 [btrfs]
> ? kthread_stop+0x161/0x260
> generic_shutdown_super+0x6c/0x120
> kill_anon_super+0xe/0x20
> btrfs_kill_super+0x13/0x100 [btrfs]
> deactivate_locked_super+0x3f/0x70
> cleanup_mnt+0x3b/0x70
> task_work_run+0x78/0x90
> exit_to_usermode_loop+0x77/0xa6
> do_syscall_64+0x1c5/0x1e0
> entry_SYSCALL_64_after_hwframe+0x42/0xb7
> RIP: 0033:0x7f1784f90827
> RSP: 002b:00007ffdeeb03118 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
> RAX: 0000000000000000 RBX: 0000556a60c62970 RCX: 00007f1784f90827
> RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000556a60c62b50
> RBP: 0000000000000000 R08: 0000000000000005 R09: 00000000ffffffff
> R10: 0000556a60c63900 R11: 0000000000000246 R12: 0000556a60c62b50
> R13: 00007f17854a81c4 R14: 0000000000000000 R15: 0000000000000000
> Code: 65 a1 fd ff be 01 00 00 00 48 89 ef e8 58 a1 fd ff 48 8b 7d 00 e8 9f 33 fe ff 48 89 ef e8 17 6c d3 ed 48 83 c4 50 5b 5d 41 5c c3 <49> 8b 44 24 60 f0 0f ba a8 80 65 01 00 02 72 23 83 fb fb 75 39
> RIP: free_log_tree+0xd2/0x140 [btrfs] RSP: ffffa7cf40d7bd10
> CR2: 0000000000000060
> ---[ end trace 3bc199fbf8fb4977 ]---
>
> Cc: <stable@vger.kernel.org> # v3.13
> Fixes: 681ae50917df9 (Btrfs: cleanup reserved space when freeing tree log on error)
> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
> ---
> fs/btrfs/tree-log.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index f8220ec02036..a5f6971a125f 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -3143,9 +3143,12 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
> };
>
> ret = walk_log_tree(trans, log, &wc);
> - /* I don't think this can happen but just in case */
Example of a very useful comment :)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] btrfs: fix error handling in free_log_tree
2018-09-07 12:00 ` David Sterba
@ 2018-09-07 13:00 ` Jeff Mahoney
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Mahoney @ 2018-09-07 13:00 UTC (permalink / raw)
To: dsterba, linux-btrfs, stable
[-- Attachment #1.1: Type: text/plain, Size: 4092 bytes --]
On 9/7/18 8:00 AM, David Sterba wrote:
> On Thu, Sep 06, 2018 at 04:59:33PM -0400, jeffm@suse.com wrote:
>> From: Jeff Mahoney <jeffm@suse.com>
>
> If this is a resend, I can't find the previous postings, same or similar
> subject.
I had tagged it as submitted in March, but I can't find any posting of
it either.
>> When we hit an I/O error in free_log_tree->walk_log_tree during file system
>> shutdown we can crash due to there not being a valid transaction handle.
>>
>> Use btrfs_handle_fs_error when there's no transaction handle to use.
>>
>> BUG: unable to handle kernel NULL pointer dereference at 0000000000000060
>> IP: free_log_tree+0xd2/0x140 [btrfs]
>> PGD 0 P4D 0
>> Oops: 0000 [#1] SMP DEBUG_PAGEALLOC PTI
>> Modules linked in: <modules>
>> CPU: 2 PID: 23544 Comm: umount Tainted: G W 4.12.14-kvmsmall #9 SLE15 (unreleased)
>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
>> task: ffff96bfd3478880 task.stack: ffffa7cf40d78000
>> RIP: 0010:free_log_tree+0xd2/0x140 [btrfs]
>> RSP: 0018:ffffa7cf40d7bd10 EFLAGS: 00010282
>> RAX: 00000000fffffffb RBX: 00000000fffffffb RCX: 0000000000000002
>> RDX: 0000000000000000 RSI: ffff96c02f07d4c8 RDI: 0000000000000282
>> RBP: ffff96c013cf1000 R08: ffff96c02f07d4c8 R09: ffff96c02f07d4d0
>> R10: 0000000000000000 R11: 0000000000000002 R12: 0000000000000000
>> R13: ffff96c005e800c0 R14: ffffa7cf40d7bdb8 R15: 0000000000000000
>> FS: 00007f17856bcfc0(0000) GS:ffff96c03f600000(0000) knlGS:0000000000000000
>> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>> CR2: 0000000000000060 CR3: 0000000045ed6002 CR4: 00000000003606e0
>> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>> Call Trace:
>> ? wait_for_writer+0xb0/0xb0 [btrfs]
>> btrfs_free_log+0x17/0x30 [btrfs]
>> btrfs_drop_and_free_fs_root+0x9a/0xe0 [btrfs]
>> btrfs_free_fs_roots+0xc0/0x130 [btrfs]
>> ? wait_for_completion+0xf2/0x100
>> close_ctree+0xea/0x2e0 [btrfs]
>> ? kthread_stop+0x161/0x260
>> generic_shutdown_super+0x6c/0x120
>> kill_anon_super+0xe/0x20
>> btrfs_kill_super+0x13/0x100 [btrfs]
>> deactivate_locked_super+0x3f/0x70
>> cleanup_mnt+0x3b/0x70
>> task_work_run+0x78/0x90
>> exit_to_usermode_loop+0x77/0xa6
>> do_syscall_64+0x1c5/0x1e0
>> entry_SYSCALL_64_after_hwframe+0x42/0xb7
>> RIP: 0033:0x7f1784f90827
>> RSP: 002b:00007ffdeeb03118 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
>> RAX: 0000000000000000 RBX: 0000556a60c62970 RCX: 00007f1784f90827
>> RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000556a60c62b50
>> RBP: 0000000000000000 R08: 0000000000000005 R09: 00000000ffffffff
>> R10: 0000556a60c63900 R11: 0000000000000246 R12: 0000556a60c62b50
>> R13: 00007f17854a81c4 R14: 0000000000000000 R15: 0000000000000000
>> Code: 65 a1 fd ff be 01 00 00 00 48 89 ef e8 58 a1 fd ff 48 8b 7d 00 e8 9f 33 fe ff 48 89 ef e8 17 6c d3 ed 48 83 c4 50 5b 5d 41 5c c3 <49> 8b 44 24 60 f0 0f ba a8 80 65 01 00 02 72 23 83 fb fb 75 39
>> RIP: free_log_tree+0xd2/0x140 [btrfs] RSP: ffffa7cf40d7bd10
>> CR2: 0000000000000060
>> ---[ end trace 3bc199fbf8fb4977 ]---
>>
>> Cc: <stable@vger.kernel.org> # v3.13
>> Fixes: 681ae50917df9 (Btrfs: cleanup reserved space when freeing tree log on error)
>> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
>
> Reviewed-by: David Sterba <dsterba@suse.com>
>
>> ---
>> fs/btrfs/tree-log.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
>> index f8220ec02036..a5f6971a125f 100644
>> --- a/fs/btrfs/tree-log.c
>> +++ b/fs/btrfs/tree-log.c
>> @@ -3143,9 +3143,12 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
>> };
>>
>> ret = walk_log_tree(trans, log, &wc);
>> - /* I don't think this can happen but just in case */
>
> Example of a very useful comment :)
Heh, I think it was true when the comment was added. :)
-Jeff
--
Jeff Mahoney
SUSE Labs
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-07 17:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-06 20:59 [PATCH RESEND] btrfs: fix error handling in free_log_tree jeffm
2018-09-07 12:00 ` David Sterba
2018-09-07 13:00 ` Jeff Mahoney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).