]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_repair: fix thread creation failure recovery
authorJeff Mahoney <jeffm@suse.com>
Tue, 22 Aug 2017 15:01:31 +0000 (10:01 -0500)
committerEric Sandeen <sandeen@redhat.com>
Tue, 22 Aug 2017 15:01:31 +0000 (10:01 -0500)
commitb97ad969e0899abfb56ed97611ad6e53c1c24a24
tree4e0c17c429e5970a36807f86b279b7928fc2e2ba
parente8ff6275b3559c276df39f17377c46a58243ccb3
xfs_repair: fix thread creation failure recovery

When pf_create_prefetch_thread fails, it tears down the args struct
and frees it.  This causes a use-after-free in prefetch_ag_range, which
then passes the now-invalid pointer to start_inode_prefetch.  The struct
is only freed when the queuing thread can't be started.  When we can't
start even one worker thread, we mark the args ready for processing and
allow it to proceed single-threaded.  Unfortunately, this only marks
the current args ready for processing and since we return immediately,
the call to pf_create_prefetch_thread at the end of pf_queuing_worker
never gets called and we wait forever for prefetch to start on the
next AG.

This patch factors out the cleanup into a new pf_skip_prefetch_thread
that is called when we fail to create either the queuing thread or
the first of the workers.  It marks the args ready for processing, marks
it done so start_inode_prefetch doesn't add another AG to the list, and
tries to start a new thread for the next AG in the list.  We also clear
->next_args and check for it in cleanup_inode_prefetch so this condition
is easier to catch should it arise again.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
repair/prefetch.c