github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/fuchsia/test/job (about) 1 # Expect failure when creating a job from an invalid handle. 2 3 zx_job_create(0x0, 0x0, &AUTO) # ZX_ERR_BAD_HANDLE 4 5 # Create a valid job handle and several child jobs. 6 7 r1 = syz_job_default() 8 zx_job_create(r1, 0x0, &AUTO=<r2=>0x0) 9 zx_job_create(r1, 0x0, &AUTO=<r3=>0x0) 10 zx_job_create(r1, 0x0, &AUTO=<r4=>0x0) 11 12 # With policy format ZX_JOB_POL_BASIC_V1, set policy ZX_POL_ACTION_ALLOW for condition ZX_POL_NEW_ANY. 13 14 zx_job_set_policy$BASIC_V1(r2, 0x0, 0x0, &AUTO=[{0x3, 0x0}], 0x1) 15 16 # With policy format ZX_JOB_POL_TIMER_SLACK, set a min slack of 256ns with a default mode of ZX_TIMER_SLACK_CENTER. 17 18 zx_job_set_policy$TIMER_SLACK(r4, 0x0, 0x1, &AUTO=[{0x100, 0x0, "00000000"}], 0x1) 19 20 # With policy format ZX_JOB_POL_BASIC_V2, set policy ZX_POL_ACTION_DENY for condition ZX_POL_NEW_ANY with flag ZX_POLICY_OVERRIDE_DENY. 21 22 zx_job_set_policy$BASIC_V2(r3, 0x0, 0x01000000, &AUTO=[{0x3, 0x1, 0x1}], 0x1) 23 24 # Setting the same policy again should succeed with either the ZX_JOB_POL_ABSOLUTE or ZX_JOB_POL_RELATIVE option. 25 26 zx_job_set_policy$BASIC_V2(r3, 0x0, 0x01000000, &AUTO=[{0x3, 0x1, 0x1}], 0x1) 27 28 # Setting a conflicting policy with the ZX_JOB_POL_RELATIVE option should succeed. 29 30 zx_job_set_policy$BASIC_V2(r3, 0x0, 0x01000000, &AUTO=[{0x3, 0x0, 0x1}], 0x1) 31 32 # Setting a conflicting policy with the ZX_JOB_POL_ABSOLUTE option should fail. 33 34 zx_job_set_policy$BASIC_V2(r3, 0x1, 0x01000000, &AUTO=[{0x3, 0x0, 0x1}], 0x1) # ZX_ERR_ALREADY_EXISTS 35 36 # Create a grandchild job. Expect failure when setting a previously allowed policy once a job has a child job. 37 38 zx_job_create(r3, 0x0, &AUTO=<r5=>0x0) 39 zx_job_set_policy$BASIC_V2(r3, 0x0, 0x01000000, &AUTO=[{0x3, 0x1, 0x1}], 0x1) # ZX_ERR_BAD_STATE 40 41 # Create a process and set it as critical for a job. 42 # TODO: when possible, create a non-self process and test that the parent job dies when the process handle is closed. 43 44 r6 = syz_job_default() 45 r7 = syz_process_self() 46 zx_job_set_critical(r6, 0x0, r7)