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] [day] [month] [year] [list]
Date:	Mon, 13 Apr 2015 10:30:24 -0700
From:	Kees Cook <keescook@...omium.org>
To:	Kees Cook <keescook@...omium.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Andy Lutomirski <luto@...capital.net>,
	Will Drewry <wad@...omium.org>
Subject: Re: security problem with seccomp-filter

On Sun, Apr 12, 2015 at 2:33 PM, Felix von Leitner
<felix-linuxkernel@...e.de> wrote:
>> What you're describing should work correctly (it's part of the
>> regression test suite we use). So, given that, I'd love to get to the
>> bottom of what you're seeing. Do you have a URL to your code? What
>> architecture are you running on?
>
> Well, I must be doing something wrong then.
> I extracted a test case from my program.
> I put it on http://ptrace.fefe.de/seccompfail.c
>
> It installs three seccomp filters, the last one containing this:
>
>     DISALLOW_SYSCALL(prctl),
>
> with
>
> #define DISALLOW_SYSCALL(name) \
>         BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \
>         BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL)
>
> It is my understanding that that should then kill the process if the
> prctl syscall is called again.
>
> I test this by attempting to install the very same seccomp filter again,
> which calls prctl, but the process is not killed.
>
> What am I doing wrong?

Your filters don't load a syscall number, so the comparisons aren't
validating anything.

For example, from the working filter:

  struct sock_filter filter[] = {
...
    /* load the syscall number */
    BPF_STMT(BPF_LD+BPF_W+BPF_ABS, offsetof(struct seccomp_data, nr)),
...
    ALLOW_SYSCALL(close),
...
    BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL)
  };

Where as yours from seccomp_denyfile and seccomp_denysocket don't load
the syscall number:

  struct sock_filter filter[] = {
    DISALLOW_SYSCALL(open),
...
    BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
  };

When you add the load as the first statement in both filters:

  struct sock_filter filter[] = {
    BPF_STMT(BPF_LD+BPF_W+BPF_ABS, offsetof(struct seccomp_data, nr)),
    DISALLOW_SYSCALL(open),
...
    BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
  };

things work as expected:

$ ./seccompfail
Bad system call

I wonder if the validator could be improved to disallow comparisons
when the accumulator hasn't been written to. That might have helped
you find this mistake more quickly (i.e. getting EINVAL from your
filter install attempts).

-Kees

-- 
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ