Skip to content

Commit

Permalink
refs #23: Prevent killing of REPL daemons
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Nov 1, 2016
1 parent 25752a4 commit 422321f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ node_modules/
*.gz

.*.swp
*/venv
Binary file modified bin/intra-jail
Binary file not shown.
Binary file modified bin/intra-jail-check
Binary file not shown.
Binary file modified bin/jail
Binary file not shown.
Binary file modified bin/jail-check
Binary file not shown.
3 changes: 1 addition & 2 deletions git/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#! /bin/bash
eval "$(pyenv init -)"
pyenv shell $SORNA_PYTHON_VERSION
#exec /home/sorna/jail git `pyenv which python` /home/sorna/run.py
`pyenv which python` /home/sorna/run.py
exec /home/sorna/jail git `pyenv which python` /home/sorna/run.py
4 changes: 4 additions & 0 deletions jail/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (
id_Fork, _ = seccomp.GetSyscallFromNameByArch("fork", arch)
id_Vfork, _ = seccomp.GetSyscallFromNameByArch("vfork", arch)
id_Execve, _ = seccomp.GetSyscallFromNameByArch("execve", arch)
id_Kill, _ = seccomp.GetSyscallFromNameByArch("kill", arch)
id_Chmod, _ = seccomp.GetSyscallFromNameByArch("chmod", arch)
id_Fchmodat, _ = seccomp.GetSyscallFromNameByArch("fchmodat", arch)
)
Expand Down Expand Up @@ -177,6 +178,9 @@ loop:
if debug {
l.Printf("fork owner: %s\n", execPath)
}
case id_Kill:
targetPid := int(regs.Rdi)
allow = (targetPid != pid && targetPid != os.Getpid())
case id_Execve:
execPath, _ := utils.GetExecutable(result.pid)
if execPath == myExecPath {
Expand Down
9 changes: 5 additions & 4 deletions jail/policy/common.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package policy

import seccomp "github.com/seccomp/libseccomp-golang"
import "syscall"

//import "syscall"

var TracedSyscalls []string
var AllowedSyscalls []string
Expand Down Expand Up @@ -59,7 +60,7 @@ func init() {

// Following syscalls are conditionally allowed.
ConditionallyAllowedSyscalls = map[string]seccomp.ScmpCondition{
"kill": {1, seccomp.CompareEqual, uint64(syscall.SIGSTOP), 0},
//"kill": {1, seccomp.CompareEqual, uint64(syscall.SIGSTOP), 0},
}

// Following syscalls are blindly allowed.
Expand Down Expand Up @@ -189,7 +190,7 @@ func init() {
"getegid",
"getregid",
"getresgid",
"getgroups", // for shell
"getgroups", // for shell
"getcwd",
"socket",
"socketpair",
Expand Down Expand Up @@ -240,7 +241,7 @@ func init() {
"setpgid", // for shell
"getpgrp",
"getsid",
"setsid", // for shell
"setsid", // for shell
"gettimeofday",
"clock_gettime",
"clock_getres",
Expand Down

0 comments on commit 422321f

Please sign in to comment.