Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5225146pxj; Wed, 26 May 2021 05:56:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMfxl8iP2Z735eCeHQqh7R4eRSKGggYdzJ6XEPNbJhq6OBlPSArVkGpdtU74f6EIz2K+it X-Received: by 2002:a02:9443:: with SMTP id a61mr3058768jai.60.1622033811067; Wed, 26 May 2021 05:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622033811; cv=none; d=google.com; s=arc-20160816; b=asGct4mTdMzalRLAWGcVxmRpCGpd4wLjJgOF1dimijBZnFaUBwSQpk+p/ubCwjR0U8 CJEWF8INhfSxqrvEkpyTbWKsrdgeLlQV8IqhjvDu+cu0Cdh6aUMSFjtmad8E3767235u JiiayZCXMPhcNpqo2qvA+iAWLyQncK+Wnyre1RdwbfNFDqYICkCt4Gl83Dh6Oxv6kJbr dWezyfRjrq+fmx5vxuFs3SD8g+m1CJTYc4SAQMqs5mGm5RsReJwsKyGn8AzrKam9QOO9 3+6BO6ScYP2kJdD2ZQTNXf+LZoGslqBWZ7H+FGbCuyc1eWIxLEVh9sMumXmRwpWuunkB ThvQ== 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=5Uw+/IY4PFLhc9QD0XQTD8Vq22Bv9V1A42B8cw/tcfQ=; b=KW7FJvB9wdJ+jk74GsAKQV/IyZGQjTY5WKHsTidJMARqHX92esosnWBbt2xTee5W9L MMZk6X85HgUf0EJC50hqu0Lk6suXy3dhQfjbxy7jxGfydgTAJlENdl9Mkt94RfdPcXYX cLtWJ1PVCtsXSOavX13yQzqK4VJoqueLJPmjomdG0v5OXcxTt1kgPBvkdSFXAtdjYUJt h+XBo4VclBUcIaXXw8u9nf6DiCduyUMTO0K1yfN+NpIhjxnGrli1EQhhzsVEBNXvJBt7 ISVx9oSbwv5vveKi5PmU3/b1KVyZ/1HyOd7mb0XMuFAJbsjAXC5IkfVYBHNIblbbtpLK xC+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KZW7SBXe; 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 o2si21409556jaa.70.2021.05.26.05.56.34; Wed, 26 May 2021 05:56:51 -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=KZW7SBXe; 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 S232803AbhEZLqu (ORCPT + 99 others); Wed, 26 May 2021 07:46:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33697 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232303AbhEZLqs (ORCPT ); Wed, 26 May 2021 07:46:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622029516; 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=5Uw+/IY4PFLhc9QD0XQTD8Vq22Bv9V1A42B8cw/tcfQ=; b=KZW7SBXegZu/wpZtz8zD3v+c+Tfn24w8Eh3QahoBAYv0mpHdy6NN90Pi9eTOR4ih+SkyEC Jf0bJbiqlXJ21kPasLIbijiQ9LPvSbiQI8LWQ2eukOZjfTtYzxlONsPX/yCSUf1N4nyABf PSighAa3eR5ZZsVoX0qyYHzpK1vuiOQ= Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-563-grsnJUM7Oq2zQud-VMIJxA-1; Wed, 26 May 2021 07:45:15 -0400 X-MC-Unique: grsnJUM7Oq2zQud-VMIJxA-1 Received: by mail-yb1-f200.google.com with SMTP id s8-20020a5b04480000b029049fb35700b9so1389013ybp.5 for ; Wed, 26 May 2021 04:45:15 -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=5Uw+/IY4PFLhc9QD0XQTD8Vq22Bv9V1A42B8cw/tcfQ=; b=SlydC2Yl46WTS/c5hOweg7U3dKbi20GCbsqCqiZR9bT4rwgKBUCubhre1b+465kuIP kfo1m7FI1abHjQruknjqY8I4DhO6nzuG+anGVAug/CJPrIef2VMvOAVYboWZNW1m5sNZ ReSqpLf4ndlZMty6+Z0kbd+wtA7qh7qkcPg+6EcIFCHoVvmIbXBkv5z8b/s91bgIC2tP ZwJqehxbqCcwaxBehjIy8kJBUS/Jx4y/93fIvGwupw9fg0yv47hEsvvWNQV9xe2NPMDl +x1nMjgBCgNceJzSfnH36bhwhnyvGAQCebE5m6MD/z3pu5l4zV/wGwAQ0kdf275ZBJcL Sf5Q== X-Gm-Message-State: AOAM533wzRSmrWc1/h8UQqRv3aog5/CE/9KyiSOVNA7ryE0O14OSBrfu 5sjK2UVSbqWri9kZ9y4aBOSZPuCqlGYylrhjb5xAEUZkjLzND10x0Aak1k80CwYsbWzazYPQ9/b pC8l1yx/4okP0knYUvjQmrd/PrZVMcd14MnBcKjnj X-Received: by 2002:a25:f50e:: with SMTP id a14mr48352365ybe.172.1622029514564; Wed, 26 May 2021 04:45:14 -0700 (PDT) X-Received: by 2002:a25:f50e:: with SMTP id a14mr48352333ybe.172.1622029514339; Wed, 26 May 2021 04:45:14 -0700 (PDT) MIME-Version: 1.0 References: <20210517092006.803332-1-omosnace@redhat.com> <87o8d9k4ln.fsf@mpe.ellerman.id.au> In-Reply-To: <87o8d9k4ln.fsf@mpe.ellerman.id.au> From: Ondrej Mosnacek Date: Wed, 26 May 2021 13:44:59 +0200 Message-ID: Subject: Re: [PATCH v2] lockdown,selinux: avoid bogus SELinux lockdown permission checks To: Michael Ellerman 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 , Casey Schaufler , Paul Moore Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 17, 2021 at 1:00 PM Michael Ellerman wrote: > Ondrej Mosnacek writes: > > 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 modifying the hook to accept a struct cred > > pointer as argument, where NULL will be interpreted as a request for a > > "global", task-independent lockdown decision only. Then modify SELinux > > to ignore calls with cred == NULL. > > > > Since most callers will just want to pass current_cred() as the cred > > parameter, rename the hook to security_cred_locked_down() and provide > > the original security_locked_down() function as a simple wrapper around > > the new hook. > > > > The callers migrated to the new hook, passing NULL as cred: > > 1. arch/powerpc/xmon/xmon.c > > Here the hook seems to be called from non-task context and is only > > used for redacting some sensitive values from output sent to > > userspace. > > It's hard to follow but it actually disables interactive use of xmon > entirely if lockdown is in confidentiality mode, and disables > modifications of the kernel in integrity mode. > > But that's not really that important, the patch looks fine. > > Acked-by: Michael Ellerman (powerpc) Thanks, Michael! James/Paul, is there anything blocking this patch from being merged? Especially the BPF case is causing real trouble for people and the only workaround is to broadly allow lockdown::confidentiality in the policy. -- Ondrej Mosnacek Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.