-
Notifications
You must be signed in to change notification settings - Fork 315
Add seccomp feature #529
Add seccomp feature #529
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,6 +169,13 @@ func (c *linuxContainer) newInitProcess(p *Process, cmd *exec.Cmd, parentPipe, c | |
| cmd.SysProcAttr.Credential = &syscall.Credential{} | ||
| } | ||
| } | ||
| if cloneFlags&uintptr(configs.CLONE_SECCOMP) != 0 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should be done by client. Silently ignore security issue isn't good idea.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| //os don't surport for CLONE_SECCOMP, remote it | ||
| c.config.Namespaces.Remove(configs.NEWSECCOMP) | ||
| cloneFlags = c.config.Namespaces.CloneFlags() | ||
| } else { | ||
| c.config.Seccomps.SysCalls = []string{} | ||
| } | ||
| cmd.Env = append(cmd.Env, t) | ||
| cmd.SysProcAttr.Cloneflags = cloneFlags | ||
| return &initProcess{ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #!/usr/bin/perl | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want I can help you rewrite this on go and use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, of course you should commit generated code and not rely on generation tool. It is pretty hard to track bugs this way.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, I'll prepare PR to your PR. |
||
|
|
||
| # ./seccomp.pl < syscall.sample > seccompsyscall.go | ||
|
|
||
| use strict; | ||
| use warnings; | ||
|
|
||
| my $pid = open(my $in, "-|") // die "Couldn't fork1 ($!)\n"; | ||
|
|
||
| if($pid == 0) { | ||
| $pid = open(my $out, "|-") // die "Couldn't fork2 ($!)\n"; | ||
| if($pid == 0) { | ||
| exec "cpp" or die "Couldn't exec cpp ($!)\n"; | ||
| exit 1; | ||
| } | ||
|
|
||
| print $out "#include <sys/syscall.h>\n"; | ||
| while(<>) { | ||
| if(/^\w/) { | ||
| my $name="$_"; | ||
| chomp($name); | ||
|
|
||
| print $out $name; | ||
| print $out " = "; | ||
| print $out "__NR_$_"; | ||
| } | ||
| } | ||
| close $out; | ||
| exit 0; | ||
| } | ||
| print "//"; | ||
| system("uname -m"); | ||
| print "package seccomp\r\n\r\n"; | ||
| print "var syscallMap = map[string] int {\n"; | ||
| while(<$in>) { | ||
| my $line=$_; | ||
|
|
||
| if($line =~ /^[\da-z_]/) | ||
| { | ||
| my @personal=split(/=/); | ||
| $personal[0] =~ s/[ ]//; | ||
| $personal[1] =~ s/[\r\n]//; | ||
| print " \""; | ||
| print $personal[0]; | ||
| print "\""; | ||
| print " : "; | ||
| if (($personal[1] !~ /[0-9]/) || length($personal[1]) > 4) | ||
| { | ||
| print "-1,\r\n"; | ||
| }else{ | ||
| print $personal[1]; | ||
| print ",\r\n"; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| print "}\r\n"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #/bin/bash | ||
|
|
||
| chmod 755 hack/seccomp.pl | ||
| hack/seccomp.pl < hack/syscall.sample > seccomp/seccompsyscall.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually
CLONE_NEWUSER. Why we need this at all?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLONE_NEWUSER = 0x10000000
CLONE_NEWSECCOMP is a pseudo flag, which is diffrent other CLONE_xx flag, and it can not pass to clone.