Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4752979pxj; Wed, 12 May 2021 12:26:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx259E7WWa/0/IxrKFJspTdsC1gRX6A6a8N6f0fKADi7+Rq9ad6T989PHk6xiVX5HctFfqX X-Received: by 2002:a17:907:161f:: with SMTP id hb31mr39588401ejc.514.1620847459735; Wed, 12 May 2021 12:24:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620847459; cv=none; d=google.com; s=arc-20160816; b=k5dgBTzUyia86UYhkjMZZlNc7M/95R7B/GgfaDQORfw0xX7sQVsXRFknNXPmnKQLkY AXp/A/yKNK2TJnKusEKXKS9VPkemrA3eitI0Gv34yF/qOu9b2fMUm3vzWXb/lfVWvQlL PuOAfe7D9uKJBIs4umZTJnYfeGHSDmhLGMdX/GFSWm+qNWaK+GbLOAlrCsrSsb7YUHTU Kr6Ju0XqKl9TnJXi+FHizWDDMYv8OOnZRkU3Q2KBH7mDxtwBzYZyMzPjRatW+Vdw16e3 /1thE5EiHrK932Dq4Vo6MJram9xxRi8TRdFXTjOm3gEZCHN/glGySFiokIVcVkAmVU7m SC0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1wT9y/+CUxpw2t+GrCY0Qp+nfyUTGHKVjJx14ixlaYw=; b=Dq9HwLZ6ihCyXUd0nyaERgvTQbafzkpWpcd2i98P5Nty1jmcMMJoi8v/7tKPu5vZYJ ximpWfac0KZFD5jFcylx1J33KE716Fc5fGQraL3Brqk16Kei6YkTDC5+D6DGx8gn+XUl WLZ5sUVDtJq0JktvByYFI4XPRJVMzFqWJpzYz+zkCi4J4MRO7IDEI5xIqd+KTDfjK/8o dd9VgVRRIOaDcovU/AgYK+lLJGKzPLtoqFb2bpzF4gAI9Ofx+HbeNcKW1r0+8GlS61Hq yJRw468qRhOMKnBi0VteMYB4IwE5CGbTIGg69GtkARDvLdDXzRqqiWglCLTUk0pFm6Xq Srew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ef0LUMNJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si484397edd.145.2021.05.12.12.23.55; Wed, 12 May 2021 12:24:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ef0LUMNJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379007AbhELTSZ (ORCPT + 99 others); Wed, 12 May 2021 15:18:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50155 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244347AbhELQpp (ORCPT ); Wed, 12 May 2021 12:45:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620837874; 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=Ef0LUMNJ+2iDUklUtfj2fdV2HB1I/+d678yNRRsNH0CmZj2p6+sv+xWuwkLgMvaclkBbe9 baMOvRkm/NTiCSawZeWMKdHs7NMcV0vHrjipIl5adLaZjYulxItr4wnA8KimvrvJHa7rfU iGSsuBwZJhcEV4PMOmsBy7npFV2cWyA= Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-478-kPmap6uQOb6iQz04pO4eow-1; Wed, 12 May 2021 12:44:33 -0400 X-MC-Unique: kPmap6uQOb6iQz04pO4eow-1 Received: by mail-yb1-f197.google.com with SMTP id d4-20020a25b5c40000b02904f8e3c8c6c9so12099177ybg.14 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=SLxlb5bczf5lUo0dP48Xalvvajh7BQGHF8VYI55fEAWJjmWLAQ39GcNWZx91FEN6xU bP/qjLYpVp0XSVbmxkNEPMvfyBDye/6z/OikDXexOFlIXjUDGWZIHYfyYJXOT873ax1u CWoCQEmvh1NC7Z9jKp1bIEQlqagUq9iv9k3ntyT4t/hPe/+qQNCPhT5c0IK8kmPjK5Kh v0777MGuEhkjvDHsmcw/Yti5JV1TRkOuQjytAX9us6zeS9pOKYWNlyKrWJb3sntdtHqV pxf8W4740n6MaIFLdCsscovhSa17NRFZ/K8/fWLgpG0FNQrYIiROGDQRiGwgVgSonD+O q2yA== X-Gm-Message-State: AOAM531UoPcSkUW57Ix2IDs87XKuhxaVHtBlCPmBT4gX1NilF3Xr+ktj /YCD7KWhMt21OX5oLWBBA5w+O835vrsEl9JL8KFHLcDvQ2UtVKWqkMVk/sroZSekcc9rZogurms almAWBYvNmcAAjXcWqgpL4IRQnM28KpsGIVD9khkN X-Received: by 2002:a25:6886:: with SMTP id d128mr49884183ybc.227.1620837872713; Wed, 12 May 2021 09:44:32 -0700 (PDT) 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: linux-kernel@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.