* General flags to turn things off (getrandom, pid lookup, etc)
@ 2014-07-25 18:30 Andy Lutomirski
2014-07-25 20:15 ` Dave Jones
` (2 more replies)
0 siblings, 3 replies; 28+ messages in thread
From: Andy Lutomirski @ 2014-07-25 18:30 UTC (permalink / raw)
To: Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro,
Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore,
James Morris, Linux API, Meredydd Luff, Christoph Hellwig,
linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o,
Andy Lutomirski, Henrique de Moraes Holschuh, linux-crypto
[new thread because this sort of combines two threads]
There is recent interest in having a way to turn generally-available
kernel features off. Maybe we should add a good one so we can stop
bikeshedding and avoid proliferating dumb interfaces.
Things that might want to be turn-off-able include:
- getrandom with GRND_RANDOM [from the getrandom threads]
- Any lookup of a non-self pid [from the capsicum thread]
- Any lookup of a pid outside the caller thread group [capsicum]
- Various architectural things (personal wishlist), e.g.:
- RDTSC and userspace HPET access
- CPUID?
- 32-bit GDT code segments [huge attack surface]
- 64-bit GDT code segments [probably pointless]
I would propose a new syscall for this:
long restrict_userspace(int mode, int type, int value, int flags);
mode is RESTRICT_SET, RESTRICT_GET, or RESTRICT_LOCK.
type is RESTRICT_GRND_RANDOM, RESTRICT_PID_SCOPE, RESTRICT_X86_TIMING, etc.
Value is zero if RESTRICT_GET. Otherwise value is the desired value,
generally 0 or 1. For RESTRICT_PID_SCOPE, value would be
RESTRICT_PID_SCOPE_ANY, RESTRICT_PID_SCOPE_THREADGROUP, or
RESTRICT_PID_SCOPE_SELF.
flags must be zero. Someday, someone will propose a thread-sync flag.
restrict_userspace requires either no_new_privs or CAP_SYS_ADMIN in
the current user namespace.
Thoughts?
--Andy
--
Andy Lutomirski
AMA Capital Management, LLC
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-25 18:30 General flags to turn things off (getrandom, pid lookup, etc) Andy Lutomirski @ 2014-07-25 20:15 ` Dave Jones [not found] ` <20140725201507.GA23410-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> [not found] ` <CALCETrWGvBfrX1W5XaFgJZhKHLf+oac9YrwPR3ppK=deQtu5hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2014-07-27 21:06 ` Theodore Ts'o 2 siblings, 1 reply; 28+ messages in thread From: Dave Jones @ 2014-07-25 20:15 UTC (permalink / raw) To: Andy Lutomirski Cc: Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto On Fri, Jul 25, 2014 at 11:30:48AM -0700, Andy Lutomirski wrote: > There is recent interest in having a way to turn generally-available > kernel features off. Maybe we should add a good one so we can stop > bikeshedding and avoid proliferating dumb interfaces. > > Things that might want to be turn-off-able include: > - getrandom with GRND_RANDOM [from the getrandom threads] > - Any lookup of a non-self pid [from the capsicum thread] > - Any lookup of a pid outside the caller thread group [capsicum] > - Various architectural things (personal wishlist), e.g.: > - RDTSC and userspace HPET access > - CPUID? > - 32-bit GDT code segments [huge attack surface] > - 64-bit GDT code segments [probably pointless] I'm not sure there's value in disabling cpuid dev interface, when the instruction is unprivileged. > I would propose a new syscall for this: > > long restrict_userspace(int mode, int type, int value, int flags); do the restrictions happen system-wide like in say SELinux, or only within the calling process, like seccomp ? Dave ^ permalink raw reply [flat|nested] 28+ messages in thread
[parent not found: <20140725201507.GA23410-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-25 20:15 ` Dave Jones @ 2014-07-25 20:21 ` Andy Lutomirski 0 siblings, 0 replies; 28+ messages in thread From: Andy Lutomirski @ 2014-07-25 20:21 UTC (permalink / raw) To: Dave Jones, Andy Lutomirski, Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto-u79uwXL29TY76Z2rM5mHXA On Fri, Jul 25, 2014 at 1:15 PM, Dave Jones <davej-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote: > On Fri, Jul 25, 2014 at 11:30:48AM -0700, Andy Lutomirski wrote: > > > There is recent interest in having a way to turn generally-available > > kernel features off. Maybe we should add a good one so we can stop > > bikeshedding and avoid proliferating dumb interfaces. > > > > Things that might want to be turn-off-able include: > > - getrandom with GRND_RANDOM [from the getrandom threads] > > - Any lookup of a non-self pid [from the capsicum thread] > > - Any lookup of a pid outside the caller thread group [capsicum] > > - Various architectural things (personal wishlist), e.g.: > > - RDTSC and userspace HPET access > > - CPUID? > > - 32-bit GDT code segments [huge attack surface] > > - 64-bit GDT code segments [probably pointless] > > I'm not sure there's value in disabling cpuid dev interface, > when the instruction is unprivileged. I meant the CPUID instruction. Some CPUs have a setting that turns off the CPUID instruction for user code. In principle, all VMs can do this, too, if the hypervisor would be kind enough to help out. I only mentioned the x86 stuff here to make the point that there are quite a few possibilities along these lines. There's actually already a way to turn off RDTSC, but it's not currently very useful because it doesn't do the right thing for the vDSO. That could be fixed, but there's certainly no reason to make any of the other stuff here wait for that. > > > I would propose a new syscall for this: > > > > long restrict_userspace(int mode, int type, int value, int flags); > > do the restrictions happen system-wide like in say SELinux, > or only within the calling process, like seccomp ? > The calling process and children, like seccomp. --Andy ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-25 20:21 ` Andy Lutomirski 0 siblings, 0 replies; 28+ messages in thread From: Andy Lutomirski @ 2014-07-25 20:21 UTC (permalink / raw) To: Dave Jones, Andy Lutomirski, Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto On Fri, Jul 25, 2014 at 1:15 PM, Dave Jones <davej@redhat.com> wrote: > On Fri, Jul 25, 2014 at 11:30:48AM -0700, Andy Lutomirski wrote: > > > There is recent interest in having a way to turn generally-available > > kernel features off. Maybe we should add a good one so we can stop > > bikeshedding and avoid proliferating dumb interfaces. > > > > Things that might want to be turn-off-able include: > > - getrandom with GRND_RANDOM [from the getrandom threads] > > - Any lookup of a non-self pid [from the capsicum thread] > > - Any lookup of a pid outside the caller thread group [capsicum] > > - Various architectural things (personal wishlist), e.g.: > > - RDTSC and userspace HPET access > > - CPUID? > > - 32-bit GDT code segments [huge attack surface] > > - 64-bit GDT code segments [probably pointless] > > I'm not sure there's value in disabling cpuid dev interface, > when the instruction is unprivileged. I meant the CPUID instruction. Some CPUs have a setting that turns off the CPUID instruction for user code. In principle, all VMs can do this, too, if the hypervisor would be kind enough to help out. I only mentioned the x86 stuff here to make the point that there are quite a few possibilities along these lines. There's actually already a way to turn off RDTSC, but it's not currently very useful because it doesn't do the right thing for the vDSO. That could be fixed, but there's certainly no reason to make any of the other stuff here wait for that. > > > I would propose a new syscall for this: > > > > long restrict_userspace(int mode, int type, int value, int flags); > > do the restrictions happen system-wide like in say SELinux, > or only within the calling process, like seccomp ? > The calling process and children, like seccomp. --Andy ^ permalink raw reply [flat|nested] 28+ messages in thread
[parent not found: <CALCETrWGvBfrX1W5XaFgJZhKHLf+oac9YrwPR3ppK=deQtu5hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-25 18:30 General flags to turn things off (getrandom, pid lookup, etc) Andy Lutomirski @ 2014-07-25 21:35 ` One Thousand Gnomes [not found] ` <CALCETrWGvBfrX1W5XaFgJZhKHLf+oac9YrwPR3ppK=deQtu5hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2014-07-27 21:06 ` Theodore Ts'o 2 siblings, 0 replies; 28+ messages in thread From: One Thousand Gnomes @ 2014-07-25 21:35 UTC (permalink / raw) To: Andy Lutomirski Cc: Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto-u79uwXL29TY76Z2rM5mHXA On Fri, 25 Jul 2014 11:30:48 -0700 Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org> wrote: > [new thread because this sort of combines two threads] > > There is recent interest in having a way to turn generally-available > kernel features off. Maybe we should add a good one so we can stop > bikeshedding and avoid proliferating dumb interfaces. We sort of have one. It's called capable(). Just needs extending to cover anything else you care about, and probably all the numeric constants replacing with textual names. Alan ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-25 21:35 ` One Thousand Gnomes 0 siblings, 0 replies; 28+ messages in thread From: One Thousand Gnomes @ 2014-07-25 21:35 UTC (permalink / raw) To: Andy Lutomirski Cc: Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto On Fri, 25 Jul 2014 11:30:48 -0700 Andy Lutomirski <luto@amacapital.net> wrote: > [new thread because this sort of combines two threads] > > There is recent interest in having a way to turn generally-available > kernel features off. Maybe we should add a good one so we can stop > bikeshedding and avoid proliferating dumb interfaces. We sort of have one. It's called capable(). Just needs extending to cover anything else you care about, and probably all the numeric constants replacing with textual names. Alan ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-25 21:35 ` One Thousand Gnomes (?) @ 2014-07-25 21:41 ` Andy Lutomirski 2014-07-26 19:48 ` Eric W. Biederman 2014-07-30 14:37 ` One Thousand Gnomes -1 siblings, 2 replies; 28+ messages in thread From: Andy Lutomirski @ 2014-07-25 21:41 UTC (permalink / raw) To: One Thousand Gnomes Cc: Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto On Fri, Jul 25, 2014 at 2:35 PM, One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> wrote: > On Fri, 25 Jul 2014 11:30:48 -0700 > Andy Lutomirski <luto@amacapital.net> wrote: > >> [new thread because this sort of combines two threads] >> >> There is recent interest in having a way to turn generally-available >> kernel features off. Maybe we should add a good one so we can stop >> bikeshedding and avoid proliferating dumb interfaces. > > We sort of have one. It's called capable(). Just needs extending to cover > anything else you care about, and probably all the numeric constants > replacing with textual names. > Except that it's all backwards: these are things that default to *on*, and people might want them to turn off. capable() is totally fscked if you want otherwise unprivileged users to carry capabilities around, and fixing it seems to run into endless claims that the "capability" system is carefully designed, flawless, perfect, ideal, amazing, and shouldn't be changed, despite the fact that it's empirically damn near useless. Also, capabilities do the wrong thing wrt namespaces. The things I'm talking about aren't namespaced. They're either on or off. --Andy ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-25 21:41 ` Andy Lutomirski @ 2014-07-26 19:48 ` Eric W. Biederman 2014-07-30 14:37 ` One Thousand Gnomes 1 sibling, 0 replies; 28+ messages in thread From: Eric W. Biederman @ 2014-07-26 19:48 UTC (permalink / raw) To: Andy Lutomirski Cc: One Thousand Gnomes, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto Andy Lutomirski <luto@amacapital.net> writes: > On Fri, Jul 25, 2014 at 2:35 PM, One Thousand Gnomes > <gnomes@lxorguk.ukuu.org.uk> wrote: >> On Fri, 25 Jul 2014 11:30:48 -0700 >> Andy Lutomirski <luto@amacapital.net> wrote: >> >>> [new thread because this sort of combines two threads] >>> >>> There is recent interest in having a way to turn generally-available >>> kernel features off. Maybe we should add a good one so we can stop >>> bikeshedding and avoid proliferating dumb interfaces. >> >> We sort of have one. It's called capable(). Just needs extending to cover >> anything else you care about, and probably all the numeric constants >> replacing with textual names. The big difference is capable only subdivides roots powers (aka things most applications should not have). When we start talking about things that things that are safe for most applications capable is probably not the right tool for the job. A much closer match is the personality system call. Look at setarch to see how it is used. My biggest concern with personality is there are only 32bits to play with. Still I expect what you want may be a sandbox personality, that disables everything that could possibly be a problem (including access to the personality syscall). Eric ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-26 19:48 ` Eric W. Biederman 0 siblings, 0 replies; 28+ messages in thread From: Eric W. Biederman @ 2014-07-26 19:48 UTC (permalink / raw) To: Andy Lutomirski Cc: One Thousand Gnomes, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto Andy Lutomirski <luto@amacapital.net> writes: > On Fri, Jul 25, 2014 at 2:35 PM, One Thousand Gnomes > <gnomes@lxorguk.ukuu.org.uk> wrote: >> On Fri, 25 Jul 2014 11:30:48 -0700 >> Andy Lutomirski <luto@amacapital.net> wrote: >> >>> [new thread because this sort of combines two threads] >>> >>> There is recent interest in having a way to turn generally-available >>> kernel features off. Maybe we should add a good one so we can stop >>> bikeshedding and avoid proliferating dumb interfaces. >> >> We sort of have one. It's called capable(). Just needs extending to cover >> anything else you care about, and probably all the numeric constants >> replacing with textual names. The big difference is capable only subdivides roots powers (aka things most applications should not have). When we start talking about things that things that are safe for most applications capable is probably not the right tool for the job. A much closer match is the personality system call. Look at setarch to see how it is used. My biggest concern with personality is there are only 32bits to play with. Still I expect what you want may be a sandbox personality, that disables everything that could possibly be a problem (including access to the personality syscall). Eric ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-25 21:41 ` Andy Lutomirski 2014-07-26 19:48 ` Eric W. Biederman @ 2014-07-30 14:37 ` One Thousand Gnomes 1 sibling, 0 replies; 28+ messages in thread From: One Thousand Gnomes @ 2014-07-30 14:37 UTC (permalink / raw) To: Andy Lutomirski Cc: Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto > > We sort of have one. It's called capable(). Just needs extending to cover > > anything else you care about, and probably all the numeric constants > > replacing with textual names. > > > > Except that it's all backwards: these are things that default to *on*, > and people might want them to turn off. capable() is totally fscked > if you want otherwise unprivileged users to carry capabilities around The userspace API is, but capable() as a userspace API and capable() as an in kernel check are only connected by history. For the in kernel part you can either teach everyone another disjoint API or we can have a single API in kernel for saying "is XYZ allowed". ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-25 18:30 General flags to turn things off (getrandom, pid lookup, etc) Andy Lutomirski @ 2014-07-25 23:43 ` H. Peter Anvin [not found] ` <CALCETrWGvBfrX1W5XaFgJZhKHLf+oac9YrwPR3ppK=deQtu5hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2014-07-27 21:06 ` Theodore Ts'o 2 siblings, 0 replies; 28+ messages in thread From: H. Peter Anvin @ 2014-07-25 23:43 UTC (permalink / raw) To: Andy Lutomirski, Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto-u79uwXL29TY76Z2rM5mHXA On 07/25/2014 11:30 AM, Andy Lutomirski wrote: > - 32-bit GDT code segments [huge attack surface] > - 64-bit GDT code segments [probably pointless] I presume you mean s/GDT/LDT/. We already don't allow 64-bit LDT code segments. Also, it is unclear to me how 32-bit LDT segments have a huge attack surface, given that there will realistically always be a 32-bit *GDT* segment present. -hpa ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-25 23:43 ` H. Peter Anvin 0 siblings, 0 replies; 28+ messages in thread From: H. Peter Anvin @ 2014-07-25 23:43 UTC (permalink / raw) To: Andy Lutomirski, Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto On 07/25/2014 11:30 AM, Andy Lutomirski wrote: > - 32-bit GDT code segments [huge attack surface] > - 64-bit GDT code segments [probably pointless] I presume you mean s/GDT/LDT/. We already don't allow 64-bit LDT code segments. Also, it is unclear to me how 32-bit LDT segments have a huge attack surface, given that there will realistically always be a 32-bit *GDT* segment present. -hpa ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-25 23:43 ` H. Peter Anvin (?) @ 2014-07-25 23:54 ` Andy Lutomirski -1 siblings, 0 replies; 28+ messages in thread From: Andy Lutomirski @ 2014-07-25 23:54 UTC (permalink / raw) To: H. Peter Anvin Cc: Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto On Fri, Jul 25, 2014 at 4:43 PM, H. Peter Anvin <hpa@zytor.com> wrote: > On 07/25/2014 11:30 AM, Andy Lutomirski wrote: >> - 32-bit GDT code segments [huge attack surface] >> - 64-bit GDT code segments [probably pointless] > > I presume you mean s/GDT/LDT/. > > We already don't allow 64-bit LDT code segments. Also, it is unclear to > me how 32-bit LDT segments have a huge attack surface, given that there > will realistically always be a 32-bit *GDT* segment present. I really did mean GDT :) Setting the 32-bit code segment to "not present" (and using seccomp to block modify_ldt) prevents any attempt to exploit bugs in the sysenter and cstar code. It also might prevent exploiting CPU bugs, although I've never heard of a relevant CPU bug in this area. If I actually tried to implement this (which wouldn't be part of the initial implementation), I'd split out the unusual things in __switch_to and friends to a slow path that's only used if weird settings are present (e.g. this, TSC restrictions, etc). But twiddling the present bit on a GDT entry is very fast, I assume -- it's just memory, and I don't think that any flush is needed. Also, if I implement this, I will curse Xen. I might even go so far as to disable the feature entirely if there's a paravirt GDT. Hmm. A separate flag to turn int $0x80 into GPF could have some value, too. --Andy ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-25 18:30 General flags to turn things off (getrandom, pid lookup, etc) Andy Lutomirski @ 2014-07-27 12:26 ` David Drysdale [not found] ` <CALCETrWGvBfrX1W5XaFgJZhKHLf+oac9YrwPR3ppK=deQtu5hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2014-07-27 21:06 ` Theodore Ts'o 2 siblings, 0 replies; 28+ messages in thread From: David Drysdale @ 2014-07-27 12:26 UTC (permalink / raw) To: Andy Lutomirski Cc: Eric W. Biederman, Julien Tinnes, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto-u79uwXL29TY76Z2rM5mHXA On Fri, Jul 25, 2014 at 7:30 PM, Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org> wrote: > [new thread because this sort of combines two threads] > > There is recent interest in having a way to turn generally-available > kernel features off. Maybe we should add a good one so we can stop > bikeshedding and avoid proliferating dumb interfaces. > > Things that might want to be turn-off-able include: > - getrandom with GRND_RANDOM [from the getrandom threads] > - Any lookup of a non-self pid [from the capsicum thread] > - Any lookup of a pid outside the caller thread group [capsicum] > - Various architectural things (personal wishlist), e.g.: > - RDTSC and userspace HPET access > - CPUID? > - 32-bit GDT code segments [huge attack surface] > - 64-bit GDT code segments [probably pointless] > > I would propose a new syscall for this: > > long restrict_userspace(int mode, int type, int value, int flags); > > mode is RESTRICT_SET, RESTRICT_GET, or RESTRICT_LOCK. > > type is RESTRICT_GRND_RANDOM, RESTRICT_PID_SCOPE, RESTRICT_X86_TIMING, etc. > > Value is zero if RESTRICT_GET. Otherwise value is the desired value, > generally 0 or 1. For RESTRICT_PID_SCOPE, value would be > RESTRICT_PID_SCOPE_ANY, RESTRICT_PID_SCOPE_THREADGROUP, or > RESTRICT_PID_SCOPE_SELF. > > flags must be zero. Someday, someone will propose a thread-sync flag. Today, me: proposed :-) > restrict_userspace requires either no_new_privs or CAP_SYS_ADMIN in > the current user namespace. > > Thoughts? > > --Andy > > -- > Andy Lutomirski > AMA Capital Management, LLC ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-27 12:26 ` David Drysdale 0 siblings, 0 replies; 28+ messages in thread From: David Drysdale @ 2014-07-27 12:26 UTC (permalink / raw) To: Andy Lutomirski Cc: Eric W. Biederman, Julien Tinnes, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Theodore Ts'o, Henrique de Moraes Holschuh, linux-crypto On Fri, Jul 25, 2014 at 7:30 PM, Andy Lutomirski <luto@amacapital.net> wrote: > [new thread because this sort of combines two threads] > > There is recent interest in having a way to turn generally-available > kernel features off. Maybe we should add a good one so we can stop > bikeshedding and avoid proliferating dumb interfaces. > > Things that might want to be turn-off-able include: > - getrandom with GRND_RANDOM [from the getrandom threads] > - Any lookup of a non-self pid [from the capsicum thread] > - Any lookup of a pid outside the caller thread group [capsicum] > - Various architectural things (personal wishlist), e.g.: > - RDTSC and userspace HPET access > - CPUID? > - 32-bit GDT code segments [huge attack surface] > - 64-bit GDT code segments [probably pointless] > > I would propose a new syscall for this: > > long restrict_userspace(int mode, int type, int value, int flags); > > mode is RESTRICT_SET, RESTRICT_GET, or RESTRICT_LOCK. > > type is RESTRICT_GRND_RANDOM, RESTRICT_PID_SCOPE, RESTRICT_X86_TIMING, etc. > > Value is zero if RESTRICT_GET. Otherwise value is the desired value, > generally 0 or 1. For RESTRICT_PID_SCOPE, value would be > RESTRICT_PID_SCOPE_ANY, RESTRICT_PID_SCOPE_THREADGROUP, or > RESTRICT_PID_SCOPE_SELF. > > flags must be zero. Someday, someone will propose a thread-sync flag. Today, me: proposed :-) > restrict_userspace requires either no_new_privs or CAP_SYS_ADMIN in > the current user namespace. > > Thoughts? > > --Andy > > -- > Andy Lutomirski > AMA Capital Management, LLC ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-25 18:30 General flags to turn things off (getrandom, pid lookup, etc) Andy Lutomirski 2014-07-25 20:15 ` Dave Jones [not found] ` <CALCETrWGvBfrX1W5XaFgJZhKHLf+oac9YrwPR3ppK=deQtu5hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2014-07-27 21:06 ` Theodore Ts'o 2014-07-27 22:17 ` Andy Lutomirski 2 siblings, 1 reply; 28+ messages in thread From: Theodore Ts'o @ 2014-07-27 21:06 UTC (permalink / raw) To: Andy Lutomirski Cc: Eric W. Biederman, Julien Tinnes, David Drysdale, Al Viro, Paolo Bonzini, LSM List, Greg Kroah-Hartman, Paul Moore, James Morris, Linux API, Meredydd Luff, Christoph Hellwig, linux-kernel@vger.kernel.org, Kees Cook, Henrique de Moraes Holschuh, linux-crypto On Fri, Jul 25, 2014 at 11:30:48AM -0700, Andy Lutomirski wrote: > > There is recent interest in having a way to turn generally-available > kernel features off. Maybe we should add a good one so we can stop > bikeshedding and avoid proliferating dumb interfaces. I believe the seccomp infrastructure (which is already upstream) should be able to do most of what you want, at least with respect to features which are exposed via system calls (which was most of your list). It won't cover x86 specific things like restricting RDTSC or CPUID (and as far as I know you can't intercept the CPUID instruction), but I'm not sure it matters. I don't really see the point, myself. - Ted ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-27 21:06 ` Theodore Ts'o @ 2014-07-27 22:17 ` Andy Lutomirski [not found] ` <CALCETrXfzOZEC3mOKkm3_GvitvkEu4kAa3LowRv-fjHnzrQnBg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 28+ messages in thread From: Andy Lutomirski @ 2014-07-27 22:17 UTC (permalink / raw) To: Paolo Bonzini, linux-crypto, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Eric W. Biederman, Kees Cook, Meredydd Luff, Christoph Hellwig On Jul 27, 2014 5:06 PM, "Theodore Ts'o" <tytso@mit.edu> wrote: > > On Fri, Jul 25, 2014 at 11:30:48AM -0700, Andy Lutomirski wrote: > > > > There is recent interest in having a way to turn generally-available > > kernel features off. Maybe we should add a good one so we can stop > > bikeshedding and avoid proliferating dumb interfaces. > > I believe the seccomp infrastructure (which is already upstream) > should be able to do most of what you want, at least with respect to > features which are exposed via system calls (which was most of your > list). Seccomp can't really restrict lookups of non-self pids. In fact, this feature idea started out as a response to a patch adding a kind of nasty seccomp feature to make it sort of possible. I agree that that seccomp can turn off GRND_RANDOM, but how is it supposed to do it in such a way that the filtered software will fall back to something sensible? -ENOSYS? -EPERM? Something else? I think that -ENOSYS is clearly wrong, but standardizing this would be nice. Admittedly, adding something fancy like this for GRND_RANDOM may not be appropriate. --Andy > > It won't cover x86 specific things like restricting RDTSC or CPUID > (and as far as I know you can't intercept the CPUID instruction), but > I'm not sure it matters. I don't really see the point, myself. > > - Ted ^ permalink raw reply [flat|nested] 28+ messages in thread
[parent not found: <CALCETrXfzOZEC3mOKkm3_GvitvkEu4kAa3LowRv-fjHnzrQnBg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: General flags to turn things off (getrandom, pid lookup, etc) [not found] ` <CALCETrXfzOZEC3mOKkm3_GvitvkEu4kAa3LowRv-fjHnzrQnBg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2014-07-27 23:53 ` Eric W. Biederman @ 2014-07-27 23:53 ` Eric W. Biederman 0 siblings, 0 replies; 28+ messages in thread From: Eric W. Biederman @ 2014-07-27 23:53 UTC (permalink / raw) To: Andy Lutomirski Cc: Paolo Bonzini, linux-crypto-u79uwXL29TY76Z2rM5mHXA, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org> writes: > On Jul 27, 2014 5:06 PM, "Theodore Ts'o" <tytso-3s7WtUTddSA@public.gmane.org> wrote: >> >> On Fri, Jul 25, 2014 at 11:30:48AM -0700, Andy Lutomirski wrote: >> > >> > There is recent interest in having a way to turn generally-available >> > kernel features off. Maybe we should add a good one so we can stop >> > bikeshedding and avoid proliferating dumb interfaces. >> >> I believe the seccomp infrastructure (which is already upstream) >> should be able to do most of what you want, at least with respect to >> features which are exposed via system calls (which was most of your >> list). > > Seccomp can't really restrict lookups of non-self pids. In fact, this > feature idea started out as a response to a patch adding a kind of > nasty seccomp feature to make it sort of possible. > > I agree that that seccomp can turn off GRND_RANDOM, but how is it > supposed to do it in such a way that the filtered software will fall > back to something sensible? -ENOSYS? -EPERM? Something else? > > I think that -ENOSYS is clearly wrong, but standardizing this would be > nice. Admittedly, adding something fancy like this for GRND_RANDOM > may not be appropriate. Andy you seem to be arguing here for two system calls. get_urandom() and get_random(). Where get_urandom only blocks if there is not enough starting entropy, and get_random(GRND_RANDOM) blocks if there is currently not enough entropy. That would allow -ENOSYS to be the right return value and it would simply things for everyone. Eric ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-27 23:53 ` Eric W. Biederman 0 siblings, 0 replies; 28+ messages in thread From: Eric W. Biederman @ 2014-07-27 23:53 UTC (permalink / raw) To: Andy Lutomirski Cc: Paolo Bonzini, linux-crypto, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig Andy Lutomirski <luto@amacapital.net> writes: > On Jul 27, 2014 5:06 PM, "Theodore Ts'o" <tytso@mit.edu> wrote: >> >> On Fri, Jul 25, 2014 at 11:30:48AM -0700, Andy Lutomirski wrote: >> > >> > There is recent interest in having a way to turn generally-available >> > kernel features off. Maybe we should add a good one so we can stop >> > bikeshedding and avoid proliferating dumb interfaces. >> >> I believe the seccomp infrastructure (which is already upstream) >> should be able to do most of what you want, at least with respect to >> features which are exposed via system calls (which was most of your >> list). > > Seccomp can't really restrict lookups of non-self pids. In fact, this > feature idea started out as a response to a patch adding a kind of > nasty seccomp feature to make it sort of possible. > > I agree that that seccomp can turn off GRND_RANDOM, but how is it > supposed to do it in such a way that the filtered software will fall > back to something sensible? -ENOSYS? -EPERM? Something else? > > I think that -ENOSYS is clearly wrong, but standardizing this would be > nice. Admittedly, adding something fancy like this for GRND_RANDOM > may not be appropriate. Andy you seem to be arguing here for two system calls. get_urandom() and get_random(). Where get_urandom only blocks if there is not enough starting entropy, and get_random(GRND_RANDOM) blocks if there is currently not enough entropy. That would allow -ENOSYS to be the right return value and it would simply things for everyone. Eric ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-27 23:53 ` Eric W. Biederman 0 siblings, 0 replies; 28+ messages in thread From: Eric W. Biederman @ 2014-07-27 23:53 UTC (permalink / raw) To: Andy Lutomirski Cc: Paolo Bonzini, linux-crypto-u79uwXL29TY76Z2rM5mHXA, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org> writes: > On Jul 27, 2014 5:06 PM, "Theodore Ts'o" <tytso-3s7WtUTddSA@public.gmane.org> wrote: >> >> On Fri, Jul 25, 2014 at 11:30:48AM -0700, Andy Lutomirski wrote: >> > >> > There is recent interest in having a way to turn generally-available >> > kernel features off. Maybe we should add a good one so we can stop >> > bikeshedding and avoid proliferating dumb interfaces. >> >> I believe the seccomp infrastructure (which is already upstream) >> should be able to do most of what you want, at least with respect to >> features which are exposed via system calls (which was most of your >> list). > > Seccomp can't really restrict lookups of non-self pids. In fact, this > feature idea started out as a response to a patch adding a kind of > nasty seccomp feature to make it sort of possible. > > I agree that that seccomp can turn off GRND_RANDOM, but how is it > supposed to do it in such a way that the filtered software will fall > back to something sensible? -ENOSYS? -EPERM? Something else? > > I think that -ENOSYS is clearly wrong, but standardizing this would be > nice. Admittedly, adding something fancy like this for GRND_RANDOM > may not be appropriate. Andy you seem to be arguing here for two system calls. get_urandom() and get_random(). Where get_urandom only blocks if there is not enough starting entropy, and get_random(GRND_RANDOM) blocks if there is currently not enough entropy. That would allow -ENOSYS to be the right return value and it would simply things for everyone. Eric ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-27 23:53 ` Eric W. Biederman @ 2014-07-30 14:37 ` One Thousand Gnomes -1 siblings, 0 replies; 28+ messages in thread From: One Thousand Gnomes @ 2014-07-30 14:37 UTC (permalink / raw) To: Eric W. Biederman Cc: Andy Lutomirski, Paolo Bonzini, linux-crypto, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig > Andy you seem to be arguing here for two system calls. > get_urandom() and get_random(). > > Where get_urandom only blocks if there is not enough starting entropy, > and get_random(GRND_RANDOM) blocks if there is currently not enough > entropy. > > That would allow -ENOSYS to be the right return value and it would > simply things for everyone. So you replace the "no file handle" special case with the "unsupported or disabled syscall" special case, which is even harder to test. Interfaces have failure modes. People who can't deal with that shouldn't be writing code that does anything important in languages which don't handle it for them. Alan ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-30 14:37 ` One Thousand Gnomes 0 siblings, 0 replies; 28+ messages in thread From: One Thousand Gnomes @ 2014-07-30 14:37 UTC (permalink / raw) To: Eric W. Biederman Cc: Andy Lutomirski, Paolo Bonzini, linux-crypto, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig > Andy you seem to be arguing here for two system calls. > get_urandom() and get_random(). > > Where get_urandom only blocks if there is not enough starting entropy, > and get_random(GRND_RANDOM) blocks if there is currently not enough > entropy. > > That would allow -ENOSYS to be the right return value and it would > simply things for everyone. So you replace the "no file handle" special case with the "unsupported or disabled syscall" special case, which is even harder to test. Interfaces have failure modes. People who can't deal with that shouldn't be writing code that does anything important in languages which don't handle it for them. Alan ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-30 14:37 ` One Thousand Gnomes @ 2014-07-30 18:41 ` Eric W. Biederman -1 siblings, 0 replies; 28+ messages in thread From: Eric W. Biederman @ 2014-07-30 18:41 UTC (permalink / raw) To: One Thousand Gnomes Cc: Andy Lutomirski, Paolo Bonzini, linux-crypto, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> writes: >> Andy you seem to be arguing here for two system calls. >> get_urandom() and get_random(). >> >> Where get_urandom only blocks if there is not enough starting entropy, >> and get_random(GRND_RANDOM) blocks if there is currently not enough >> entropy. >> >> That would allow -ENOSYS to be the right return value and it would >> simply things for everyone. > > So you replace the "no file handle" special case with the "unsupported or > disabled syscall" special case, which is even harder to test. > > Interfaces have failure modes. People who can't deal with that shouldn't > be writing code that does anything important in languages which don't > handle it for them. Perhaps I misread the earlier conversation but it what I have read of this discussion people want to disable some of get_random() modes with seccomp. Today get_random does not have any failure codes define except -ENOSYS. get_random(0) succeeding and get_random(GRND_RANDOM) returning -ENOSYS has every chance of causing applications to legitimately assume the get_random system call is not available in any mode. So the code either needs a defined error code for bad flags (-EINVAL) or we need to split the syscall in two. Now that I think about it having the seccomp filter return -EINVAL if it doesn't like the parameter is better that splitting a syscall. Presumably that is what get_random(UNSUPPORTED_FLAG) returns. Eric ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-30 18:41 ` Eric W. Biederman 0 siblings, 0 replies; 28+ messages in thread From: Eric W. Biederman @ 2014-07-30 18:41 UTC (permalink / raw) To: One Thousand Gnomes Cc: Andy Lutomirski, Paolo Bonzini, linux-crypto, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> writes: >> Andy you seem to be arguing here for two system calls. >> get_urandom() and get_random(). >> >> Where get_urandom only blocks if there is not enough starting entropy, >> and get_random(GRND_RANDOM) blocks if there is currently not enough >> entropy. >> >> That would allow -ENOSYS to be the right return value and it would >> simply things for everyone. > > So you replace the "no file handle" special case with the "unsupported or > disabled syscall" special case, which is even harder to test. > > Interfaces have failure modes. People who can't deal with that shouldn't > be writing code that does anything important in languages which don't > handle it for them. Perhaps I misread the earlier conversation but it what I have read of this discussion people want to disable some of get_random() modes with seccomp. Today get_random does not have any failure codes define except -ENOSYS. get_random(0) succeeding and get_random(GRND_RANDOM) returning -ENOSYS has every chance of causing applications to legitimately assume the get_random system call is not available in any mode. So the code either needs a defined error code for bad flags (-EINVAL) or we need to split the syscall in two. Now that I think about it having the seccomp filter return -EINVAL if it doesn't like the parameter is better that splitting a syscall. Presumably that is what get_random(UNSUPPORTED_FLAG) returns. Eric ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-30 18:41 ` Eric W. Biederman @ 2014-07-30 21:29 ` One Thousand Gnomes -1 siblings, 0 replies; 28+ messages in thread From: One Thousand Gnomes @ 2014-07-30 21:29 UTC (permalink / raw) To: Eric W. Biederman Cc: Andy Lutomirski, Paolo Bonzini, linux-crypto, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig On Wed, 30 Jul 2014 11:41:41 -0700 ebiederm@xmission.com (Eric W. Biederman) wrote: > One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> writes: > > >> Andy you seem to be arguing here for two system calls. > >> get_urandom() and get_random(). > >> > >> Where get_urandom only blocks if there is not enough starting entropy, > >> and get_random(GRND_RANDOM) blocks if there is currently not enough > >> entropy. > >> > >> That would allow -ENOSYS to be the right return value and it would > >> simply things for everyone. > > > > So you replace the "no file handle" special case with the "unsupported or > > disabled syscall" special case, which is even harder to test. > > > > Interfaces have failure modes. People who can't deal with that shouldn't > > be writing code that does anything important in languages which don't > > handle it for them. > > Perhaps I misread the earlier conversation but it what I have read of > this discussion people want to disable some of get_random() modes with > seccomp. Today get_random does not have any failure codes define except > -ENOSYS. > > get_random(0) succeeding and get_random(GRND_RANDOM) returning -ENOSYS > has every chance of causing applications to legitimately assume the > get_random system call is not available in any mode. Or more likely it'll be used like this get_random(foo); /* always works */ Now the existing failure mode is is open(...) /* forget the check */ read() /* forget the check */ and triggered by evil local attacks on file handles. The "improved" behaviour is unchecked -ENOSYS returns which are likely to occur systemically when users run stuff on old kernels, in vm's with it off etc. So you've swapped the odd evil user attack on a single target for the likelyhood of mass generation of flawed keys with no error reporting. In fact you could do a better job of the whole mess in libc rather than the kernel, because in libc you'd write it like this if (open(.. ) < 0) kill(getpid(), 9); if (read(...) < expected) kill(getpid(), 9); close(fd); and a) on an older library you'd get a good failure (unable to execute the binary) b) on a newer system you'd get "do or die" behaviour and can improve its robustness as desired Alan ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-30 21:29 ` One Thousand Gnomes 0 siblings, 0 replies; 28+ messages in thread From: One Thousand Gnomes @ 2014-07-30 21:29 UTC (permalink / raw) To: Eric W. Biederman Cc: Andy Lutomirski, Paolo Bonzini, linux-crypto, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig On Wed, 30 Jul 2014 11:41:41 -0700 ebiederm@xmission.com (Eric W. Biederman) wrote: > One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> writes: > > >> Andy you seem to be arguing here for two system calls. > >> get_urandom() and get_random(). > >> > >> Where get_urandom only blocks if there is not enough starting entropy, > >> and get_random(GRND_RANDOM) blocks if there is currently not enough > >> entropy. > >> > >> That would allow -ENOSYS to be the right return value and it would > >> simply things for everyone. > > > > So you replace the "no file handle" special case with the "unsupported or > > disabled syscall" special case, which is even harder to test. > > > > Interfaces have failure modes. People who can't deal with that shouldn't > > be writing code that does anything important in languages which don't > > handle it for them. > > Perhaps I misread the earlier conversation but it what I have read of > this discussion people want to disable some of get_random() modes with > seccomp. Today get_random does not have any failure codes define except > -ENOSYS. > > get_random(0) succeeding and get_random(GRND_RANDOM) returning -ENOSYS > has every chance of causing applications to legitimately assume the > get_random system call is not available in any mode. Or more likely it'll be used like this get_random(foo); /* always works */ Now the existing failure mode is is open(...) /* forget the check */ read() /* forget the check */ and triggered by evil local attacks on file handles. The "improved" behaviour is unchecked -ENOSYS returns which are likely to occur systemically when users run stuff on old kernels, in vm's with it off etc. So you've swapped the odd evil user attack on a single target for the likelyhood of mass generation of flawed keys with no error reporting. In fact you could do a better job of the whole mess in libc rather than the kernel, because in libc you'd write it like this if (open(.. ) < 0) kill(getpid(), 9); if (read(...) < expected) kill(getpid(), 9); close(fd); and a) on an older library you'd get a good failure (unable to execute the binary) b) on a newer system you'd get "do or die" behaviour and can improve its robustness as desired Alan ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) 2014-07-30 21:29 ` One Thousand Gnomes @ 2014-07-31 2:37 ` Eric W. Biederman -1 siblings, 0 replies; 28+ messages in thread From: Eric W. Biederman @ 2014-07-31 2:37 UTC (permalink / raw) To: One Thousand Gnomes Cc: Andy Lutomirski, Paolo Bonzini, linux-crypto, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> writes: > On Wed, 30 Jul 2014 11:41:41 -0700 > ebiederm@xmission.com (Eric W. Biederman) wrote: > >> One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> writes: >> >> >> Andy you seem to be arguing here for two system calls. >> >> get_urandom() and get_random(). >> >> >> >> Where get_urandom only blocks if there is not enough starting entropy, >> >> and get_random(GRND_RANDOM) blocks if there is currently not enough >> >> entropy. >> >> >> >> That would allow -ENOSYS to be the right return value and it would >> >> simply things for everyone. >> > >> > So you replace the "no file handle" special case with the "unsupported or >> > disabled syscall" special case, which is even harder to test. >> > >> > Interfaces have failure modes. People who can't deal with that shouldn't >> > be writing code that does anything important in languages which don't >> > handle it for them. >> >> Perhaps I misread the earlier conversation but it what I have read of >> this discussion people want to disable some of get_random() modes with >> seccomp. Today get_random does not have any failure codes define except >> -ENOSYS. >> >> get_random(0) succeeding and get_random(GRND_RANDOM) returning -ENOSYS >> has every chance of causing applications to legitimately assume the >> get_random system call is not available in any mode. > > Or more likely it'll be used like this > > get_random(foo); /* always works */ > > > Now the existing failure mode is is > > open(...) > /* forget the check */ > read() > /* forget the check */ > > and triggered by evil local attacks on file handles. The "improved" > behaviour is unchecked -ENOSYS returns which are likely to occur > systemically when users run stuff on old kernels, in vm's with it off etc. > > So you've swapped the odd evil user attack on a single target for the > likelyhood of mass generation of flawed keys with no error reporting. > > In fact you could do a better job of the whole mess in libc rather than > the kernel, because in libc you'd write it like this > > if (open(.. ) < 0) > kill(getpid(), 9); > if (read(...) < expected) > kill(getpid(), 9); > close(fd); > > and > a) on an older library you'd get a good failure (unable to execute the > binary) > b) on a newer system you'd get "do or die" behaviour and can improve its > robustness as desired I have said enough about the silliness of disabling this syscall with seccomp or related infrastructure. The aspect I like about get_random() is that it will silence the requests from people to enable binary sysctl support in the kernel. Just so they can get random numbers when /dev/random and /dev/urandom are absent in their chroots. sysctl(2) is finally legitmately going fading away. Eric ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: General flags to turn things off (getrandom, pid lookup, etc) @ 2014-07-31 2:37 ` Eric W. Biederman 0 siblings, 0 replies; 28+ messages in thread From: Eric W. Biederman @ 2014-07-31 2:37 UTC (permalink / raw) To: One Thousand Gnomes Cc: Andy Lutomirski, Paolo Bonzini, linux-crypto, Henrique de Moraes Holschuh, linux-kernel@vger.kernel.org, James Morris, LSM List, Al Viro, Linux API, Julien Tinnes, Theodore Ts'o, Greg Kroah-Hartman, Paul Moore, David Drysdale, Kees Cook, Meredydd Luff, Christoph Hellwig One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> writes: > On Wed, 30 Jul 2014 11:41:41 -0700 > ebiederm@xmission.com (Eric W. Biederman) wrote: > >> One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> writes: >> >> >> Andy you seem to be arguing here for two system calls. >> >> get_urandom() and get_random(). >> >> >> >> Where get_urandom only blocks if there is not enough starting entropy, >> >> and get_random(GRND_RANDOM) blocks if there is currently not enough >> >> entropy. >> >> >> >> That would allow -ENOSYS to be the right return value and it would >> >> simply things for everyone. >> > >> > So you replace the "no file handle" special case with the "unsupported or >> > disabled syscall" special case, which is even harder to test. >> > >> > Interfaces have failure modes. People who can't deal with that shouldn't >> > be writing code that does anything important in languages which don't >> > handle it for them. >> >> Perhaps I misread the earlier conversation but it what I have read of >> this discussion people want to disable some of get_random() modes with >> seccomp. Today get_random does not have any failure codes define except >> -ENOSYS. >> >> get_random(0) succeeding and get_random(GRND_RANDOM) returning -ENOSYS >> has every chance of causing applications to legitimately assume the >> get_random system call is not available in any mode. > > Or more likely it'll be used like this > > get_random(foo); /* always works */ > > > Now the existing failure mode is is > > open(...) > /* forget the check */ > read() > /* forget the check */ > > and triggered by evil local attacks on file handles. The "improved" > behaviour is unchecked -ENOSYS returns which are likely to occur > systemically when users run stuff on old kernels, in vm's with it off etc. > > So you've swapped the odd evil user attack on a single target for the > likelyhood of mass generation of flawed keys with no error reporting. > > In fact you could do a better job of the whole mess in libc rather than > the kernel, because in libc you'd write it like this > > if (open(.. ) < 0) > kill(getpid(), 9); > if (read(...) < expected) > kill(getpid(), 9); > close(fd); > > and > a) on an older library you'd get a good failure (unable to execute the > binary) > b) on a newer system you'd get "do or die" behaviour and can improve its > robustness as desired I have said enough about the silliness of disabling this syscall with seccomp or related infrastructure. The aspect I like about get_random() is that it will silence the requests from people to enable binary sysctl support in the kernel. Just so they can get random numbers when /dev/random and /dev/urandom are absent in their chroots. sysctl(2) is finally legitmately going fading away. Eric ^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2014-07-31 2:37 UTC | newest]
Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-25 18:30 General flags to turn things off (getrandom, pid lookup, etc) Andy Lutomirski
2014-07-25 20:15 ` Dave Jones
[not found] ` <20140725201507.GA23410-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-07-25 20:21 ` Andy Lutomirski
2014-07-25 20:21 ` Andy Lutomirski
[not found] ` <CALCETrWGvBfrX1W5XaFgJZhKHLf+oac9YrwPR3ppK=deQtu5hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-07-25 21:35 ` One Thousand Gnomes
2014-07-25 21:35 ` One Thousand Gnomes
2014-07-25 21:41 ` Andy Lutomirski
2014-07-26 19:48 ` Eric W. Biederman
2014-07-26 19:48 ` Eric W. Biederman
2014-07-30 14:37 ` One Thousand Gnomes
2014-07-25 23:43 ` H. Peter Anvin
2014-07-25 23:43 ` H. Peter Anvin
2014-07-25 23:54 ` Andy Lutomirski
2014-07-27 12:26 ` David Drysdale
2014-07-27 12:26 ` David Drysdale
2014-07-27 21:06 ` Theodore Ts'o
2014-07-27 22:17 ` Andy Lutomirski
[not found] ` <CALCETrXfzOZEC3mOKkm3_GvitvkEu4kAa3LowRv-fjHnzrQnBg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-07-27 23:53 ` Eric W. Biederman
2014-07-27 23:53 ` Eric W. Biederman
2014-07-27 23:53 ` Eric W. Biederman
2014-07-30 14:37 ` One Thousand Gnomes
2014-07-30 14:37 ` One Thousand Gnomes
2014-07-30 18:41 ` Eric W. Biederman
2014-07-30 18:41 ` Eric W. Biederman
2014-07-30 21:29 ` One Thousand Gnomes
2014-07-30 21:29 ` One Thousand Gnomes
2014-07-31 2:37 ` Eric W. Biederman
2014-07-31 2:37 ` Eric W. Biederman
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.