• Filipe Brandenburger's avatar
    zdtm: add new dumpable02 test to check that dumpable flag set to 0 or 2 works · 6cf2906b
    Filipe Brandenburger authored
    This confirms that the fix to handle dumpable flag set to 2 still works after
    restore.
    
    To force dumpable flag set to 0 or 2 (whatever the fs.suid_dumpable is set to),
    chmod the test binary to 0111 (executable, but not readable) and execv() it
    while running as non-root.  The kernel will unset the dumpable flag to prevent
    a core dump or ptrace to giving the user access to the pages of the binary
    (which are supposedly not readable by that user.)
    
    Tested:
    - # test/zdtm.sh static/dumpable02
      Test: zdtm/live/static/dumpable02, Result: PASS
    - # test/zdtm.sh ns/static/dumpable02
      Test: zdtm/live/static/dumpable02, Result: PASS
    - Used -DDEBUG to confirm the value of the dumpable flag was 0 or 2 to match
      the fs.suid_dumpable sysctl in the tests (both in and out of namespaces.)
    - Confirmed that the test fails if the commit that fixes handling of dumpable
      flag with value 2 is reverted and the fs.suid_dumpable sysctl is set to 2.
    Signed-off-by: 's avatarFilipe Brandenburger <filbranden@google.com>
    Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    6cf2906b
dumpable02.c 4.46 KB