Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ws-daemon/pkg/libcontainer/specconv/spec_linux.go
2501 views
1
// Copyright The libcontainer authors
2
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
7
// http://www.apache.org/licenses/LICENSE-2.0
8
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
// gpl: Copied from: https://github.com/opencontainers/runc/blob/1f9e36c055b4eb97c38f8aae6ee50ca534962f77/libcontainer/specconv/spec_linux.go#L192
16
package specconv
17
18
import "github.com/opencontainers/runc/libcontainer/devices"
19
20
// AllowedDevices is the set of devices which are automatically included for
21
// all containers.
22
//
23
// # XXX (cyphar)
24
//
25
// This behaviour is at the very least "questionable" (if not outright
26
// wrong) according to the runtime-spec.
27
//
28
// Yes, we have to include certain devices other than the ones the user
29
// specifies, but several devices listed here are not part of the spec
30
// (including "mknod for any device"?!). In addition, these rules are
31
// appended to the user-provided set which means that users *cannot disable
32
// this behaviour*.
33
//
34
// ... unfortunately I'm too scared to change this now because who knows how
35
// many people depend on this (incorrect and arguably insecure) behaviour.
36
var AllowedDevices = []*devices.Device{
37
// allow mknod for any device
38
{
39
Rule: devices.Rule{
40
Type: devices.CharDevice,
41
Major: devices.Wildcard,
42
Minor: devices.Wildcard,
43
Permissions: "m",
44
Allow: true,
45
},
46
},
47
{
48
Rule: devices.Rule{
49
Type: devices.BlockDevice,
50
Major: devices.Wildcard,
51
Minor: devices.Wildcard,
52
Permissions: "m",
53
Allow: true,
54
},
55
},
56
{
57
Path: "/dev/null",
58
FileMode: 0o666,
59
Uid: 0,
60
Gid: 0,
61
Rule: devices.Rule{
62
Type: devices.CharDevice,
63
Major: 1,
64
Minor: 3,
65
Permissions: "rwm",
66
Allow: true,
67
},
68
},
69
{
70
Path: "/dev/random",
71
FileMode: 0o666,
72
Uid: 0,
73
Gid: 0,
74
Rule: devices.Rule{
75
Type: devices.CharDevice,
76
Major: 1,
77
Minor: 8,
78
Permissions: "rwm",
79
Allow: true,
80
},
81
},
82
{
83
Path: "/dev/full",
84
FileMode: 0o666,
85
Uid: 0,
86
Gid: 0,
87
Rule: devices.Rule{
88
Type: devices.CharDevice,
89
Major: 1,
90
Minor: 7,
91
Permissions: "rwm",
92
Allow: true,
93
},
94
},
95
{
96
Path: "/dev/tty",
97
FileMode: 0o666,
98
Uid: 0,
99
Gid: 0,
100
Rule: devices.Rule{
101
Type: devices.CharDevice,
102
Major: 5,
103
Minor: 0,
104
Permissions: "rwm",
105
Allow: true,
106
},
107
},
108
{
109
Path: "/dev/zero",
110
FileMode: 0o666,
111
Uid: 0,
112
Gid: 0,
113
Rule: devices.Rule{
114
Type: devices.CharDevice,
115
Major: 1,
116
Minor: 5,
117
Permissions: "rwm",
118
Allow: true,
119
},
120
},
121
{
122
Path: "/dev/urandom",
123
FileMode: 0o666,
124
Uid: 0,
125
Gid: 0,
126
Rule: devices.Rule{
127
Type: devices.CharDevice,
128
Major: 1,
129
Minor: 9,
130
Permissions: "rwm",
131
Allow: true,
132
},
133
},
134
// /dev/pts/ - pts namespaces are "coming soon"
135
{
136
Rule: devices.Rule{
137
Type: devices.CharDevice,
138
Major: 136,
139
Minor: devices.Wildcard,
140
Permissions: "rwm",
141
Allow: true,
142
},
143
},
144
{
145
Rule: devices.Rule{
146
Type: devices.CharDevice,
147
Major: 5,
148
Minor: 2,
149
Permissions: "rwm",
150
Allow: true,
151
},
152
},
153
// tuntap
154
{
155
Rule: devices.Rule{
156
Type: devices.CharDevice,
157
Major: 10,
158
Minor: 200,
159
Permissions: "rwm",
160
Allow: true,
161
},
162
},
163
}
164
165