lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 27 May 2021 14:05:38 -0500
From:   Will Drewry <wad@...omium.org>
To:     Kees Cook <keescook@...omium.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Andy Lutomirski <luto@...capital.net>
Subject: Re: [PATCH] selftests/seccomp: Flush benchmark output regularly

On Wed, May 26, 2021 at 10:30 PM Kees Cook <keescook@...omium.org> wrote:
>
> When running the seccomp benchmark under a test runner, it wouldn't
> provide any feedback on progress. Force IO flushes during the test.

Would it make sense to just setbuf(stdout, NULL); in main?

> Signed-off-by: Kees Cook <keescook@...omium.org>
> ---
>  tools/testing/selftests/seccomp/seccomp_benchmark.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c b/tools/testing/selftests/seccomp/seccomp_benchmark.c
> index fcc806585266..7be1e2131f79 100644
> --- a/tools/testing/selftests/seccomp/seccomp_benchmark.c
> +++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c
> @@ -42,6 +42,7 @@ unsigned long long timing(clockid_t clk_id, unsigned long long samples)
>                 finish.tv_sec, finish.tv_nsec,
>                 start.tv_sec, start.tv_nsec,
>                 i, (double)i / 1000000000.0);
> +       fflush(NULL);
>
>         return i;
>  }
> @@ -54,6 +55,7 @@ unsigned long long calibrate(void)
>         int seconds = 15;
>
>         printf("Calibrating sample size for %d seconds worth of syscalls ...\n", seconds);
> +       fflush(NULL);
>
>         samples = 0;
>         pid = getpid();
> @@ -157,6 +159,7 @@ int main(int argc, char *argv[])
>         /* Native call */
>         native = timing(CLOCK_PROCESS_CPUTIME_ID, samples) / samples;
>         printf("getpid native: %llu ns\n", native);
> +       fflush(NULL);
>
>         ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
>         assert(ret == 0);
> @@ -167,6 +170,7 @@ int main(int argc, char *argv[])
>
>         bitmap1 = timing(CLOCK_PROCESS_CPUTIME_ID, samples) / samples;
>         printf("getpid RET_ALLOW 1 filter (bitmap): %llu ns\n", bitmap1);
> +       fflush(NULL);
>
>         /* Second filter resulting in a bitmap */
>         ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &bitmap_prog);
> @@ -174,6 +178,7 @@ int main(int argc, char *argv[])
>
>         bitmap2 = timing(CLOCK_PROCESS_CPUTIME_ID, samples) / samples;
>         printf("getpid RET_ALLOW 2 filters (bitmap): %llu ns\n", bitmap2);
> +       fflush(NULL);
>
>         /* Third filter, can no longer be converted to bitmap */
>         ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog);
> @@ -181,6 +186,7 @@ int main(int argc, char *argv[])
>
>         filter1 = timing(CLOCK_PROCESS_CPUTIME_ID, samples) / samples;
>         printf("getpid RET_ALLOW 3 filters (full): %llu ns\n", filter1);
> +       fflush(NULL);
>
>         /* Fourth filter, can not be converted to bitmap because of filter 3 */
>         ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &bitmap_prog);
> @@ -188,6 +194,7 @@ int main(int argc, char *argv[])
>
>         filter2 = timing(CLOCK_PROCESS_CPUTIME_ID, samples) / samples;
>         printf("getpid RET_ALLOW 4 filters (full): %llu ns\n", filter2);
> +       fflush(NULL);
>
>         /* Estimations */
>  #define ESTIMATE(fmt, var, what)       do {                    \
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ