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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 737E2C433F5 for ; Thu, 23 Sep 2021 15:53:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CB4560E9B for ; Thu, 23 Sep 2021 15:53:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242261AbhIWPzH (ORCPT ); Thu, 23 Sep 2021 11:55:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242220AbhIWPzE (ORCPT ); Thu, 23 Sep 2021 11:55:04 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1C80C061756 for ; Thu, 23 Sep 2021 08:53:32 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id c33so2633216ljr.8 for ; Thu, 23 Sep 2021 08:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lAIf9S9YD0oFbCvz8QEsqa7/B46ooiou6kW4WrW11es=; b=edcnJ+kYTFajOV6YWgCkDRJ7tuME3jDCu388x+5IygYwj23a8bZILaBVzhLYkO588z ljxnaGKMshQurnuGfYg4HBwiC3Ym6JVEffomTleMBklg9nYJ1H9ODcw++lFapFP+L7Zw y7IPRTqhyiGYRNXvP5nhI306iiITGHRqHb9Nk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lAIf9S9YD0oFbCvz8QEsqa7/B46ooiou6kW4WrW11es=; b=1pujat3c9s9UmayAtYaIW4dItOihErEHNF+XJTAYtADYaiUWBVFPPvCpUGFLDEpT7v cHiVpVAEtoLDEYzT5/p4ql9N1Ih7L20QNhYvqfsjNOrwokb6Q9X/LANbhHmsg5HuO2tT EPrN+5IXytNrcXBT3q1j6rMesuDJSmj2H04ROX9p+NUGOMK5ga7yFplbmgXx3D85WY5E lKKfMtdJwF82UD4k4K8JvET3ykeD2WGPnJuAQULdqju9+vCnKBtCAM7qI5+YB4hMvAc9 Ao2mkXFvf6m3eedVWFkLjAV8JaApjHnlEVlEszzDcAEOuUGklm/zEmr38j5Jeq2+Q8rv kA0w== X-Gm-Message-State: AOAM531C0QlqxZNrTZXbWGRjWpSPN1tT0/JR+Co36Wec+OhOiF1iRPxu Q94WnLYy7lrwNy69Kipa7whhlaqTp6Qp5HDh2Wo= X-Google-Smtp-Source: ABdhPJzo9D0nE2zILdj8p5WY5FaaNYD78NbqGZ5vrVAtimN1N1bdmDJhOXaKnJsG2R7q+ihYwNUedw== X-Received: by 2002:a2e:7804:: with SMTP id t4mr6019719ljc.346.1632412410076; Thu, 23 Sep 2021 08:53:30 -0700 (PDT) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com. [209.85.208.174]) by smtp.gmail.com with ESMTPSA id n11sm680416ljg.72.2021.09.23.08.53.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Sep 2021 08:53:29 -0700 (PDT) Received: by mail-lj1-f174.google.com with SMTP id g14so2742405ljk.5 for ; Thu, 23 Sep 2021 08:53:29 -0700 (PDT) X-Received: by 2002:a2e:4e01:: with SMTP id c1mr5757554ljb.31.1632412408652; Thu, 23 Sep 2021 08:53:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Thu, 23 Sep 2021 08:53:12 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] SELinux fixes for v5.15 (#1) To: Paul Moore Cc: SElinux list , LSM List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 23, 2021 at 8:43 AM Paul Moore wrote: > > However, we have the LSM framework because there is never one way to > solve a problem, The thing is, the lockdown patches were merged because they were allegedly sane. As far as I can tell, this is purely a SELinux internal bug. SELinux did something wrong. Stop doing it. Stop sending patches to then screw up the generic security layer, and violate the rules under which these patches were accepted. We have now this week have two discussions about the selinux doing completely invalid and incorrect things, and both were related to just thinking that it's ok to just randomly access thread data. At some point, you just have to look at the SELinux code and say :"this does something wrong". Instead of this kind of "no, everybody else is wrong, I will modify them to do what I mistakenly did". IOW, just make the patch be diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 6517f221d52c..4e93bf5dc8ef 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -7016,7 +7016,8 @@ static void selinux_bpf_prog_free(struct bpf_prog_aux *aux) static int selinux_lockdown(enum lockdown_reason what) { struct common_audit_data ad; - u32 sid = current_sid(); + /* Lockdown requests come in non-thread context, can't use 'current_sid()' */ + u32 sid = SECINITSID_UNLABELED; int invalid_reason = (what <= LOCKDOWN_NONE) || (what == LOCKDOWN_INTEGRITY_MAX) || (what >= LOCKDOWN_CONFIDENTIALITY_MAX); and stop accessing random security ID's from random contexts. And stop thinking it's ok for SELinux to just do bad things. Linus