Repository navigation
Commit c407c03
[PATCH] binfmt_misc: improve calculation of interpreter's credentials
This patch allows for misc binaries to run with credentials and security
token that are calculated according to the binaries, and not according to the
interpreter, which is the legacy behavior of binfmt_misc.
The way it is done is by calling prepare_binprm, which is where these
attributes are calculated, before switching the 'file' field in the bprm from
the binary to the interpreter.
This feature should be used with care, since the interpreter will have root
permissions when running a setuid binary owned by root.
Please note -
- Only root can register an interpreter with binfmt_misc. The feature is
documented and the administrator is advised to handle it with care
- The new feature is enabled only with a special flag in the registration
string. When this flag is not specified the current behavior of
binfmt_misc is kept
- This is the only 'right' way for an interpreter to know the correct
AT_SECURE value for the interpreted binary
From: Chris Wright <chrisw@osdl.org>
This patchset looks OK, except for one problem. It installs the fd (which
could've been unreadable) without unsharing the ->files. So someone can use
this to read unreadable yet executable files. Here's a patch which fixes
that up. I added one bit that's commented out because I'm not positive if a
final steal_locks() is needed.
I did a fair amount of rearranging to simplify the error conditions
relative to the fd_install(), and unshare_files().
From: Chris Wright <chrisw@osdl.org>
I found that the intel patchset (and mine as well) leaked i_writecount on
the original executed file. In addition, I verified that the steal_locks()
bit is indeed needed.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>1 parent 79baf43 commit c407c03
2 files changed
Lines changed: 78 additions & 51 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
51 | 58 | | |
52 | 59 | | |
53 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | | - | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
114 | | - | |
| 112 | + | |
| 113 | + | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
| |||
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
129 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
130 | 131 | | |
131 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
132 | 143 | | |
133 | 144 | | |
134 | 145 | | |
135 | | - | |
| 146 | + | |
136 | 147 | | |
137 | 148 | | |
138 | | - | |
| 149 | + | |
139 | 150 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 151 | + | |
146 | 152 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
151 | 160 | | |
152 | | - | |
153 | 161 | | |
154 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
155 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
156 | 172 | | |
157 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
158 | 177 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | 178 | | |
163 | 179 | | |
164 | 180 | | |
| |||
170 | 186 | | |
171 | 187 | | |
172 | 188 | | |
173 | | - | |
174 | | - | |
175 | 189 | | |
176 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
177 | 199 | | |
178 | 200 | | |
179 | 201 | | |
180 | 202 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | 203 | | |
195 | | - | |
196 | 204 | | |
197 | | - | |
| 205 | + | |
198 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
199 | 212 | | |
200 | 213 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | 214 | | |
209 | 215 | | |
210 | | - | |
| 216 | + | |
211 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
212 | 223 | | |
213 | | - | |
214 | 224 | | |
215 | 225 | | |
216 | 226 | | |
| |||
271 | 281 | | |
272 | 282 | | |
273 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
274 | 291 | | |
275 | 292 | | |
276 | 293 | | |
| |||
280 | 297 | | |
281 | 298 | | |
282 | 299 | | |
283 | | - | |
| 300 | + | |
284 | 301 | | |
285 | 302 | | |
286 | 303 | | |
| |||
453 | 470 | | |
454 | 471 | | |
455 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
456 | 476 | | |
457 | 477 | | |
458 | 478 | | |
| |||
0 commit comments