David Howells
db20a8925b
cachefiles: Fix race between inactivating and culling a cache object
There's a race between cachefiles_mark_object_inactive() and
cachefiles_cull():
(1) cachefiles_cull() can't delete a backing file until the cache object
is marked inactive, but as soon as that's the case it's fair game.
(2) cachefiles_mark_object_inactive() marks the object as being inactive
and *only then* reads the i_blocks on the backing inode - but
cachefiles_cull() might've managed to delete it by this point.
Fix this by making sure cachefiles_mark_object_inactive() gets any data it
needs from the backing inode before deactivating the object.
Without this, the following oops may occur:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
IP: [<ffffffffa06c5cc1>] cachefiles_mark_object_inactive+0x61/0xb0 [cachefiles]
...
CPU: 11 PID: 527 Comm: kworker/u64:4 Tainted: G I ------------ 3.10.0-470.el7.x86_64 #1
Hardware name: Hewlett-Packard HP Z600 Workstation/0B54h, BIOS 786G4 v03.19 03/11/2011
Workqueue: fscache_object fscache_object_work_func [fscache]
task: ffff880035edaf10 ti: ffff8800b77c0000 task.ti: ffff8800b77c0000
RIP: 0010:[<ffffffffa06c5cc1>] cachefiles_mark_object_inactive+0x61/0xb0 [cachefiles]
RSP: 0018:ffff8800b77c3d70 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff8800bf6cc400 RCX: 0000000000000034
RDX: 0000000000000000 RSI: ffff880090ffc710 RDI: ffff8800bf761ef8
RBP: ffff8800b77c3d88 R08: 2000000000000000 R09: 0090ffc710000000
R10: ff51005d2ff1c400 R11: 0000000000000000 R12: ffff880090ffc600
R13: ffff8800bf6cc520 R14: ffff8800bf6cc400 R15: ffff8800bf6cc498
FS: 0000000000000000(0000) GS:ffff8800bb8c0000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000000098 CR3: 00000000019ba000 CR4: 00000000000007e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Stack:
ffff880090ffc600 ffff8800bf6cc400 ffff8800867df140 ffff8800b77c3db0
ffffffffa06c48cb ffff880090ffc600 ffff880090ffc180 ffff880090ffc658
ffff8800b77c3df0 ffffffffa085d846 ffff8800a96b8150 ffff880090ffc600
Call Trace:
[<ffffffffa06c48cb>] cachefiles_drop_object+0x6b/0xf0 [cachefiles]
[<ffffffffa085d846>] fscache_drop_object+0xd6/0x1e0 [fscache]
[<ffffffffa085d615>] fscache_object_work_func+0xa5/0x200 [fscache]
[<ffffffff810a605b>] process_one_work+0x17b/0x470
[<ffffffff810a6e96>] worker_thread+0x126/0x410
[<ffffffff810a6d70>] ? rescuer_thread+0x460/0x460
[<ffffffff810ae64f>] kthread+0xcf/0xe0
[<ffffffff810ae580>] ? kthread_create_on_node+0x140/0x140
[<ffffffff81695418>] ret_from_fork+0x58/0x90
[<ffffffff810ae580>] ? kthread_create_on_node+0x140/0x140
The oopsing code shows:
callq 0xffffffff810af6a0 <wake_up_bit>
mov 0xf8(%r12),%rax
mov 0x30(%rax),%rax
mov 0x98(%rax),%rax <---- oops here
lock add %rax,0x130(%rbx)
where this is:
d_backing_inode(object->dentry)->i_blocks
Fixes: a5b3a80b89 (CacheFiles: Provide read-and-reset release counters for cachefilesd)
Reported-by: Jianhong Yin <jiyin@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Steve Dickson <steved@redhat.com>
cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-08-03 13:33:26 -04:00
..
2016-08-03 11:12:12 -04:00
2016-07-31 16:37:25 -04:00
2016-07-31 16:37:25 -04:00
2016-06-10 18:14:47 -07:00
2016-07-28 12:26:31 -07:00
2016-05-23 17:04:14 -07:00
2016-05-09 11:41:14 -04:00
2016-07-26 19:55:54 -07:00
2016-08-03 13:33:26 -04:00
2016-07-28 12:26:31 -07:00
2016-07-31 16:37:25 -04:00
2016-05-29 19:08:00 -04:00
2016-07-10 21:02:18 +09:00
2016-05-09 11:41:14 -04:00
2016-06-07 13:41:38 -06:00
2016-06-30 23:34:49 -04:00
2016-06-05 10:36:01 -07:00
2016-06-23 11:55:58 -05:00
2016-07-08 10:35:28 -05:00
2016-07-31 16:37:25 -04:00
2016-05-20 17:58:30 -07:00
2016-06-07 13:41:38 -06:00
2016-05-02 19:49:29 -04:00
2016-07-26 19:55:54 -07:00
2016-07-28 12:59:05 -07:00
2016-07-28 12:59:05 -07:00
2016-07-31 16:37:25 -04:00
2016-06-13 10:20:39 +02:00
2016-06-30 23:34:49 -04:00
2016-07-29 12:29:15 -07:00
2016-07-26 15:37:51 -07:00
2016-07-31 16:37:25 -04:00
2016-07-31 16:37:25 -04:00
2016-05-12 19:49:30 -04:00
2016-07-31 16:37:25 -04:00
2016-04-04 10:41:08 -07:00
2016-07-31 16:37:25 -04:00
2016-07-26 18:35:55 -07:00
2016-06-10 20:21:46 -07:00
2016-07-31 16:37:25 -04:00
2016-06-10 20:21:46 -07:00
2016-07-28 12:59:05 -07:00
2016-07-28 12:26:31 -07:00
2016-05-02 19:49:32 -04:00
2016-07-31 16:37:25 -04:00
2016-07-28 18:20:09 -07:00
2016-07-28 12:59:05 -07:00
2016-07-26 15:03:07 -07:00
2016-05-19 19:12:14 -07:00
2016-07-28 12:59:05 -07:00
2016-07-28 14:22:25 -07:00
2016-05-09 11:41:14 -04:00
2016-05-09 11:41:14 -04:00
2016-07-28 12:59:05 -07:00
2016-07-29 12:05:25 +02:00
2016-07-31 16:37:25 -04:00
2016-06-14 11:34:39 -07:00
2016-05-09 11:41:14 -04:00
2016-05-09 11:41:14 -04:00
2016-06-19 18:09:31 +02:00
2016-05-20 17:58:30 -07:00
2016-07-26 15:37:51 -07:00
2016-05-09 11:41:15 -04:00
2016-06-07 13:41:38 -06:00
2016-06-10 20:21:46 -07:00
2016-05-29 16:22:07 -04:00
2016-06-23 00:29:53 +02:00
2016-07-26 15:37:51 -07:00
2016-07-28 12:59:05 -07:00
2016-07-28 12:59:05 -07:00
2016-05-23 17:04:14 -07:00
2016-01-22 18:04:28 -05:00
2016-05-27 20:09:16 -04:00
2016-05-28 16:34:59 -07:00
2016-06-07 22:07:09 -04:00
2016-06-07 22:07:09 -04:00
2016-05-27 15:26:11 -07:00
2016-05-29 19:14:03 -04:00
2016-07-28 12:59:05 -07:00
2016-07-27 09:53:35 -07:00
2016-07-14 16:21:53 +09:00
2016-06-28 10:00:13 -03:00
2016-05-24 12:55:26 -07:00
2016-06-07 22:07:09 -04:00
2016-07-28 17:38:16 -07:00
2016-07-31 16:37:25 -04:00
2016-06-07 13:41:38 -06:00
2016-03-22 15:36:02 -07:00
2016-05-19 19:12:14 -07:00
2016-05-23 17:04:14 -07:00
2016-03-22 15:36:02 -07:00
2016-05-02 19:49:28 -04:00
2016-01-19 12:02:23 -05:00
2016-07-28 16:07:41 -07:00
2016-08-03 13:31:51 -04:00
2016-08-03 13:31:51 -04:00
2016-07-28 15:23:12 -07:00
2016-06-21 09:38:45 +10:00
2016-06-21 09:23:11 +10:00
2016-05-23 17:04:14 -07:00
2016-06-20 17:11:29 -04:00
2016-07-01 10:24:18 -04:00
2016-06-21 09:23:11 +10:00
2016-02-22 22:44:04 -05:00
2016-07-26 19:55:54 -07:00
2016-07-29 12:17:52 -07:00
2016-07-01 15:20:11 -07:00
2016-06-30 08:53:27 +02:00
2016-07-26 16:19:19 -07:00
2016-05-05 09:54:45 -05:00
2016-06-24 12:11:34 -04:00
2016-03-16 13:09:08 -04:00
2016-07-15 10:30:26 +02:00
2016-05-26 00:13:25 -04:00
2016-05-19 19:12:14 -07:00
2016-04-14 12:56:09 -07:00
2016-05-11 00:00:29 -04:00
2016-01-16 11:17:23 -08:00
2016-07-26 16:19:19 -07:00
2016-04-04 10:41:08 -07:00
2016-06-09 23:42:38 +02:00
2016-07-26 16:19:19 -07:00
2016-01-22 18:04:28 -05:00
2016-05-27 20:09:16 -04:00