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=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE autolearn=no 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 4E46DC433ED for ; Wed, 12 May 2021 17:07:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CFBE613E6 for ; Wed, 12 May 2021 17:07:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241568AbhELRIi (ORCPT ); Wed, 12 May 2021 13:08:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40093 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244359AbhELQpq (ORCPT ); Wed, 12 May 2021 12:45:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620837876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1wT9y/+CUxpw2t+GrCY0Qp+nfyUTGHKVjJx14ixlaYw=; b=XzcW+h7FZZt+OkHxpxIsfqmMxRzF+v/BpzsKYx5mnjzowbigVKijhTMLzdcr1fEP9FU8Px AfRmRoLR2+KEF6BHuo3a/8J4sWuxECABjpy3Xlo9+dvNEPb34OSITSeOe+4RBm2/eGf0/k jRIOuT5OLNvi9Zp+Twx9X9fwotrBtOU= Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-549-T_6AGsWBOxWE1rKvmJcv-g-1; Wed, 12 May 2021 12:44:33 -0400 X-MC-Unique: T_6AGsWBOxWE1rKvmJcv-g-1 Received: by mail-yb1-f199.google.com with SMTP id w80-20020a25df530000b02904f953b5241bso3589710ybg.18 for ; Wed, 12 May 2021 09:44:33 -0700 (PDT) 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=1wT9y/+CUxpw2t+GrCY0Qp+nfyUTGHKVjJx14ixlaYw=; b=HAsE+v9Cs/ZCvEq0RtGdfri0UyHtzBuwJ+IPDHkRTfIBQ1X98FZ8OymqbvmCa3M53N yizzkRTRAxHYNZx/QOrnfWra+GD0wmT7f1JF9z1J03NbKn1SG+CW5HDQ5i+HRXDrnVM1 iueClM7ZBBIIuA8yJG41bEBko2egSNalpuTFvhl9YhFY8vio/2PhDI1EB/9UVAM9FKCL HOFLizJ/5mOCts3DI8c4dGfCkuJ+LZTGl8ryovVf85i8NgJQByXexnXq0esieb8y618g Y+fbycCIpy336/miVJhWWuRTMVwH0OnMgNqDiWKGC7xoHWTQ8d46cgqThTxceYnew5Vu 0bVQ== X-Gm-Message-State: AOAM530vJxorhDAEBRZeN3vka5VH96WI7ldrhAtNKblVV7VofgxGvg+R 3E1bS2eaT4nghCcTQRIXkeQPVmzeKtj70R4Cfnx4ArCdB/AO75kLRirw3N+gAZjjbPwtKZwPbfu OEU3ehgyG5/80oSDDVCGnyJXwp814 X-Received: by 2002:a25:6886:: with SMTP id d128mr49884188ybc.227.1620837872714; Wed, 12 May 2021 09:44:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziai7GI5a1DWeJt0YlXK6570k2N9+Sy1G9tLOxLGUvPGU+rPfrJ8aFA1k+I7x/KZgli19pSgP+PzUsymRQT9M= X-Received: by 2002:a25:6886:: with SMTP id d128mr49884143ybc.227.1620837872433; Wed, 12 May 2021 09:44:32 -0700 (PDT) MIME-Version: 1.0 References: <20210507114048.138933-1-omosnace@redhat.com> <24a61ff1-e415-adf8-17e8-d212364d4b97@schaufler-ca.com> In-Reply-To: <24a61ff1-e415-adf8-17e8-d212364d4b97@schaufler-ca.com> From: Ondrej Mosnacek Date: Wed, 12 May 2021 18:44:21 +0200 Message-ID: Subject: Re: [PATCH] lockdown,selinux: fix bogus SELinux lockdown permission checks To: Casey Schaufler Cc: Linux Security Module list , James Morris , Steven Rostedt , Ingo Molnar , Stephen Smalley , SElinux list , linuxppc-dev@lists.ozlabs.org, Linux FS Devel , bpf , network dev , Linux kernel mailing list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Wed, May 12, 2021 at 6:18 PM Casey Schaufler wrote: > On 5/12/2021 6:21 AM, Ondrej Mosnacek wrote: > > On Sat, May 8, 2021 at 12:17 AM Casey Schaufler wrote: > >> On 5/7/2021 4:40 AM, Ondrej Mosnacek wrote: > >>> Commit 59438b46471a ("security,lockdown,selinux: implement SELinux > >>> lockdown") added an implementation of the locked_down LSM hook to > >>> SELinux, with the aim to restrict which domains are allowed to perform > >>> operations that would breach lockdown. > >>> > >>> However, in several places the security_locked_down() hook is called in > >>> situations where the current task isn't doing any action that would > >>> directly breach lockdown, leading to SELinux checks that are basically > >>> bogus. > >>> > >>> Since in most of these situations converting the callers such that > >>> security_locked_down() is called in a context where the current task > >>> would be meaningful for SELinux is impossible or very non-trivial (and > >>> could lead to TOCTOU issues for the classic Lockdown LSM > >>> implementation), fix this by adding a separate hook > >>> security_locked_down_globally() > >> This is a poor solution to the stated problem. Rather than adding > >> a new hook you should add the task as a parameter to the existing hook > >> and let the security modules do as they will based on its value. > >> If the caller does not have an appropriate task it should pass NULL. > >> The lockdown LSM can ignore the task value and SELinux can make its > >> own decision based on the task value passed. > > The problem with that approach is that all callers would then need to > > be updated and I intended to keep the patch small as I'd like it to go > > to stable kernels as well. > > > > But it does seem to be a better long-term solution - would it work for > > you (and whichever maintainer would be taking the patch(es)) if I just > > added another patch that refactors it to use the task parameter? > > I can't figure out what you're suggesting. Are you saying that you > want to add a new hook *and* add the task parameter? No, just to keep this patch as-is (and let it go to stable in this form) and post another (non-stable) patch on top of it that undoes the new hook and re-implements the fix using your suggestion. (Yeah, it'll look weird, but I'm not sure how better to handle such situation - I'm open to doing it whatever different way the maintainers prefer.) -- Ondrej Mosnacek Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.