Received: by 2002:ac8:71d8:0:b0:40f:fb00:664b with SMTP id i24csp199521qtp; Fri, 4 Aug 2023 08:24:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUuuD3QyDi2Z1ByFkAyGXGCL2UilFvFp9LCELJr7YBI81zhzo8Ua9e0ELMTdaPoex7T68U X-Received: by 2002:a05:6808:1495:b0:3a7:83f6:9d19 with SMTP id e21-20020a056808149500b003a783f69d19mr686900oiw.51.1691162673835; Fri, 04 Aug 2023 08:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691162673; cv=none; d=google.com; s=arc-20160816; b=xeE/UMtfPfJWMBWbP5tmNSenxN4ywxNNnwezL9Y66wl8xt0oHBzE03/F+dx7Hf1aZ+ E8+QAvBzpGitEvyAgrpUXE84GkF//IprWwlVe4CmaN+f1Vkv+FgKNSPe2eeamihhtSXl ou0COuZuoVZCXwrAVNR8ifF1GqwPrA6q9HWip0i5/dCn8sEJ5Al5uYz4lb+NQ4lO6KlG jG031RMSLtrq3NmTvPOMbDa0gDPtvqkw67F8QKSvAr6BfjDUd4m/F/jtqr2WtTNN3gDh blpgq6d321ytv3rwsPxjVKtQeg9HIIhDukEuWwsufkUB5MATUJyz2TzCO24JpiR9C451 vB1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=obUjDUYXYeTUDK2opFgvx08zifi9IeBL/RTGGVT6YBY=; fh=5uFZxSwCnASVdYxTU8tHsNdxuXn6/rzobCC/EhWaWp4=; b=IdIPi0Bq/vVHpT+wWHdo3snar5grgxsKrSgfcgnH/gJnG/IqgwbYB0H6322Ji4W/zi U3VXXBKPIYe9XavH/OPS1envrOVnn9XhNKFtEztxgrmOe5v5nzQ7bU8A9zjVHwI/ozSq /DL1ghYqcR8DyEFCjkwRYg8iwJ8ebbuZ+w0KS+LLkhPrwa7tMrjadbnAwV6EV9MBxPeD m+puUGv6h8ViMFySfAN/UU7xGYUAylRCbEW4cyuZCVUUrmDiAAIvWdvxXaWGzK08reA/ I479dSJQfqS/LU2zgnHrLYzD910vRVQYt0+DejpcJG2DDknQre4U0w3XYnHYzg3lwPIX DF4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZIbsa4aN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d2-20020a655ac2000000b005641ddd0309si1847693pgt.599.2023.08.04.08.24.17; Fri, 04 Aug 2023 08:24:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZIbsa4aN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231811AbjHDPRM (ORCPT + 99 others); Fri, 4 Aug 2023 11:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjHDPRL (ORCPT ); Fri, 4 Aug 2023 11:17:11 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61B7449C1 for ; Fri, 4 Aug 2023 08:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691162184; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=obUjDUYXYeTUDK2opFgvx08zifi9IeBL/RTGGVT6YBY=; b=ZIbsa4aNtshYxMAsSlTlNSEdBZUtoJGZQvCWy5Ild8o/yqGeX2YZ0FhsPiGfz4ApeNPORj rXSeLz5LvU0dIKMIcCiIXD7QBVuyObCCetr9FY7UvGZ/wdlxkdh0/hWys6CrZ/ZFd9SStm 9cGgLX9tXZ9ori+gNhrUWUHlfIKeW3E= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-93-1FSrIDZ_MvOnd_-k6mrKOQ-1; Fri, 04 Aug 2023 11:16:22 -0400 X-MC-Unique: 1FSrIDZ_MvOnd_-k6mrKOQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6DEDE856F67; Fri, 4 Aug 2023 15:16:21 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBD192166B25; Fri, 4 Aug 2023 15:16:18 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <20230802-master-v6-1-45d48299168b@kernel.org> To: Paul Moore Cc: dhowells@redhat.com, Jeff Layton , Alexander Viro , Christian Brauner , Trond Myklebust , Anna Schumaker , James Morris , "Serge E. Hallyn" , Stephen Smalley , Eric Paris , Casey Schaufler , Scott Mayhew , Stephen Smalley , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Subject: Re: [PATCH v6] vfs, security: Fix automount superblock LSM init problem, preventing NFS sb sharing MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2678221.1691162178.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Aug 2023 16:16:18 +0100 Message-ID: <2678222.1691162178@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Paul Moore wrote: > = > I generally dislike core kernel code which makes LSM calls conditional > on some kernel state maintained outside the LSM. Sometimes it has to > be done as there is no other good options, but I would like us to try > and avoid it if possible. The commit description mentioned that this > was put here to avoid a SELinux complaint, can you provide an example > of the complain? Does it complain about a double/invalid mount, e.g. > "SELinux: mount invalid. Same superblock, different security ..."? > = > I'd like to understand why the sb_set_mnt_opts() call fails when it > comes after the fs_context_init() call. I'm particulary curious to > know if the failure is due to conflicting SELinux state in the > fs_context, or if it is simply an issue of sb_set_mnt_opts() not > properly handling existing values. Perhaps I'm being overly naive, > but I'm hopeful that we can address both of these within the SELinux > code itself. > = > In a worst case situation, we could always implement a flag *inside* > the SELinux code, similar to what has been done with 'lsm_set' here. IIRC, the issue is when you make a mount with an explicit context=3D setti= ng and make another mount from some way down the export tree that doesn't have an explicit setting, e.g.: mount carina:/ /mnt -o context=3Dsystem_u:object_r:root_t:s0 mount carina:/nfs/scratch /mnt2 and then cause an automount to walk from one to the other: stat /mnt/nfs/scratch/foo For reference, my server has: /nfs/scratch 192.168.6.0/255.255.255.0,90.155.74.16/255.255.255.248 /nfs 192.168.6.0/255.255.255.0,90.155.74.16/255.255.255.248 / 192.168.6.0/255.255.255.0,90.155.74.16/255.255.255.248 and if I look in /proc/fs/nfsfs/volumes, I can see the individual superblo= cks: NV SERVER PORT DEV FSID FSC v4 c0a80601 801 0:51 0:0 no = v4 c0a80601 801 0:56 3:0 no = v4 c0a80601 801 0:52 1:0 no = v4 c0a80601 801 0:55 3:0 no = As you can see, there are two referring to the same 'volume'. Without the "fc->lsm_set=3Dtrue" bit, you get an error something like: SELinux: mount invalid. Same superblock, different security settings for= (dev 0:56, type nfs4) One important question is how should sharing of a mount with unspecified context be handled when we try to unify it with a mount that has an explic= it context? David