Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757175AbdDFMz2 (ORCPT ); Thu, 6 Apr 2017 08:55:28 -0400 Received: from mail-yw0-f172.google.com ([209.85.161.172]:33634 "EHLO mail-yw0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756947AbdDFMzT (ORCPT ); Thu, 6 Apr 2017 08:55:19 -0400 Date: Thu, 6 Apr 2017 08:55:14 -0400 From: Alexei Starovoitov To: Tycho Andersen Cc: Kees Cook , Daniel Borkmann , Alexei Starovoitov , LKML , Network Development , "kernel-hardening@lists.openwall.com" , =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= Subject: Re: [PATCH] ebpf: verify the output of the JIT Message-ID: <20170406125513.GA56553@ast-mbp.thefacebook.com> References: <20170404220810.14250-1-tycho@docker.com> <20170405034536.oulhc3ylhlrfgqeg@docker> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170405034536.oulhc3ylhlrfgqeg@docker> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1562 Lines: 34 On Tue, Apr 04, 2017 at 09:45:36PM -0600, Tycho Andersen wrote: > Hi Kees, > > On Tue, Apr 04, 2017 at 03:17:57PM -0700, Kees Cook wrote: > > On Tue, Apr 4, 2017 at 3:08 PM, Tycho Andersen wrote: > > > The goal of this patch is to protect the JIT against an attacker with a > > > write-in-memory primitive. The JIT allocates a buffer which will eventually > > > be marked +x, so we need to make sure that what was written to this buffer > > > is what was intended. > > > > > > We acheive this by building a hash of the instruction buffer as > > > instructions are emittted and then comparing that to a hash at the end of > > > the JIT compile after the buffer has been marked read-only. > > > > > > Signed-off-by: Tycho Andersen > > > CC: Daniel Borkmann > > > CC: Alexei Starovoitov > > > CC: Kees Cook > > > CC: Micka?l Sala?n > > > > Cool! This closes the race condition on producing the JIT vs going > > read-only. I wonder if it might be possible to make this a more > > generic interface to the BPF which would be allocate the hash, provide > > the update callback during emit, and then do the hash check itself at > > the end of bpf_jit_binary_lock_ro()? > > Yes, probably so. I can look into that for the next version. Nack. Please stop wasting yours and our time with buggy code that pretends to fix a problem that doesn't exist. This security paranoia around JIT must stop. Make sure that CONFIG_BPF_JIT is off in your system.