-
Notifications
You must be signed in to change notification settings - Fork 200
Adding runc jailing #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding runc jailing #249
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/ | ||
bin/ | ||
runtime/logs | ||
*stamp |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,11 +47,17 @@ type Config struct { | |
LogLevel string `json:"log_level"` | ||
HtEnabled bool `json:"ht_enabled"` | ||
Debug bool `json:"debug"` | ||
|
||
// If a CreateVM call specifies no network interfaces and DefaultNetworkInterfaces is non-empty, | ||
// the VM will default to using the network interfaces as specified here. This is especially | ||
// useful when a CNI-based network interface is provided in DefaultNetworkInterfaces. | ||
DefaultNetworkInterfaces []proto.FirecrackerNetworkInterface `json:"default_network_interfaces"` | ||
JailerConfig JailerConfig `json:"jailer"` | ||
kzys marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// JailerConfig houses a set of configurable values for jailing | ||
// TODO: Add netns field | ||
type JailerConfig struct { | ||
RuncBinaryPath string `json:"runc_binary_path"` | ||
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.
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. 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.
Currently no. That'll be added as a feature later.
This does not currently return the cgroup path. We can add this as a feature request.
Currently no numa node can be specified. We've talked about this offline and have decided to be able to specify the CPUs and mem nodes as a better option. Please see here for a list of what is to come, #258 |
||
} | ||
|
||
// LoadConfig loads configuration from JSON file at 'path' | ||
|
@@ -76,6 +82,7 @@ func LoadConfig(path string) (*Config, error) { | |
CPUCount: defaultCPUCount, | ||
CPUTemplate: string(defaultCPUTemplate), | ||
} | ||
|
||
if err := json.Unmarshal(data, cfg); err != nil { | ||
return nil, errors.Wrapf(err, "failed to unmarshal config from %q", path) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
{ | ||
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. How closely have you validated this config against the set of actions that Firecracker's jailer takes? In particular:
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.
Firecracker's jailer doesn't explicitly use capabilities. They rely on seccomp and inherits its capabilities from the jailer binary
cgroups are all inherited by the parent which reflects what Firecracker's jailer does.
Firecracker's jailer only uses the mount and pid namespaces. And has the option to enter a pre-existing network namespace.
No, Firecracker's mounts are a lot more simple, as in they don't mount anything. In our runc config we specify a bunch of different mounts, like
Yes, with the ones we provide. runc however will create some other devices, like /dev/null
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. For our initial integration, let's match what Firecracker's jailer does rather than match runc's defaults. |
||
"ociVersion": "1.0.1", | ||
"process": { | ||
"terminal": false, | ||
"user": { | ||
"uid": 0, | ||
"gid": 0 | ||
}, | ||
"args": [ | ||
"/firecracker", | ||
"--api-sock", | ||
"api.socket" | ||
], | ||
"env": [ | ||
"PATH=/" | ||
], | ||
"cwd": "/", | ||
"capabilities": { | ||
"effective": [ | ||
], | ||
"bounding": [ | ||
], | ||
"inheritable": [ | ||
], | ||
"permitted": [ | ||
], | ||
"ambient": [ | ||
] | ||
}, | ||
"rlimits": [ | ||
{ | ||
"type": "RLIMIT_NOFILE", | ||
"hard": 1024, | ||
"soft": 1024 | ||
} | ||
], | ||
"noNewPrivileges": true | ||
}, | ||
"root": { | ||
"path": "rootfs", | ||
"readonly": false | ||
}, | ||
"hostname": "runc", | ||
"mounts": [ | ||
sipsma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
"destination": "/proc", | ||
"type": "proc", | ||
"source": "proc" | ||
} | ||
], | ||
"linux": { | ||
"devices": [ | ||
{ | ||
"path": "/dev/kvm", | ||
"type": "c", | ||
"major": 10, | ||
"minor": 232, | ||
"fileMode": 438, | ||
"uid": 0, | ||
"gid": 0 | ||
}, | ||
{ | ||
"path": "/dev/net/tun", | ||
"type": "c", | ||
"major": 10, | ||
"minor": 200, | ||
"fileMode": 438, | ||
"uid": 0, | ||
"gid": 0 | ||
} | ||
], | ||
"resources": { | ||
"devices": [ | ||
sipsma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
"allow": false, | ||
"access": "rwm" | ||
}, | ||
{ | ||
"allow": true, | ||
"major": 10, | ||
"minor": 232, | ||
"access": "rwm" | ||
}, | ||
{ | ||
"allow": true, | ||
"major": 10, | ||
"minor": 200, | ||
"access": "rwm" | ||
} | ||
] | ||
}, | ||
sipsma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"namespaces": [ | ||
sipsma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
"type": "cgroup" | ||
}, | ||
{ | ||
"type": "pid" | ||
}, | ||
{ | ||
"type": "network" | ||
}, | ||
{ | ||
"type": "ipc" | ||
}, | ||
{ | ||
"type": "uts" | ||
}, | ||
{ | ||
"type": "mount" | ||
} | ||
], | ||
"maskedPaths": [ | ||
"/proc/asound", | ||
"/proc/kcore", | ||
"/proc/latency_stats", | ||
"/proc/timer_list", | ||
"/proc/timer_stats", | ||
"/proc/sched_debug", | ||
"/sys/firmware", | ||
"/proc/scsi" | ||
], | ||
"readonlyPaths": [ | ||
"/proc/bus", | ||
"/proc/fs", | ||
"/proc/irq", | ||
"/proc/sys", | ||
"/proc/sysrq-trigger" | ||
] | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.