Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5017812ybb; Tue, 24 Mar 2020 09:25:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs46gNCSWlDUKixXCoe3tKZ97ivJCv4T6eM7X7Rjh+Hmt3px3jl1VjXJJ2BUnNV6UWZWCEl X-Received: by 2002:a9d:6b02:: with SMTP id g2mr7136725otp.340.1585067153302; Tue, 24 Mar 2020 09:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585067153; cv=none; d=google.com; s=arc-20160816; b=acQ7KnYA/noxfGACp9x8J9no3/JkiI+q1Sq6l505VYcw/JXNsEUqVub6GfJeNF9jrf B+rv0P2OgtyKln9F2IAzmbmaTt8YU5oVS6OtLR9lXuV9AQ2cB2SRpUB0vmbcdRG2aJdL q9beaNp+5TW66YMYeinNwMjnTH2HWWSHll1DcHT4/Y4NEnAbcK6a7+SfAj1FCUsSK1L9 TODWiyKEjrWaApxTkMvzaQxS4a+L3ZbeiRRCF2ntCOtzU0lQKhGiyyc14MUgqMSkfVcE phJMuirDhtYimHGrb9vc+XLOEGvqSCER0HEYesJuxy2U7D3JUtWr1BUn6S2Ril+x1egU Bk9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=qdPQEgSTQB41Bal6ymFUiR/BsK6X7afGzWcEaJLoHCY=; b=ayuF5RfRnOCR4QbV/D1dNNA0/lDPPN+LESdLqPjAMBvjen8LU2EUZYn9UHn2DMdHH3 sKw6JDy0WEN28NOXcrNVy5wG2F9nHGkyW8yzLzbj1PhfD2RAnBgqRuxeMO8KnKCVuQzs ZEBd8M7sa0VOn8AQ/KKgRa85R2HIP7fz3Aw2WZ1SXMWjt3daSl2b+eKL6sIYIumfv8EP Ej8jYXrXpTFZd8/xajQx4XfCFLjMkqDurFcdEAE6uFepVAI7hhra8GcKECp+CkohJi8c 1/CH5bH1bNYFSNDUHlZ50D4s6F7CExwQ8hR3krW3uE59drU68gyOlJHh3TTAetJeweaY WRCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=nrHTJeUw; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 127si9130610oig.130.2020.03.24.09.25.40; Tue, 24 Mar 2020 09:25:53 -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=@yahoo.com header.s=s2048 header.b=nrHTJeUw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728159AbgCXQZR (ORCPT + 99 others); Tue, 24 Mar 2020 12:25:17 -0400 Received: from sonic307-15.consmr.mail.ne1.yahoo.com ([66.163.190.38]:45239 "EHLO sonic307-15.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727773AbgCXQZR (ORCPT ); Tue, 24 Mar 2020 12:25:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1585067114; bh=qdPQEgSTQB41Bal6ymFUiR/BsK6X7afGzWcEaJLoHCY=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=nrHTJeUw0AQJBDhA1F1a2M42iVMAemcpoCTq6OpwjNMKZAJvYb6N6KE8AWUm/MFNzqaDyfWJ0W097z63vstr1w1Pc7WyT+KxiPiM1Wi0NXt8d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_IDylg XmAjYg2LDWEBfRejjfJ_vKKCwVwTlU4wnsLTRnk8gVldwGH8RL4aUVMr5CQF8NTtEgsnI020MvWb 6trj1o0Wl05ZxWoNebmdbljlT2jnesajGvKg0GZyYsduRIF3tf4q8J2ofslGYD2tqcs_cTsp4OyE 93iMhHOhTeoUOWMXihhtS5ujGoF9j5AC0TcHxjVdAr7N.u74vfp.7D3_HzSGbaL9wN7JfZ968Xcn cITBwxO3YIy69nyA5nHKV3hbTtjiCLk1mx9ByAGmpOMH9a18igPTr8E3bcLZoMZwHuAbeg.fGg6K BPJBoBJS.HH2aExhy4jMPcdc_fLMaFsvMyRORq2UTvaPsj7PEg8HMcLHdbSf7_tRzSuBXsz1J.qG aYr12P__.tVkzG3ZqvPvqg70NIANQ1pgkmeFhIs4kC2Ttb5FOZekQGRM2kgOY1Tr2SgkG1MhgP0_ AFbqzRbSO0RIv53colcD00OuDBM2vpN2mu3YDAL69TCzg70r_d2StLC4DWI0DiGupl.e4DijrNpM naSOoKCzsS3EATzp4_sR5W_NJ6DDlDK4R45pSXdUAdCuDab2dEDrj2OwkJER4CCg4Q4SOdIhrv.a 5XskMx5hmi8DjC2mFnwD7sOUfcabwdhj6GZi3Zjcr1vYN Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ne1.yahoo.com with HTTP; Tue, 24 Mar 2020 16:25:14 +0000 Received: by smtp424.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 01ec4449a7fc946d45d56f2d212b357d; Tue, 24 Mar 2020 16:25:10 +0000 (UTC) Subject: Re: [PATCH bpf-next v5 4/7] bpf: lsm: Implement attach, detach and execution To: Stephen Smalley , KP Singh Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, LSM List , Brendan Jackman , Florent Revest , Alexei Starovoitov , Daniel Borkmann , James Morris , Kees Cook , Paul Turner , Jann Horn , Florent Revest , Brendan Jackman , Greg Kroah-Hartman , Paul Moore , Casey Schaufler References: <20200323164415.12943-1-kpsingh@chromium.org> <20200323164415.12943-5-kpsingh@chromium.org> <20200324145003.GA2685@chromium.org> From: Casey Schaufler Autocrypt: addr=casey@schaufler-ca.com; keydata= mQINBFzV9HABEAC/mmv3jeJyF7lR7QhILYg1+PeBLIMZv7KCzBSc/4ZZipoWdmr77Lel/RxQ 1PrNx0UaM5r6Hj9lJmJ9eg4s/TUBSP67mTx+tsZ1RhG78/WFf9aBe8MSXxY5cu7IUwo0J/CG vdSqACKyYPV5eoTJmnMxalu8/oVUHyPnKF3eMGgE0mKOFBUMsb2pLS/enE4QyxhcZ26jeeS6 3BaqDl1aTXGowM5BHyn7s9LEU38x/y2ffdqBjd3au2YOlvZ+XUkzoclSVfSR29bomZVVyhMB h1jTmX4Ac9QjpwsxihT8KNGvOM5CeCjQyWcW/g8LfWTzOVF9lzbx6IfEZDDoDem4+ZiPsAXC SWKBKil3npdbgb8MARPes2DpuhVm8yfkJEQQmuLYv8GPiJbwHQVLZGQAPBZSAc7IidD2zbf9 XAw1/SJGe1poxOMfuSBsfKxv9ba2i8hUR+PH7gWwkMQaQ97B1yXYxVEkpG8Y4MfE5Vd3bjJU kvQ/tOBUCw5zwyIRC9+7zr1zYi/3hk+OG8OryZ5kpILBNCo+aePeAJ44znrySarUqS69tuXd a3lMPHUJJpUpIwSKQ5UuYYkWlWwENEWSefpakFAIwY4YIBkzoJ/t+XJHE1HTaJnRk6SWpeDf CreF3+LouP4njyeLEjVIMzaEpwROsw++BX5i5vTXJB+4UApTAQARAQABtChDYXNleSBTY2hh dWZsZXIgPGNhc2V5QHNjaGF1Zmxlci1jYS5jb20+iQJUBBMBCAA+FiEEC+9tH1YyUwIQzUIe OKUVfIxDyBEFAlzV9HACGwMFCRLMAwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQOKUV fIxDyBG6ag/6AiRl8yof47YOEVHlrmewbpnlBTaYNfJ5cZflNRKRX6t4bp1B2YV1whlDTpiL vNOwFkh+ZE0eI5M4x8Gw2Oiok+4Q5liA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gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Mailer: WebService/1.1.15518 hermes Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_242) Content-Length: 2482 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/24/2020 7:58 AM, Stephen Smalley wrote: > On Tue, Mar 24, 2020 at 10:50 AM KP Singh wrote:= >> On 24-M=C3=A4r 10:35, Stephen Smalley wrote: >>> On Mon, Mar 23, 2020 at 12:46 PM KP Singh wrot= e: >>>> From: KP Singh >>>> diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c >>>> index 530d137f7a84..2a8131b640b8 100644 >>>> --- a/kernel/bpf/bpf_lsm.c >>>> +++ b/kernel/bpf/bpf_lsm.c >>>> @@ -9,6 +9,9 @@ >>>> #include >>>> #include >>>> #include >>>> +#include >>>> +#include >>>> +#include >>>> >>>> /* For every LSM hook that allows attachment of BPF programs, decl= are a NOP >>>> * function where a BPF program can be attached as an fexit trampol= ine. >>>> @@ -27,6 +30,32 @@ noinline __weak void bpf_lsm_##NAME(__VA_ARGS__) = {} >>>> #include >>>> #undef LSM_HOOK >>>> >>>> +#define BPF_LSM_SYM_PREFX "bpf_lsm_" >>>> + >>>> +int bpf_lsm_verify_prog(struct bpf_verifier_log *vlog, >>>> + const struct bpf_prog *prog) >>>> +{ >>>> + /* Only CAP_MAC_ADMIN users are allowed to make changes to L= SM hooks >>>> + */ >>>> + if (!capable(CAP_MAC_ADMIN)) >>>> + return -EPERM; >>> I had asked before, and will ask again: please provide an explicit LS= M >>> hook for mediating whether one can make changes to the LSM hooks. >>> Neither CAP_MAC_ADMIN nor CAP_SYS_ADMIN suffices to check this for SE= Linux. >> What do you think about: >> >> int security_check_mutable_hooks(void) >> >> Do you have any suggestions on the signature of this hook? Does this >> hook need to be BPF specific? > I'd do something like int security_bpf_prog_attach_security(const > struct bpf_prog *prog) or similar. > Then the security module can do a check based on the current task > and/or the prog. We already have some bpf-specific hooks. I *strongly* disagree with Stephen on this. KRSI and SELinux are peers. Just as Yama policy is independent of SELinux policy so KRSI policy shoul= d be independent of SELinux policy. I understand the argument that BDF prog= rams ought to be constrained by SELinux, but I don't think it's right. Further= , we've got unholy layering when security modules call security_ functions.= I'm not saying there is no case where it would be appropriate, but this i= s not one of them.