Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1345771yba; Sat, 6 Apr 2019 09:45:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkygTERDSe/St/DoqMBTjiLw7EUdO+K5Z/Azsoq2LqP26k4rYw9WRJUUtQVcE2Un2ImsDi X-Received: by 2002:a17:902:396a:: with SMTP id e39mr19961181plg.220.1554569125734; Sat, 06 Apr 2019 09:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554569125; cv=none; d=google.com; s=arc-20160816; b=taM7U7O/4AW36OvE/5qvctopCR63GSVUoiLxGk++VgPQZs+ZRLKn8l50ubj2aKAO0n eqgdG9TSD7PMdRFtwIbGxPCcqR10npsXG8dlwr8sPbPPsjG9uXOfTpRHpOUNQRNyW1Gh 67xsbZwO0cE5QJ2DUBCFwWfLNzCj3/tuyzlIrgrsVSjT5cqQuW+wFVwhITh509RsgOcd HBDsWjt3Mygj8akpWHBOTxz8I7Eg7TGKSArL0KgDxUbP9SMSaz9BZgExOTar2PURYjYs 9ieVXe/CEW9UPbMTdHQHzYsBItavT1T2t27RA5ql9ZYWtTFCTrX/FrEFqcTxOzuhbKP3 iC1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1QPBWvNYRfn9RrwkGQNrcPHT2k49F8+w/Q08uBtT2w4=; b=OivpjMWTW7xtHZWCuZzX2cQw9AknCi4TgCBsh6DLMNqZrXeU/hDke2zh2sB/uIDdaq 5hLjgUFuz59kcERcNhol9tr6LUZXqtzEUYJg61HErzDfLdrO8PY9rbK0/wi3uF/BPK/8 HFvma7GDCTVe9cv6ZQ72BoubegEloqxY7OVLMZiaGQV7tgZ0nnVBakF/+5wftrriL9ZM 11ajmX9WsiXIgE+Oc3SstuqCma5/HH+V+wH9IxSXSBHe5KXKp81DcExZQAQwat16g1JN ryGIwbLQEhqo3hqmKTUzWMmZWc5+Kyi9agps4USLlRBxPLhrGVUySzFw1UHFjL1dl5ab R8jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="JB/yXI+T"; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si13036714pgn.530.2019.04.06.09.44.59; Sat, 06 Apr 2019 09:45:25 -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=@chromium.org header.s=google header.b="JB/yXI+T"; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726580AbfDFQoJ (ORCPT + 99 others); Sat, 6 Apr 2019 12:44:09 -0400 Received: from mail-vs1-f65.google.com ([209.85.217.65]:32896 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726475AbfDFQoH (ORCPT ); Sat, 6 Apr 2019 12:44:07 -0400 Received: by mail-vs1-f65.google.com with SMTP id a190so5275166vsd.0 for ; Sat, 06 Apr 2019 09:44:06 -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=HYZDkuzxUl9r1c/HKCPEBdij3n8KZH3mnLLt6pKAFDLsL2cZenxItnEB0CdN4lPLV+ xTkD0MVusb4r3vj2LtWJWLKtYdRn43GkQU/Faay4mBYmxmPXHNSSzwLNlI9NczjVqBRD mj9Zij6hkEWBqKoPeoQzixHs8SgIKdk4wttWU9g81JD3hznMimjsymEdRc2BGAmkkoui ieGKZy7WG1vmslVcIvEWE+85Z7/zAoYqjzcOO2QNNt2JqYvI7k5MSZiXNwqEgUsA/9t5 uvSaDHrOKN4wEN8Z8Mms3DMv6HXppU9c5wdnT8v/fyWtZTVQ5+nuCIyJjrs43+/3ndh7 aZtA== X-Gm-Message-State: APjAAAU6ilx5oOP6xA7MEYexfoiBopyuk5VxEJTT1lfFt7vAW70UiMYl vk2qOfL7LA+o+WBurtYy+1GYv11RWPU= X-Received: by 2002:a67:f04e:: with SMTP id q14mr12099363vsm.133.1554569045812; Sat, 06 Apr 2019 09:44:05 -0700 (PDT) Received: from mail-vs1-f41.google.com (mail-vs1-f41.google.com. [209.85.217.41]) by smtp.gmail.com with ESMTPSA id m23sm36294298vsl.24.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:03 -0700 (PDT) Received: by mail-vs1-f41.google.com with SMTP id s2so5269900vsi.5 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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