Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp436271pxb; Fri, 29 Oct 2021 12:44:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxla26G2GJOQCmc27Nte/MdOixz4hrT86g+5LgIA1CBYnYk1nANyWez+hgYBs/ahZsTqtCe X-Received: by 2002:a05:6e02:1a42:: with SMTP id u2mr10027750ilv.97.1635536645927; Fri, 29 Oct 2021 12:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635536645; cv=none; d=google.com; s=arc-20160816; b=S6O1gE96C3pE3sai5EsaDo/qOlHQKVFsw5wsBocwl+hEWoaRDnS+UvuDaz+XcKAEvb Tx86D1JHnwpFBGUmzPqTv4Wsh6eOe5hUE5Ns6ZbdUNj6rlAdGL7nU7JZWnMDM/0vGKv7 eyEa6uIFoPxFSz3q0a0DWJlglHZBL2dj8hzmEIhymq8g7taGiwUM5NtEHTXVeskTdauT adjP8Ly3XcrPwHa01dccmb1AeBDKGKM5PR4zuGaL2cb7pQ1aVEzZFT21o/yd5gLMdnYK vze0qsPdaK153W3cHqRmKovJnkmqMZSv5Gzay7vRAGh/B8TLgCHlDuM7lmGO/kCDLmGD B2cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=gn9U7gGdA+WeErbo9uxq5f7cfwy1qxp91JvyhWQSwKg=; b=ifCDRN9UpaOVDjrZ+uxsqV2UI8VDfxRJzpLgPMBHWinqfCZ5asrcs8PGjnyYaDqI4Y JR+wuOPMbtj93VhiYBR0L23LevM8qIEf0b3cjYPd6zYZElUqVs0WKCo+VjyHXjOwQIRl DLDmHb4He/3AV+MNHIFw2sa51kiEJ7yA+JXOsjuxy+rVJ7qJDBzw+OGNOMFyq6Op4IZ8 ohMF2vs7aXpmfCvBukyEjI5V5PLbhG4vQqjKwKCxrY2CIU1+1hySU6zhmep86TjIgSyg pNAYYNMpJ/3Ha4NSNXVPPM4LkbHBSXOT+9LqIP7cW3KJS/s+8RFv9Hxp0wrNJ7A0BEuj FbQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b97si7557216jai.49.2021.10.29.12.43.54; Fri, 29 Oct 2021 12:44:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231305AbhJ2ToU (ORCPT + 99 others); Fri, 29 Oct 2021 15:44:20 -0400 Received: from mga02.intel.com ([134.134.136.20]:57300 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229474AbhJ2ToT (ORCPT ); Fri, 29 Oct 2021 15:44:19 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10152"; a="217920452" X-IronPort-AV: E=Sophos;i="5.87,193,1631602800"; d="scan'208";a="217920452" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2021 12:41:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,193,1631602800"; d="scan'208";a="487693801" Received: from gupta-dev2.jf.intel.com (HELO gupta-dev2.localdomain) ([10.54.74.119]) by orsmga007.jf.intel.com with ESMTP; 29 Oct 2021 12:41:36 -0700 Date: Fri, 29 Oct 2021 12:43:54 -0700 From: Pawan Gupta To: Alexei Starovoitov , Daniel Borkmann Cc: Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, antonio.gomez.iglesias@intel.com, tony.luck@intel.com, dave.hansen@linux.intel.com, gregkh@linuxfoundation.org, mark.rutland@arm.com, linux@armlinux.org.uk Subject: [PATCH ebpf v3] bpf: Disallow unprivileged bpf by default Message-ID: <0ace9ce3f97656d5f62d11093ad7ee81190c3c25.1635535215.git.pawan.kumar.gupta@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Disabling unprivileged BPF would help prevent unprivileged users from creating the conditions required for potential speculative execution side-channel attacks on affected hardware. A deep dive on such attacks and mitigation is available here [1]. Sync with what many distros are currently applying, disable unprivileged BPF by default. An admin can enable this at runtime, if necessary. [1] https://ebpf.io/summit-2021-slides/eBPF_Summit_2021-Keynote-Daniel_Borkmann-BPF_and_Spectre.pdf Signed-off-by: Pawan Gupta --- v3: - Drop the conditional default for CONFIG_BPF_UNPRIV_DEFAULT_OFF until we have an arch generic way to determine arch-common spectre type bugs. [Mark Rutland, Daniel Borkmann]. - Also drop the patch to Generalize ARM's CONFIG_CPU_SPECTRE. - Minor changes to commit message. v2: https://lore.kernel.org/lkml/cover.1635383031.git.pawan.kumar.gupta@linux.intel.com/ - Generalize ARM's CONFIG_CPU_SPECTRE to be available for all architectures. - Make CONFIG_BPF_UNPRIV_DEFAULT_OFF depend on CONFIG_CPU_SPECTRE. - Updated commit message to reflect the dependency on CONFIG_CPU_SPECTRE. - Add reference to BPF spectre presentation in commit message. v1: https://lore.kernel.org/all/d37b01e70e65dced2659561ed5bc4b2ed1a50711.1635367330.git.pawan.kumar.gupta@linux.intel.com/ kernel/bpf/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/bpf/Kconfig b/kernel/bpf/Kconfig index a82d6de86522..73d446294455 100644 --- a/kernel/bpf/Kconfig +++ b/kernel/bpf/Kconfig @@ -64,6 +64,7 @@ config BPF_JIT_DEFAULT_ON config BPF_UNPRIV_DEFAULT_OFF bool "Disable unprivileged BPF by default" + default y depends on BPF_SYSCALL help Disables unprivileged BPF by default by setting the corresponding @@ -72,6 +73,10 @@ config BPF_UNPRIV_DEFAULT_OFF disable it by setting it to 1 (from which no other transition to 0 is possible anymore). + Unprivileged BPF can be used to exploit potential speculative + execution side-channel vulnerabilities on affected hardware. If you + are concerned about it, answer Y. + source "kernel/bpf/preload/Kconfig" config BPF_LSM -- 2.31.1