Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp146190ima; Thu, 25 Oct 2018 17:18:34 -0700 (PDT) X-Google-Smtp-Source: AJdET5fQwdSgnm+Gl04oP5kh3zveK6stw6OiRpGMwNddlJwA1Ht9ljxX7b26zfbfgYjqFD/Bd92B X-Received: by 2002:a17:902:e00a:: with SMTP id ca10-v6mr1278817plb.166.1540513114873; Thu, 25 Oct 2018 17:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540513114; cv=none; d=google.com; s=arc-20160816; b=daTjsXazKg+CQl172w1oWC6Iv+RSegMO3upcsFWE46PZxiZyoj8pjS/Sz63DKC6/cM MXNJTI80sbXKQAluyXPs+zTTgyWVj+Ke/GdK5lfEMWm7QGIOVEqSLms63NVynwnTcYFd OrAtJw7ic1ks83SK/4eWIKnxbKea1dWuygm6XDlYvi99elC5HFeC3LPP4NdYAOq2GYBI Fl0gVwMimkkvwJA/+ArCsAqO4dJF7cumXgmW8WDGkfgBVhhKQUG7aDiKO0vdYRrPfJS+ 8A3qm+28S4gX3D/hkSErfutPd7m5XgSZcuwmn5OuIb/6gLSlSMVJLHYpSccnn3yg+gjc ILSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Z7Wvlm+UPuunyxf7xRLHkbAOSpFa6NUPWmoOQFvLsak=; b=HVMuSRjE9XBn1cTv8zhdv0aKDf+b6nrMW3ls9eAeHqfIpIJiYYr2MfTZWW/K9qnC3a 9XD+JHIL9X8WnpZpz3Z6591VasY7PcZ6NIWkBWUe5zQcTKUrjXsyxADpKeX/P4xOJCUE VgLRMVbWFIwfGzjLKeGRmY0+SDdEzuigKZXlpl1687qCbgJOCowcuc44JNZ4zBznQDuV DT8cUL+Ck5guOvGa510tamDdmj7vJ5scabsT+duNUqfw+VGCTovjXrvWcJLVLOKNxmgn dshu42oOGnec8sJLhybGnkPGdO/QoGMQ6tABn6yrGI+xLe+uac9TYlPOORB3WHyAe2l1 79+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E7GLl2AL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1-v6si10065923pfn.117.2018.10.25.17.18.18; Thu, 25 Oct 2018 17:18:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E7GLl2AL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726501AbeJZIwD (ORCPT + 99 others); Fri, 26 Oct 2018 04:52:03 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:36884 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbeJZIwC (ORCPT ); Fri, 26 Oct 2018 04:52:02 -0400 Received: by mail-yb1-f196.google.com with SMTP id d18-v6so4471113yba.4; Thu, 25 Oct 2018 17:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Z7Wvlm+UPuunyxf7xRLHkbAOSpFa6NUPWmoOQFvLsak=; b=E7GLl2ALsu8z4sBIzlm5YqkDAz7tvrafyI92q1olDcRFI9VHsCcEeSrSzYHnMfXEM9 aQntRb6T7cEsQ40ZWnPZKKdxsTBO9Z4hnBYZmPxigkPetlxoCbArzbDtroIeGRCGnhiQ IUWvQSq7ItnzZMiGVAbtBq/eg/LuoS9HptJVwXmn5dukE57wd0lqppb07wbR6vqnlmdg YzFWXTWEoQwXFF34QeVk9/YGsRQ6XhHi3/z2lmg0u9aw2ndONq5c+qULloeEEyd9JIvU ch7pSq/IM+4ExNP8M8x/PpFS7yUVyrG8QsuISXS5kfMVL65YpoYPRyUinI3LUmoUlnkE Y8PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Z7Wvlm+UPuunyxf7xRLHkbAOSpFa6NUPWmoOQFvLsak=; b=PK6dv1BCSsj8U5FNrkhk25WraFNcQ2QuyBmHXmaBoasfS+k4D9J1syNfqsdoumbrB0 BHwbv8sVA18cOE+dFxSmtMWEi+kAC5UcXm4JV82NHUL5aaPRUUb70j8u6RreJlUFxYLk hIFYevk7Rka3Rqx4l7nEk0LhTKroVjBpRgss/pZOI5PRk0tupdOxQqxwqlIAnC4ujYe4 ypUp83jLSRaRXa9WOW5SL2wX3aWMaUvJn4oR96jXYZeujHQyQ16M679YtZq3ivvVxVV6 J7y315prGDAqdbRJmChFB8hrW1Q7vswI6kFZhnkDJYgN6H+OEQWV5Fn/8O7dxmo/PRoR k1RQ== X-Gm-Message-State: AGRZ1gLvCH0sATUMbUTJK0yRROeb/E/ExqSm8RmKHI+wWKG3fO4Ehobf YD4u7fsNC2t9jOHa6iYChZ4= X-Received: by 2002:a25:be85:: with SMTP id i5-v6mr1580081ybk.138.1540513036751; Thu, 25 Oct 2018 17:17:16 -0700 (PDT) Received: from ast-mbp ([2620:10d:c091:180::1:9409]) by smtp.gmail.com with ESMTPSA id q6-v6sm2842056ywh.41.2018.10.25.17.17.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Oct 2018 17:17:15 -0700 (PDT) Date: Thu, 25 Oct 2018 17:17:13 -0700 From: Alexei Starovoitov To: Daniel Borkmann Cc: ast@kernel.org, rick.p.edgecombe@intel.com, eric.dumazet@gmail.com, jannh@google.com, keescook@chromium.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH bpf] bpf: add bpf_jit_limit knob to restrict unpriv allocations Message-ID: <20181026001711.w55n5au2vx3sepmb@ast-mbp> References: <20181022231104.3443-1-daniel@iogearbox.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181022231104.3443-1-daniel@iogearbox.net> User-Agent: NeoMutt/20180223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 23, 2018 at 01:11:04AM +0200, Daniel Borkmann wrote: > Rick reported that the BPF JIT could potentially fill the entire module > space with BPF programs from unprivileged users which would prevent later > attempts to load normal kernel modules or privileged BPF programs, for > example. If JIT was enabled but unsuccessful to generate the image, then > before commit 290af86629b2 ("bpf: introduce BPF_JIT_ALWAYS_ON config") > we would always fall back to the BPF interpreter. Nowadays in the case > where the CONFIG_BPF_JIT_ALWAYS_ON could be set, then the load will abort > with a failure since the BPF interpreter was compiled out. > > Add a global limit and enforce it for unprivileged users such that in case > of BPF interpreter compiled out we fail once the limit has been reached > or we fall back to BPF interpreter earlier w/o using module mem if latter > was compiled in. In a next step, fair share among unprivileged users can > be resolved in particular for the case where we would fail hard once limit > is reached. > > Fixes: 290af86629b2 ("bpf: introduce BPF_JIT_ALWAYS_ON config") > Fixes: 0a14842f5a3c ("net: filter: Just In Time compiler for x86-64") > Co-Developed-by: Rick Edgecombe > Signed-off-by: Daniel Borkmann > Acked-by: Alexei Starovoitov > Cc: Eric Dumazet > Cc: Jann Horn > Cc: Kees Cook > Cc: LKML > --- > Hi Rick, I've reworked the original patch into something much simpler > which is only focussing on the actual main issue we want to resolve right > now as a first step to make some forward progress, that is, limiting usage > on the JIT for unprivileged users. Tested the below on x86 and arm64. > (Trimmed down massive Cc list as well a bit and Cc'ed people related to > commits referenced and netdev where BPF patches are usually discussed.) > Thanks a lot! Applied to bpf tree. Thanks Daniel.