From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8764C10F06 for ; Sat, 6 Apr 2019 16:44:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F2C7218D3 for ; Sat, 6 Apr 2019 16:44:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="JB/yXI+T" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726499AbfDFQoG (ORCPT ); Sat, 6 Apr 2019 12:44:06 -0400 Received: from mail-vk1-f195.google.com ([209.85.221.195]:46056 "EHLO mail-vk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726475AbfDFQoG (ORCPT ); Sat, 6 Apr 2019 12:44:06 -0400 Received: by mail-vk1-f195.google.com with SMTP id h127so2118198vkd.12 for ; Sat, 06 Apr 2019 09:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1QPBWvNYRfn9RrwkGQNrcPHT2k49F8+w/Q08uBtT2w4=; b=JB/yXI+TgDQVGBmtzY2ZRlJ0qSadgN2Vxb0yPlHggu5bo3idHxxGmeEo3Wuj/TwU2U z0YCEy5FRbRoMrBBiPMRerZx88hdPKlC2yYrDiNB0mL1Pydz0See1IP7DuqIRMzxQdWC hJSO/JN3BzpXArUnEm570QxEaOQt3LrcyWdmM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1QPBWvNYRfn9RrwkGQNrcPHT2k49F8+w/Q08uBtT2w4=; b=OT8wLOy5LRXlVu2/ya4nz2ooXuXNKaP/vabnaRw0Bo84aDffxB8OFeQZIN79xWneNz hlz83xKVpN4ZhHCiSg4HW8lmoBvXKlj+Sp4YBH0o3vXjb1eMrxZUeLrTjKV2DK0Qs5gH MUOLYYjn1zslKaXAJuelW1D+FTxLwiasdm4A3a5vVnZosW/YisagYge7kUZ1EOEOyq0X zdY6mskFfsNuowFjEHC35g+bKI2VYEEH7feb2HrwxajOrw36OdlbfWY0/OjbKH6jOnv/ X6Pef2GSyDsAKeLMp99aCAAFc0RxLIxTMWKP0Pd9F4+uM9GcxhaUY8hWUj0nlARiTIWR oLZA== X-Gm-Message-State: APjAAAUpnGw9qie6QAp0hRlErcA07FQ0ASUvMTETvVLjR8mXiykCSdVH EUf6/wn1BtWZx5JjcAYyCIDb/es3olw= X-Google-Smtp-Source: APXvYqyakI2Qs5IOH6owd844ZeJTr5J+LelqDKZkJdQVW7Z2j1oCZddGAbOIxkIXIT+HzLgj/r579A== X-Received: by 2002:a1f:2106:: with SMTP id h6mr11674715vkh.18.1554569044734; Sat, 06 Apr 2019 09:44:04 -0700 (PDT) Received: from mail-vs1-f50.google.com (mail-vs1-f50.google.com. [209.85.217.50]) by smtp.gmail.com with ESMTPSA id q128sm7303666vke.2.2019.04.06.09.44.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Apr 2019 09:44:02 -0700 (PDT) Received: by mail-vs1-f50.google.com with SMTP id a190so5275105vsd.0 for ; Sat, 06 Apr 2019 09:44:02 -0700 (PDT) X-Received: by 2002:a67:1345:: with SMTP id 66mr11653813vst.30.1554569041739; Sat, 06 Apr 2019 09:44:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Kees Cook Date: Sat, 6 Apr 2019 09:43:50 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 bpf-next 00/21] bpf: Sysctl hook To: Andrey Ignatov Cc: Network Development , Alexei Starovoitov , Daniel Borkmann , Roman Gushchin , kernel-team , Luis Chamberlain , Alexey Dobriyan , LKML , "linux-fsdevel@vger.kernel.org" , linux-security-module , Jann Horn Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri, Apr 5, 2019 at 12:36 PM Andrey Ignatov wrote: > > v2->v3: > - simplify C based selftests by relying on variable offset stack access. > > v1->v2: > - add fs/proc/proc_sysctl.c mainteners to Cc:. > > The patch set introduces new BPF hook for sysctl. > > It adds new program type BPF_PROG_TYPE_CGROUP_SYSCTL and attach type > BPF_CGROUP_SYSCTL. > > BPF_CGROUP_SYSCTL hook is placed before calling to sysctl's proc_handler so > that accesses (read/write) to sysctl can be controlled for specific cgroup > and either allowed or denied, or traced. > > The hook has access to sysctl name, current sysctl value and (on write > only) to new sysctl value via corresponding helpers. New sysctl value can > be overridden by program. Both name and values (current/new) are > represented as strings same way they're visible in /proc/sys/. It is up to > program to parse these strings. > > To help with parsing the most common kind of sysctl value, vector of > integers, two new helpers are provided: bpf_strtol and bpf_strtoul with > semantic similar to user space strtol(3) and strtoul(3). > > The hook also provides bpf_sysctl context with two fields: > * @write indicates whether sysctl is being read (= 0) or written (= 1); > * @file_pos is sysctl file position to read from or write to, can be > overridden. > > The hook allows to make better isolation for containerized applications > that are run as root so that one container can't change a sysctl and affect > all other containers on a host, make changes to allowed sysctl in a safer > way and simplify sysctl tracing for cgroups. This sounds more like an LSM than BPF. So sysctls can get blocked when new BPF is added to a cgroup? Can the BPF be removed (or rather, what's the lifetime of such BPF?) -- Kees Cook