Skip to content

Commit a8317ae

Browse files
Dont do untrusted worker stuff on batch (#4402)
This is breaking fuzzing on batch in oss-fuzz. Looking forward to the day when we can get rid of untrusted worker. Them living side by side with uworker is unpleasant.
1 parent f4df493 commit a8317ae

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/clusterfuzz/_internal/bot/tasks/setup.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def setup_testcase(testcase: data_types.Testcase, job_type: str,
287287
_copy_testcase_to_device_and_setup_environment(testcase, testcase_file_path)
288288

289289
# Push testcases to worker.
290-
if environment.is_trusted_host():
290+
if take_trusted_host_path():
291291
from clusterfuzz._internal.bot.untrusted_runner import file_host
292292
file_host.push_testcases_to_worker()
293293

@@ -467,6 +467,12 @@ def _prepare_update_data_bundle(fuzzer, data_bundle):
467467
return data_bundle_directory
468468

469469

470+
def take_trusted_host_path():
471+
if environment.is_uworker():
472+
return False
473+
return environment.is_trusted_host()
474+
475+
470476
def update_data_bundle(
471477
fuzzer: data_types.Fuzzer,
472478
data_bundle_corpus: uworker_msg_pb2.DataBundleCorpus) -> bool: # pylint: disable=no-member
@@ -486,10 +492,12 @@ def update_data_bundle(
486492
# case, the fuzzer will generate testcases from a gcs bucket periodically.
487493
if not _is_search_index_data_bundle(data_bundle.name):
488494

489-
if not (environment.is_trusted_host() and data_bundle.sync_to_worker):
495+
if not (take_trusted_host_path() and data_bundle.sync_to_worker):
496+
logs.info('Data bundles: normal path.')
490497
result = corpus_manager.sync_data_bundle_corpus_to_disk(
491498
data_bundle_corpus, data_bundle_directory)
492499
else:
500+
logs.info('Data bundles: untrusted runner path.')
493501
from clusterfuzz._internal.bot.untrusted_runner import \
494502
corpus_manager as untrusted_corpus_manager
495503
from clusterfuzz._internal.bot.untrusted_runner import file_host
@@ -515,7 +523,7 @@ def update_data_bundle(
515523
# Write last synced time in the sync file.
516524
sync_file_path = _get_data_bundle_sync_file_path(data_bundle_directory)
517525
utils.write_data_to_file(time_before_sync_start, sync_file_path)
518-
if environment.is_trusted_host() and data_bundle.sync_to_worker:
526+
if take_trusted_host_path() and data_bundle.sync_to_worker:
519527
from clusterfuzz._internal.bot.untrusted_runner import file_host
520528
worker_sync_file_path = file_host.rebase_to_worker_root(sync_file_path)
521529
file_host.copy_file_to_worker(sync_file_path, worker_sync_file_path)
@@ -690,7 +698,7 @@ def update_fuzzer_and_data_bundles(
690698

691699
# For launcher script usecase, we need the entire fuzzer directory on the
692700
# worker.
693-
if environment.is_trusted_host():
701+
if take_trusted_host_path():
694702
from clusterfuzz._internal.bot.untrusted_runner import file_host
695703
worker_fuzzer_directory = file_host.rebase_to_worker_root(
696704
fuzzer_directory)
@@ -710,7 +718,7 @@ def _is_data_bundle_up_to_date(data_bundle, data_bundle_directory):
710718
"""Return true if the data bundle is up to date, false otherwise."""
711719
sync_file_path = _get_data_bundle_sync_file_path(data_bundle_directory)
712720

713-
if environment.is_trusted_host() and data_bundle.sync_to_worker:
721+
if not (take_trusted_host_path() and data_bundle.sync_to_worker):
714722
from clusterfuzz._internal.bot.untrusted_runner import file_host
715723
worker_sync_file_path = file_host.rebase_to_worker_root(sync_file_path)
716724
shell.remove_file(sync_file_path)

src/clusterfuzz/_internal/fuzzing/corpus_manager.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,9 @@ def get_proto_data_bundle_corpus(
611611
data_bundle_corpus.data_bundle.CopyFrom(
612612
uworker_io.entity_to_protobuf(data_bundle))
613613
if task_types.task_main_runs_on_uworker():
614-
# Slow path for when we need an untrusted worker to run a task.
615-
# Note that the security of the system (only the correctness) depends on
616-
# this path being taken. If it is not taken when we need to, utask_main will
614+
# Slow path for when we need an untrusted worker to run a task. Note that
615+
# the security of the system (only the correctness) does not depend on this
616+
# path being taken. If it is not taken when we need to, utask_main will
617617
# simply fail as it tries to do privileged operation it does not have
618618
# permissions for.
619619
urls = (f'{data_bundle_corpus.gcs_url}/{url}'
@@ -627,7 +627,8 @@ def get_proto_data_bundle_corpus(
627627

628628

629629
def sync_data_bundle_corpus_to_disk(data_bundle_corpus, directory):
630-
if not task_types.task_main_runs_on_uworker():
630+
if (not task_types.task_main_runs_on_uworker() and
631+
not environment.is_uworker()):
631632
# Fast path for when we don't need an untrusted worker to run a task.
632633
return gsutil.GSUtilRunner().rsync(
633634
data_bundle_corpus.gcs_url, directory, delete=False).return_code == 0

0 commit comments

Comments
 (0)