Return-path: Received: from mga04.intel.com ([192.55.52.120]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fC8zX-0007Sa-3j for speck@linutronix.de; Fri, 27 Apr 2018 21:25:11 +0200 Date: Fri, 27 Apr 2018 12:25:08 -0700 From: Andi Kleen Subject: [MODERATED] Re: [PATCH v2] Linux Patch 1/1 Message-ID: <20180427192508.GG75137@tassilo.jf.intel.com> References: <92c45587-5eb3-2421-6fc1-42e74a715e30@linux.intel.com> <20180427164743.GA14180@pd.tnic> <6e2b14fc-3bf6-071d-6ce2-e518f2c4f069@redhat.com> <20180427173221.GB14180@pd.tnic> <20180427180944.GD75137@tassilo.jf.intel.com> <20180427184500.GE75137@tassilo.jf.intel.com> MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: > Still the point is that if you spawn a thread and you know that the thread > is going to run untrusted code, you want to make sure that MD is disabled > for that thread, right? So if that thread can reenable it, then you lost > control. There are multiple levels 1) JITed sandbox. cannot just do system calls, but can do PRIME+PROBE and may have call interfaces to other code 2) Native code process. No protection inside the process if you're at this level. Can also normally do system calls. 3) Kernel. 3) Between processes. We try to protect against case (1) doing attacks here. If the untrusted code can do random system calls you already lost control in a much worse way. So you already need to have system call protection in some way (using a JIT not allowing them or seccomp). Or rather if the process can subvert its environment somehow to do the prctl it can already execute arbitrary code, which is much worse the SSB. Or to put it differently, the point of the prctl is to not allow JITed code to read data it shouldn't read from its JITed sandbox. If it already has escaped its sandbox then it can already read everything it wants in its address space, and do much worse thing. On the other hand if you have the ability to switch it everywhere you want that gives you more flexibility to do the protection you need for your JIT. -Andi