Re: new seccomp mode aims to improve performance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 29, 2020 at 5:50 AM zhujianwei (C) <zhujianwei7@xxxxxxxxxx> wrote:
>
> Hi, all
>
>   We're using seccomp to increase container security, but bpf rules filter causes performance to deteriorate. So, is there a good solution to improve performance, or can we add a simplified seccomp mode to improve performance?

I don't think your hunch at where cpu is spending cycles is correct.
Could you please do two experiments:
1. try trivial seccomp bpf prog that simply returns 'allow'
2. replace bpf_prog_run_pin_on_cpu() in seccomp.c with C code
  that returns 'allow' and make sure it's noinline or in a different C file,
  so that compiler doesn't optimize the whole seccomp_run_filters() into a nop.

Then measure performance of both.
I bet you'll see exactly the same numbers.
If you have retpoline on then bpf case will be slightly slower because
of retpoline cost.

Only after this experiment let's discuss the options about accelerating seccomp.

>
>   // Pseudo code
>   int __secure_computing(int this_syscall)
>   {
>         ...
>         switch (mode) {
>         case SECCOMP_MODE_STRICT:
>                 ...
>         case SECCOMP_MODE_FILTER:
>                 ...
>         case SECCOMP_MODE_LIGHT_FILTER:
>                 //do light syscall filter.
>                 ...
>                 break;
>         }
>         ...
>   }
>
>   int light_syscall_filter(int syscall_num) {
>         if(scno > SYSNUM_MAX) {
>                 ...
>                 return -EACCESS;
>         }
>
>         bool *filter_map = get_filter_map(current);
>         if(filter_map == NULL) {
>                 ...
>                 return -EFAULT;
>         }
>
>         if(filter_map[syscall_num] == true) {
>                 ...
>                 return 0;
>         } else {
>                 ...
>                 return -EACCESS;
>         }
>         ...
>   }




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux