github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/sys/linux/test/landlock_ptrace (about)

     1  # Creates independent Landlock hierarchies and try different tracer/tracee
     2  # schemas (without scheduling control).
     3  #
     4  # In this test, some ptrace(2) calls return different code according to the
     5  # calling thread.
     6  
     7  capset(&AUTO={0x20080522, 0x0}, &AUTO={0x0, 0x0, 0x0, 0x0, 0x0, 0x0})
     8  prctl$PR_SET_NO_NEW_PRIVS(0x26, 0x1)
     9  
    10  r0 = syz_clone(0x11, 0x0, 0x0, 0x0, 0x0, 0x0)
    11  
    12  # PTRACE_ATTACH and PTRACE_DETACH
    13  
    14  ptrace(0x10, r0)
    15  ptrace(0x11, r0)
    16  
    17  r1 = landlock_create_ruleset(&AUTO={0x100, 0x0, 0x0}, AUTO, 0x0)
    18  landlock_restrict_self(r1, 0x0)
    19  
    20  r2 = syz_clone(0x11, 0x0, 0x0, 0x0, 0x0, 0x0)
    21  
    22  ptrace(0x10, r0) # EPERM
    23  ptrace(0x11, r0)
    24  
    25  ptrace(0x10, r2)
    26  ptrace(0x11, r2)
    27  
    28  r3 = landlock_create_ruleset(&AUTO={0x100, 0x0, 0x0}, AUTO, 0x0)
    29  landlock_restrict_self(r3, 0x0)
    30  
    31  ptrace(0x10, r0) # EPERM
    32  ptrace(0x11, r0)
    33  
    34  ptrace(0x10, r2) # EPERM
    35  ptrace(0x11, r2)
    36  
    37  # For now, PTRACE_TRACEME is transformed to -1, which returns an error:
    38  # https://github.com/google/syzkaller/blob/cbd0445ec3b0b184db66966d8a47e6b37d13692e/sys/linux/init.go#L179-L182
    39  
    40  ptrace(0x0, 0x0)