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.5 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,SPF_PASS 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 076E4C43470 for ; Wed, 12 May 2021 13:21:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3CA261363 for ; Wed, 12 May 2021 13:21:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231203AbhELNXC (ORCPT ); Wed, 12 May 2021 09:23:02 -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-Google-Smtp-Source: ABdhPJxmv2Qjn6VYEo9c/oXPEmu6i04CA+M1aunHQiWM6u48mJ31LcpQnTbka787MtlSpRVc8GFLI9xcdcVeHkvyMsg= 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.