From: Dmitry V. Levin Date: Sat, 6 Feb 2016 01:40:09 +0000 (+0000) Subject: tests: extend coverage of capget syscall X-Git-Tag: v4.12~581 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a59fcec4c937c4854600ec8f1f2161fad75ce5e7;p=strace tests: extend coverage of capget syscall * tests/caps.c (main): Check decoding of inaccessible cap_user_header_t and/or cap_user_data_t. * tests/caps.awk: Update match patterns. * tests/caps.test: Update. --- diff --git a/tests/caps.awk b/tests/caps.awk index bad8b0f3..ecf1a282 100644 --- a/tests/caps.awk +++ b/tests/caps.awk @@ -1,6 +1,8 @@ #!/bin/gawk # -# Copyright (c) 2014-2015 Dmitry V. Levin +# This file is part of caps strace test. +# +# Copyright (c) 2014-2016 Dmitry V. Levin # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -27,12 +29,18 @@ BEGIN { cap = "(0|CAP_[A-Z_]+(\\|CAP_[A-Z_]+)*|CAP_[A-Z_]+(\\|CAP_[A-Z_]+){37}\\|0xffffffc0)" - r[1] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, \\{" cap ", " cap ", " cap "\\}\\) = 0$" + s_efault = "-1 EFAULT (Bad address)" + r_efault = "-1 EFAULT \\(Bad address\\)" + r_addr = "0x[[:xdigit:]]+" + s[1] = "capget(NULL, NULL) = " s_efault + r[2] = "^capget\\(" r_addr ", " r_addr "\\) = " r_efault + r[3] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, " r_addr "\\) = " r_efault + r[4] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, \\{" cap ", " cap ", " cap "\\}\\) = 0$" capset_data = "{CAP_DAC_OVERRIDE|CAP_WAKE_ALARM, CAP_DAC_READ_SEARCH|CAP_BLOCK_SUSPEND, 0}" - s[2] = "capset({_LINUX_CAPABILITY_VERSION_3, 0}, " capset_data ") = -1 EPERM (Operation not permitted)" - s[3] = "+++ exited with 0 +++" + s[5] = "capset({_LINUX_CAPABILITY_VERSION_3, 0}, " capset_data ") = -1 EPERM (Operation not permitted)" + s[6] = "+++ exited with 0 +++" - lines = 3 + lines = 6 fail = 0 } diff --git a/tests/caps.c b/tests/caps.c index 2aca8625..17e10777 100644 --- a/tests/caps.c +++ b/tests/caps.c @@ -1,4 +1,6 @@ /* + * This file is part of caps strace test. + * * Copyright (c) 2014-2016 Dmitry V. Levin * All rights reserved. * @@ -27,6 +29,7 @@ #include "tests.h" #include +#include extern int capget(int *, int *); extern int capset(int *, const int *); @@ -34,15 +37,24 @@ extern int capset(int *, const int *); int main(void) { - int unused[6]; const int data[] = { 2, 4, 0, 8, 16, 0 }; const int v3 = 0x20080522; - int head[] = { v3, 0 }; - if (capget(head, unused)) + int * const head = tail_alloc(sizeof(int) * 2); + head[0] = v3; + head[1] = 0; + int * const tail_data = tail_alloc(sizeof(data)); + + capget(NULL, NULL); + capget(head + 2, tail_data); + capget(head, tail_data + ARRAY_SIZE(data)); + + if (capget(head, tail_data)) perror_msg_and_skip("capget"); if (head[0] != v3) error_msg_and_skip("capget: v3 expected"); + + memcpy(tail_data, data, sizeof(data)); if (capset(head, data) == 0 || errno != EPERM) perror_msg_and_skip("capset"); diff --git a/tests/caps.test b/tests/caps.test index 9437a4ba..607a75bb 100755 --- a/tests/caps.test +++ b/tests/caps.test @@ -5,7 +5,7 @@ . "${srcdir=.}/init.sh" run_prog -run_strace -e trace=capget,capset $args +run_strace -a 19 -e trace=capget,capset $args match_awk exit 0