Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5139019ybb; Tue, 24 Mar 2020 11:35:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs4tqFVC2qxV4ay4Rth0Nr1auDfi2/EiPwHg2WUKk8mYTNI0qu5wCMo3o5HlRAt5mepzAn8 X-Received: by 2002:aca:bd46:: with SMTP id n67mr4266523oif.120.1585074935579; Tue, 24 Mar 2020 11:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585074935; cv=none; d=google.com; s=arc-20160816; b=t8e91C7Q46atz+BSY/ic//IwDeynHJkbwVF/J3eFGNEJAD9K3Txrr733NoPIf9GIoO qB3gGlXc/4ebVisQOCmfOh9qihwuj3s8dgsToYGcKfTHGjR7qYzAEGkdaBUi/qw/nIo5 jtXL9I/be0oKdR3M7vE1VAHjhIwQooypJtN1BzujoIGc0bEI3Na+XD57rs7dLZdL3edP LXtzBtyHDbT004wDNMTsr31Mw0mbLb65WRuGEA69989xtAGCKP1Qh3TBmVzjl4xvSc3K gNF3jrZwVr0AGofy3wb53pwa5KhGOg71yFgNeji7S0ySYNsrxy/3G2K4FYs+0pdCMGSM YqMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mx9h2G9Pa234gVddEgnTViqlM2nzOYE5T6EE2ivPTBA=; b=1E/ZIkpdHTF9CO//GE9igT7wUbOOm7BZLSl9SWhvFlTuyMJTfQg/0VtTU3m4eOAxt2 qFVz8XG5TugN29cM5IMPjOLIOXSQ2xjZhkj/btJ40N3fCOn6VmlZ/b5vVgfPVbANGrvq GARSk6GGC9KGXjFU25MTmcJDr+zFO/VX0PlPM13op45Yr5DRo8qkM338a2VyY1+FeK09 KBM4v90BBl53K+RcVaOhyIbMIdwG1+rvIZacm7EAmr7qEY9KgBegNfur1IhPMM0yf/EA sfwlVHihspxCGdz7QBZ+9GHiToawI77ogYIblajSejUGaiam0rUiT2k8pcuzwnCgorF/ JWlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=X8BpTUsh; 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 r17si5388506otp.254.2020.03.24.11.35.21; Tue, 24 Mar 2020 11:35:35 -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=X8BpTUsh; 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 S1727708AbgCXSe5 (ORCPT + 99 others); Tue, 24 Mar 2020 14:34:57 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:51299 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727543AbgCXSe4 (ORCPT ); Tue, 24 Mar 2020 14:34:56 -0400 Received: by mail-pj1-f65.google.com with SMTP id hg10so1981110pjb.1 for ; Tue, 24 Mar 2020 11:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=mx9h2G9Pa234gVddEgnTViqlM2nzOYE5T6EE2ivPTBA=; b=X8BpTUshqVTp5ZrfGENJjA7S8D3PMkC1H9raELqRdSdjLNe5sZB5Y4RMX/nghlzJ8E 1CsWUkd+SHVMvC1UIUpx6JTnz1l2RNGsNZUks9+wLQ7kIaqQcNp/2bungkmZ4F+++aNv F9F+k+zvWPAIpXVP3evPY5DDeIBLOdTEoj2Ac= 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:content-transfer-encoding :in-reply-to; bh=mx9h2G9Pa234gVddEgnTViqlM2nzOYE5T6EE2ivPTBA=; b=BdShQFJZM8ygIMAefJtQv3q1dA557HS/ak5OK1g4cnHil6+fym6yoN3LqR/WDpKxFK bK7MSO+A6jgjNMYe7zsymGu6yH0z/xS3HCFpLjTbpnuEnQu0iuoA+aWjrLHWh6Ym2FNi oF7iyZD81kRz+5CP9q1Ipm/3ONqPYYvJ6GgPRUQzgq1astD5xvCbwG+ljhzXh2kxfUUH /MTUOpLgISedJkqN7SN2qkrwnWREZ5uD1VX5g7hd7b5A1xtt7dGriBAeAUvF+gQkixeY n22VEJvRqyYhbKol3W9RNNvKQjGJ9InW16WC0oTjiV/sTl1df+xMkKQx9eygfWbLSWMq t/Yw== X-Gm-Message-State: ANhLgQ0qmX2yp6njtY8o2JOEmgOyafO5qFVF0DkLBKLIZe7wTyS+/l1y eCIP+qUBDdTT+PazNwizuMequA== X-Received: by 2002:a17:902:850a:: with SMTP id bj10mr27476778plb.28.1585074894587; Tue, 24 Mar 2020 11:34:54 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x135sm15801559pgx.41.2020.03.24.11.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 11:34:53 -0700 (PDT) Date: Tue, 24 Mar 2020 11:34:52 -0700 From: Kees Cook To: KP Singh Cc: Stephen Smalley , Casey Schaufler , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, LSM List , Brendan Jackman , Florent Revest , Alexei Starovoitov , Daniel Borkmann , James Morris , Paul Turner , Jann Horn , Florent Revest , Brendan Jackman , Greg Kroah-Hartman , Paul Moore Subject: Re: [PATCH bpf-next v5 4/7] bpf: lsm: Implement attach, detach and execution Message-ID: <202003241133.16C02BE5B@keescook> References: <20200324145003.GA2685@chromium.org> <202003241100.279457EF@keescook> <20200324180652.GA11855@chromium.org> <20200324182759.GA5557@chromium.org> <20200324183130.GA6784@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200324183130.GA6784@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 24, 2020 at 07:31:30PM +0100, KP Singh wrote: > On 24-M?r 19:27, KP Singh wrote: > > We do not have a specific capable check for BPF_PROG_TYPE_LSM programs > > now. There is a general check which requires CAP_SYS_ADMIN when > > unprivileged BPF is disabled: > > > > in kernel/bpf/sycall.c: > > > > if (sysctl_unprivileged_bpf_disabled && !capable(CAP_SYS_ADMIN)) > > return -EPERM; > > > > AFAIK, Most distros disable unprivileged eBPF. > > > > Now that I look at this, I think we might need a CAP_MAC_ADMIN check > > though as unprivileged BPF being enabled will result in an > > unprivileged user being able to load MAC policies. > > Actually we do have an extra check for loading BPF programs: > > > in kernel/bpf/syscall.c:bpf_prog_load > > if (type != BPF_PROG_TYPE_SOCKET_FILTER && > type != BPF_PROG_TYPE_CGROUP_SKB && > !capable(CAP_SYS_ADMIN)) > return -EPERM; > > Do you think we still need a CAP_MAC_ADMIN check for LSM programs? IMO, these are distinct privileges on the non-SELinux system. I think your patch is fine as-is. -- Kees Cook