Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1470254 > unrolled thread
| Started by | James Bottomley <James.Bottomley@HansenPartnership.com> |
|---|---|
| First post | 2016-08-25 18:20 +0200 |
| Last post | 2016-08-27 14:00 +0200 |
| Articles | 7 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] binfmt_misc: allow selecting the interpreter based on xattr keywords James Bottomley <James.Bottomley@HansenPartnership.com> - 2016-08-25 18:20 +0200
Re: [PATCH] binfmt_misc: allow selecting the interpreter based on xattr keywords Florian Weimer <fweimer@redhat.com> - 2016-08-26 17:00 +0200
Re: [PATCH] binfmt_misc: allow selecting the interpreter based on xattr keywords Carlos O'Donell <carlos@redhat.com> - 2016-08-26 20:00 +0200
Re: [PATCH] binfmt_misc: allow selecting the interpreter based on xattr keywords James Bottomley <James.Bottomley@HansenPartnership.com> - 2016-08-26 23:50 +0200
Re: [PATCH] binfmt_misc: allow selecting the interpreter based on xattr keywords One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-08-26 23:20 +0200
Re: [PATCH] binfmt_misc: allow selecting the interpreter based on xattr keywords James Bottomley <James.Bottomley@HansenPartnership.com> - 2016-08-26 23:30 +0200
Re: [PATCH] binfmt_misc: allow selecting the interpreter based on xattr keywords One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-08-27 14:00 +0200
| From | James Bottomley <James.Bottomley@HansenPartnership.com> |
|---|---|
| Date | 2016-08-25 18:20 +0200 |
| Subject | Re: [PATCH] binfmt_misc: allow selecting the interpreter based on xattr keywords |
| Message-ID | <sa5xM-3jP-27@gated-at.bofh.it> |
On Sun, 2016-08-21 at 21:01 -0700, Josh Max wrote: > This patch allows binfmt_misc to select the interpeter for arbitrary > binaries by comparing a specified registered keyword with the value > of a specified binary's extended attribute (user.binfmt.interp), > and then launching the program with the registered interpreter. > > This is useful when wanting to launch a collection of binaries under > the same interpreter, even when they do not necessarily share a > common extension or magic bits, or when their magic conflics with the > operation of binfmt_elf. Some examples of its use would be to launch > some executables of various different architectures in a directory, > or for running some native binaries under a sandbox (like firejail) > automatically during their launch. Could you expand on the use cases? The patch set looks OK; the issue with extended attributes is lack of universal support on filesystems, but that may not be a problem because they're definitely supported on all the standard ones. I think the current F flag solves the foreign binary in chroot or container. Self sandboxing sounds reasonable, but if this is a security feature, doesn't having the label under the user. EAs mean that the confined binary can simply remove the label and unconfine itself? James
[toc] | [next] | [standalone]
| From | Florian Weimer <fweimer@redhat.com> |
|---|---|
| Date | 2016-08-26 17:00 +0200 |
| Message-ID | <saqLU-8tm-27@gated-at.bofh.it> |
| In reply to | #1470254 |
On 08/25/2016 06:15 PM, James Bottomley wrote: > On Sun, 2016-08-21 at 21:01 -0700, Josh Max wrote: >> This patch allows binfmt_misc to select the interpeter for arbitrary >> binaries by comparing a specified registered keyword with the value >> of a specified binary's extended attribute (user.binfmt.interp), >> and then launching the program with the registered interpreter. >> >> This is useful when wanting to launch a collection of binaries under >> the same interpreter, even when they do not necessarily share a >> common extension or magic bits, or when their magic conflics with the >> operation of binfmt_elf. Some examples of its use would be to launch >> some executables of various different architectures in a directory, >> or for running some native binaries under a sandbox (like firejail) >> automatically during their launch. > > Could you expand on the use cases? A non-security use case would be to run the binary (without modification) with a different ELF interpreter (assuming this allows to override binfmt_elf, but self-sandboxing would need that as well). This would make it easier to use older or newer libcs for select binaries on the system. Right now, one has to write wrappers for that, and the explicit dynamic linker invocation is not completely transparent to the application. Florian
[toc] | [prev] | [next] | [standalone]
| From | Carlos O'Donell <carlos@redhat.com> |
|---|---|
| Date | 2016-08-26 20:00 +0200 |
| Message-ID | <satA6-1Kj-19@gated-at.bofh.it> |
| In reply to | #1470792 |
On 08/26/2016 10:55 AM, Florian Weimer wrote: > On 08/25/2016 06:15 PM, James Bottomley wrote: >> On Sun, 2016-08-21 at 21:01 -0700, Josh Max wrote: >>> This patch allows binfmt_misc to select the interpeter for >>> arbitrary binaries by comparing a specified registered keyword >>> with the value of a specified binary's extended attribute >>> (user.binfmt.interp), and then launching the program with the >>> registered interpreter. >>> >>> This is useful when wanting to launch a collection of binaries >>> under the same interpreter, even when they do not necessarily >>> share a common extension or magic bits, or when their magic >>> conflics with the operation of binfmt_elf. Some examples of its >>> use would be to launch some executables of various different >>> architectures in a directory, or for running some native binaries >>> under a sandbox (like firejail) automatically during their >>> launch. >> >> Could you expand on the use cases? Likewise, I would also like to hear about the intended use cases. > A non-security use case would be to run the binary (without > modification) with a different ELF interpreter (assuming this allows > to override binfmt_elf, but self-sandboxing would need that as well). > This would make it easier to use older or newer libcs for select > binaries on the system. Right now, one has to write wrappers for > that, and the explicit dynamic linker invocation is not completely > transparent to the application. I think this is a slightly contrived use case. Normally you would just use patchelf, or build the binary with a specific dynamic loader e.g. -Wl,--dynamic-linker=file. What is restricting the use case from modifying the binary or running under the new loader? Or to put it another way, what requires the interpreter selection to be fully dynamic? Why isn't the answer: Use ELF everywhere and specify the interpreter you actually want? Likewise if you know you want to one-off run a native binary in a sandbox or alternate loader then use a userspace tool to do that? Does the convenience gained justify the complexity we now have to explain to our users "Oh, and watch out for the xattr keywords that change how your application is started?" I'm doubtful. I haven't seen enough use cases here to justify a fully dynamic interpreter selection. It feels like a better use of our energy would be to make exec by the kernel and exec by the dynamic loader look as similar as possible so you can use one or the other without the application knowing the difference. My worry is that this is a new knob for something we have previously all expected to be a part of the binaries static definition. What impact will have on security validation? Is the binary running with the intended runtime? I assume that setting the xattr keyword requires write for the file in question, and that no capabilities mismatch means we could set the keyword but have less than write permissions on the file. There would also be a non-zero performance cost to this and it would be borne by all ELF/misc binaries at startup for what is a debugging feature. This assumes we extend binfmt_elf to look for the same xattr keyword to override the loader. This ignores the fact that the alternate loader also needs to have it's own ldconfig cache, implementation-dependent lookup paths etc, all of which have to be keyed off the xattr keyword specified dynamic loader. All of that is tractable though and can be done in userspace keyed from the selected dynamic loader. Buy why? Why not use a mount namespace and different loader e.g. lxc, docker, etc, or specify a loader that is a wrapper and does this for you? I'm not convinced this is a good idea, but I'm open to learning about more use cases. -- Cheers, Carlos.
[toc] | [prev] | [next] | [standalone]
| From | James Bottomley <James.Bottomley@HansenPartnership.com> |
|---|---|
| Date | 2016-08-26 23:50 +0200 |
| Message-ID | <saxaG-452-5@gated-at.bofh.it> |
| In reply to | #1470917 |
On Fri, 2016-08-26 at 13:59 -0400, Carlos O'Donell wrote: > On 08/26/2016 10:55 AM, Florian Weimer wrote: > > On 08/25/2016 06:15 PM, James Bottomley wrote: > > > On Sun, 2016-08-21 at 21:01 -0700, Josh Max wrote: > > > > This patch allows binfmt_misc to select the interpeter for > > > > arbitrary binaries by comparing a specified registered keyword > > > > with the value of a specified binary's extended attribute > > > > (user.binfmt.interp), and then launching the program with the > > > > registered interpreter. > > > > > > > > This is useful when wanting to launch a collection of binaries > > > > under the same interpreter, even when they do not necessarily > > > > share a common extension or magic bits, or when their magic > > > > conflics with the operation of binfmt_elf. Some examples of its > > > > use would be to launch some executables of various different > > > > architectures in a directory, or for running some native > > > > binaries > > > > under a sandbox (like firejail) automatically during their > > > > launch. > > > > > > Could you expand on the use cases? > > Likewise, I would also like to hear about the intended use cases. > > > A non-security use case would be to run the binary (without > > modification) with a different ELF interpreter (assuming this > > allows > > to override binfmt_elf, but self-sandboxing would need that as > > well). > > This would make it easier to use older or newer libcs for select > > binaries on the system. Right now, one has to write wrappers for > > that, and the explicit dynamic linker invocation is not completely > > transparent to the application. > > I think this is a slightly contrived use case. Normally you would > just use patchelf, or build the binary with a specific dynamic loader > e.g. -Wl,--dynamic-linker=file. What is restricting the use case from > modifying the binary or running under the new loader? Or to put it > another way, what requires the interpreter selection to be fully > dynamic? > > Why isn't the answer: Use ELF everywhere and specify the interpreter > you actually want? Likewise if you know you want to one-off run a > native binary in a sandbox or alternate loader then use a userspace > tool to do that? So I'm now worried about the stacking case: if you're emulating the architecture for the binary, which is the traditional binfmt_misc use case, you can't use this xattr trick to override the elf interpreter because the sequence goes binfmt_misc -> qemu-user -> elf_interp meaning qemu-user has to know to look in the xattr. Doing patchelf fixes this case as well, so it sounds like the better solution. James
[toc] | [prev] | [next] | [standalone]
| From | One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> |
|---|---|
| Date | 2016-08-26 23:20 +0200 |
| Message-ID | <sawHD-3UR-1@gated-at.bofh.it> |
| In reply to | #1470792 |
> A non-security use case would be to run the binary (without > modification) with a different ELF interpreter (assuming this allows to > override binfmt_elf, but self-sandboxing would need that as well). This > would make it easier to use older or newer libcs for select binaries on > the system. Right now, one has to write wrappers for that, and the > explicit dynamic linker invocation is not completely transparent to the > application. If it gets in I'll be using it to label CP/M COM files so that they can be auto-run nicely when crossbuilding stuff in part with the original tools but a modern build environment 8) Sandboxing is an obvious use but there are more bizarre ones such as marking a file system image to get auto-run under a virtual machine or make containers fire up as if they were commands. It's effectively also the long missing but much needed "this document belongs to this app" meta data that MacOS and the like have had for decades. Alan
[toc] | [prev] | [next] | [standalone]
| From | James Bottomley <James.Bottomley@HansenPartnership.com> |
|---|---|
| Date | 2016-08-26 23:30 +0200 |
| Message-ID | <sawRj-3Y5-5@gated-at.bofh.it> |
| In reply to | #1470997 |
On Fri, 2016-08-26 at 22:12 +0100, One Thousand Gnomes wrote: > > A non-security use case would be to run the binary (without > > modification) with a different ELF interpreter (assuming this > > allows to override binfmt_elf, but self-sandboxing would need that > > as well). This would make it easier to use older or newer libcs > > for select binaries on the system. Right now, one has to write > > wrappers for that, and the explicit dynamic linker invocation is > > not completely transparent to the application. > > If it gets in I'll be using it to label CP/M COM files so that they > can be auto-run nicely when crossbuilding stuff in part with the > original tools but a modern build environment 8) > > Sandboxing is an obvious use but there are more bizarre ones such as > marking a file system image to get auto-run under a virtual machine > or make containers fire up as if they were commands. So I asked previously but didn't get an answer. If this is useful for sandboxing and being in the sandbox depends on the xattr value, shouldn't it be in one of the privileged xattr namespaces, not the user. one? James > It's effectively also the long missing but much needed "this document > belongs to this app" meta data that MacOS and the like have had for > decades. > > Alan > -- > To unsubscribe from this list: send the line "unsubscribe linux > -fsdevel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >
[toc] | [prev] | [next] | [standalone]
| From | One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> |
|---|---|
| Date | 2016-08-27 14:00 +0200 |
| Message-ID | <saKrf-44i-13@gated-at.bofh.it> |
| In reply to | #1471000 |
On Fri, 26 Aug 2016 17:26:18 -0400 James Bottomley <James.Bottomley@HansenPartnership.com> wrote: > On Fri, 2016-08-26 at 22:12 +0100, One Thousand Gnomes wrote: > > > A non-security use case would be to run the binary (without > > > modification) with a different ELF interpreter (assuming this > > > allows to override binfmt_elf, but self-sandboxing would need that > > > as well). This would make it easier to use older or newer libcs > > > for select binaries on the system. Right now, one has to write > > > wrappers for that, and the explicit dynamic linker invocation is > > > not completely transparent to the application. > > > > If it gets in I'll be using it to label CP/M COM files so that they > > can be auto-run nicely when crossbuilding stuff in part with the > > original tools but a modern build environment 8) > > > > Sandboxing is an obvious use but there are more bizarre ones such as > > marking a file system image to get auto-run under a virtual machine > > or make containers fire up as if they were commands. > > So I asked previously but didn't get an answer. If this is useful for > sandboxing and being in the sandbox depends on the xattr value, > shouldn't it be in one of the privileged xattr namespaces, not the > user. one? IMHO no - because it's not giving additional rights, it is taking rights away voluntarily - because as a user I can simply cp the file to get an unsandboxed version If it was a setuid like bit then yes it would matter. Alan
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web