Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4469080pxj; Wed, 12 May 2021 06:23:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIGUjvYzVD1nm0ifUTVbOHP/d1u+V3kuhcVJ8ywt0eDtiKQwmw9pOxKTDiqGWYsh9bkipp X-Received: by 2002:a17:906:355a:: with SMTP id s26mr36397997eja.528.1620825816544; Wed, 12 May 2021 06:23:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620825816; cv=none; d=google.com; s=arc-20160816; b=rl+a9qLu5/Cu4L7HyswwKwVtvUpjLB4YUJz46KRLmD+w0VSvvWYplFl9hMIxZpegpe HHWcFoVlgbPV+RzuHbkveZYk1USFqOEwLUYth7yU34CPVoBMngBPa8kvASciqlVutuGN 4+dLiac7W1uQuFV9E3hFdcHK8un9v+011kAiG7fhT2xKghD+0MsYWEKoiqE7SsrDpSaM b6TB1/9IAUqoRtahzEmhhnpYrz4tinvurNPxML3nRzCLQjlG137sDoS9LeGC0yqVsjO0 e8piOjEDwnCJBH+4RBdJcdnk/0P9DKsPLiJ+/hG/86yH1FKnKFy+0ZTLGTDtVZGyOBBg cRgw== 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=dtvrIv0gd9IsJeuZT9VIJXOOFa9yzPvKusGPJfLQ7f4=; b=KAM/egEyaC1chwUSlSfsj7KrIt6O5kjlJwcb1VteJLLCMUaPp7rf7A2wDvAbQ7CyE2 YYV5FvtrUd27MkBLwvaxb9oUsVilkSV/guK7QbPf9W1MirG/Lcecxi5+3ZpNByLLBK7V zl75Pow5pjQEKsDPtzyfJ7lt9BQdtSyzrUcPrV4HbrgUCrXRcyfciUqs/rgVao2nveF1 JXNv5drDIO+V44+okKAUjFvDkbtOMFQ45Zsjz0aTnYMZrsuTJf3QTqJ7H8zMZph8t8Ys r1Vj30xP7tyeFuuAEYZgdyiN333eUEl1TD6p7dX7VtPvqp2EJeqyv4vOD82X175AzJvl zXkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A9HOWi9K; 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 8si25002748ejx.637.2021.05.12.06.22.55; Wed, 12 May 2021 06:23:36 -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=A9HOWi9K; 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 S230343AbhELNXB (ORCPT + 99 others); Wed, 12 May 2021 09:23:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51910 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230364AbhELNW7 (ORCPT ); Wed, 12 May 2021 09:22:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620825711; 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=dtvrIv0gd9IsJeuZT9VIJXOOFa9yzPvKusGPJfLQ7f4=; b=A9HOWi9KmzFFBTNqyY4ed5tNzt6Z/G0TAo1zXJQ+9ORQz1SNXSd6gmCqma9xc6OSYNDqmh 9QWsaMp1odA6cfPYSDGeRB3et+tqYOA0Ql6EFRefzo9/O0Ge/5sDJ8igY2qZ3+vNqXLV+F YeaGoGlJv7AFYoY30h7ZGxBft5bGNvY= 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-413-JtcJ-AaZPiSrTUU1iOoavQ-1; Wed, 12 May 2021 09:21:49 -0400 X-MC-Unique: JtcJ-AaZPiSrTUU1iOoavQ-1 Received: by mail-yb1-f197.google.com with SMTP id d63-20020a254f420000b02904f91ef33453so6873304ybb.12 for ; Wed, 12 May 2021 06:21:49 -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=dtvrIv0gd9IsJeuZT9VIJXOOFa9yzPvKusGPJfLQ7f4=; b=lUTkhzrBUmp3jbU8p42HDeNd6l1JyPr/0nlZzUUGr/Ia7jLe7MaanHoFkAAWFNypj/ d+12Cvm9vZNXyAlXqnG2KCrEin2OezCKlEbEn0Fe6f4PHpSues814sdEedE0sVm8NVzS bjN2BXaFa40aJ68DxAEY5s8JLEfHtjPVhBUTAwjQs7Tek7l+fJ7247Eo+Z0cLFzd77th q8bEHsTS0izemK+C4BKvO0VJEONMVwxaMNLXvMfTiT+MzAgdB9g76A/Y7gUPSRjdMbhg c14YG861krt9GniI0TwDgtyROEaKFf7bY4QpIvTLLzNWJwPr/2D9Yk8wzTifgI9GUBVJ dAvA== X-Gm-Message-State: AOAM531niX87TeIll8E6noonqHokaeOufWEhxHndNTN4IoJRHgHjC2pE TY6gnlap+yL6VcIpBQ9Z+5h+X0ygeI1M4LF6LBw4Oq08DGL8QAQOqYw0fa9v0esCYdSP/jMCoN+ 72LH1kexNNTHsm55jfwkwyKFNcuJKqPc0ZKWWDKKg X-Received: by 2002:a25:6983:: with SMTP id e125mr46782758ybc.81.1620825709171; Wed, 12 May 2021 06:21:49 -0700 (PDT) X-Received: by 2002:a25:6983:: with SMTP id e125mr46782731ybc.81.1620825708981; Wed, 12 May 2021 06:21:48 -0700 (PDT) MIME-Version: 1.0 References: <20210507114048.138933-1-omosnace@redhat.com> In-Reply-To: From: Ondrej Mosnacek Date: Wed, 12 May 2021 15:21:37 +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 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? -- Ondrej Mosnacek Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.