Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp686406rdb; Fri, 6 Oct 2023 16:08:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9kqKZG6KWSHYukf7bdKGVGF3btyIZX2g4UgzQbZL3Lp82NyQmgChLKUyq8ynwR51EUQxL X-Received: by 2002:a05:6870:ea95:b0:1dd:58a1:2879 with SMTP id s21-20020a056870ea9500b001dd58a12879mr10743622oap.35.1696633716887; Fri, 06 Oct 2023 16:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696633716; cv=none; d=google.com; s=arc-20160816; b=kpHDgCz1uDcChBeqH3ehOm3hzf/9s7SPZjYqD+Tx1Y0yO4rThBNVG831B1cmDmQg57 L3HDWok4k8+wgtG6DcB4Y72QOh5QACyYtJktLKcYu+Jm8y5RMBWd5LdiclhK9BTx2QUo vX2sdWYYq8M8EvpQvUWD23yYYp6sWPO22jclnh8XppdCXY24T5SxjR737Ge9EgDDUSss eieLEDlRJkEoLnDs2eGHVpwcDlhbCeg+Io6dl06FiAnjt0lbuYXBr80Frk0859qaWJeE +pkT5QR823U/pNSj9x7i4NIDx3rLhoBenbA7/A0MXMLRRQiwPvlteAdax/9WEopWtLoF vN0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=F50fu8DXl9ERFHVYVt4zY9h1hnn4ptAJ3MO5xm3ht8M=; fh=Xi9w8l90YS/w4QGgBHyaF5kgDGcS5gqBT/p/If4oXB8=; b=o2vcvPyZp0Nix9WvW6/GAf65aBDgcb8KZ7qmsZbP/ECue+JKw7N/1Cuei3CEl6SCkX 56bpzQjDNBXb0gd34Bc5UtbWpesisxdSLIsgw1E2pNBmzqVlfNdotSu+w/+igvlDquY3 Gt8zE2jgovnHFY7LtZh/sqmwxdlpWVJJ+se+qldgJt6qcesWf5JJq6wrm8hj2s8sucW2 ETsdhZmvBOGr6tfDj2zVcFehpbIkBMynFf9asTz4LLX2nUgtAh8b7UDBHZrop43BLsAG N5eCEdajxLvdkehntnePKB9/lcd/Hqb1611NsgpvQ9ORw4Q+wJafNzzetNqPBb13U6qQ yX1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=DSWU7Th6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id j184-20020a638bc1000000b00578f7063ae7si4942119pge.682.2023.10.06.16.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 16:08:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=DSWU7Th6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 469CD84AFCA0; Fri, 6 Oct 2023 16:08:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233627AbjJFXIH (ORCPT + 99 others); Fri, 6 Oct 2023 19:08:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233737AbjJFXIG (ORCPT ); Fri, 6 Oct 2023 19:08:06 -0400 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF4059F for ; Fri, 6 Oct 2023 16:08:04 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-59b5484fbe6so32093627b3.1 for ; Fri, 06 Oct 2023 16:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1696633684; x=1697238484; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=F50fu8DXl9ERFHVYVt4zY9h1hnn4ptAJ3MO5xm3ht8M=; b=DSWU7Th6ZPr/C9XYfy2ArD7EwQYRdfx5NerMmWa6VeiCNw24YRrs4c7/Vfca2xgG4O aiv44TiryMe03QX0qA4WsJTNRtLHaZmTv5GAFT+E90Slc9yUpNis1hUvIqujMk9dy+Lu whWgQoQmCxAp1reO223+nIWNoses+CDen4cXjYYHWeYzLJ0XgXhVLoiKgmVihZ7t0VBF KVUvLeTTU1rCg0CZsgE8hY/Wnvf7cl6RkUSwfcA/M9AgkF8uRT5sXVjkWFUGMQ7x9ArI g9ogSHC6U/qeV7Vb1LKQIgnT0KsuxnywtMV2ZAYQh0Qi2tCddZbyOa0V2URk+/YnNPYn rhyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696633684; x=1697238484; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F50fu8DXl9ERFHVYVt4zY9h1hnn4ptAJ3MO5xm3ht8M=; b=Ni08rYbpyXK0yPiZQ8DO4Rv/WZwFtjrKZLulfN4BlFGXdP/TFInnOoxmxo7FD4/w1t MmSNB6QQpoXfnwqXrecsd2MzX/0XFEF+2XYm4T3OKiNVqQPEMjEmC4AdxmkzzIG96TF4 SMAvYkk/mA7j80UPqwhIsnnSvRS7+PHcMzjaahpSAhjOCdMj8SeFJh91Ct0QLMeZAQp3 erQZQZBMm6/BTBua11kltxyFBY0SgNICJOMy9ddExGo+8siAvSpO7wFODi6XoBwr6dQx 9EWy6brtzwrzCohtMaKTZN9TQZSGvEo8Th7MQi1Nm8czBDZo9sMUApCJuAKDtxZHZuXH ZQww== X-Gm-Message-State: AOJu0YwkeEWLGuotXDlVFYhL4N7In7J5m11hAtjc/Qfii8dXcPN94Com Q2JSw/VoQR7mNAspyYYZcll9naVmqnSQB5mFXEumP+NyDCXkAlc= X-Received: by 2002:a25:b31a:0:b0:d4b:ab7b:17ed with SMTP id l26-20020a25b31a000000b00d4bab7b17edmr8590362ybj.4.1696633683762; Fri, 06 Oct 2023 16:08:03 -0700 (PDT) MIME-Version: 1.0 References: <20230928130147.564503-1-mszeredi@redhat.com> <20230928130147.564503-5-mszeredi@redhat.com> In-Reply-To: From: Paul Moore Date: Fri, 6 Oct 2023 19:07:52 -0400 Message-ID: Subject: Re: [PATCH v3 4/4] add listmount(2) syscall To: Miklos Szeredi Cc: Ian Kent , Miklos Szeredi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-man@vger.kernel.org, linux-security-module@vger.kernel.org, Karel Zak , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , Matthew House , Florian Weimer , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 06 Oct 2023 16:08:34 -0700 (PDT) X-Spam-Level: ** On Fri, Oct 6, 2023 at 4:53=E2=80=AFAM Miklos Szeredi w= rote: > On Fri, 6 Oct 2023 at 04:56, Paul Moore wrote: > > > > Also I cannot see the point in hiding some mount ID's from the list. > > > It seems to me that the list is just an array of numbers that in > > > itself doesn't carry any information. > > > > I think it really comes down to the significance of the mount ID, and > > I can't say I know enough of the details here to be entirely > > comfortable taking a hard stance on this. Can you help me understand > > the mount ID concept a bit better? > > Mount ID is a descriptor that allows referring to a specific struct > mount from userspace. > > The old 32 bit mount id is allocated with IDA from a global pool. > Because it's non-referencing it doesn't allow uniquely identifying a > mount. That was a design mistake that I made back in 2008, thinking > that the same sort of dense descriptor space as used for file > descriptors would work. Originally it was used to identify the mount > and the parent mount in /proc/PID/mountinfo. Later it was also added > to the following interfaces: > > - name_to_handle_at(2) returns 32 bit value > - /proc/PID/FD/fdinfo > - statx(2) returns 64 bit value > > It was never used on the kernel interfaces as an input argument. Thanks for the background. > statmount(2) and listmount(2) require the mount to be identified by > userspace, so having a unique ID is important. So the "[1/4] add > unique mount ID" adds a new 64 bit ID (still global) that is allocated > sequentially and only reused after reboot. It is used as an input to > these syscalls. It is returned by statx(2) if requested by > STATX_MNT_ID_UNIQUE and as an array of ID's by listmount(2). > > I can see mild security problems with the global allocation, since a > task can observe mounts being done in other namespaces. This doesn't > sound too serious, and the old ID has similar issues. But I think > making the new ID be local to the mount namespace is also feasible. The LSM hook API is designed to operate independently from any of the kernel namespaces; while some LSMs may choose to be aware of namespaces and adjust their controls accordingly, there is no requirement that they do so. For that reason, I'm not too bothered either way if the mount ID is global or tied to a namespace. > > While I'm reasonably confident that we want a security_sb_statfs() > > control point in statmount(), it may turn out that we don't want/need > > a call in the listmount() case. Perhaps your original patch was > > correct in the sense that we only want a single security_sb_statfs() > > call for the root (implying that the child mount IDs are attributes of > > the root/parent mount)? Maybe it's something else entirely? > > Mounts are arranged in a tree (I think it obvious how) and > listmount(2) just lists the IDs of the immediate children of a mount. > > I don't see ID being an attribute of a mount, it's a descriptor. In this case I think the approach you took originally in this thread is likely what we want, call security_sb_statfs() against the root mount in listmount(). Just please move it after the capability checks. If you look at the two LSMs which implement the security_sb_statfs(), Smack and SELinux, you see that Smack treats this as a read operation between the current process and the specified mount and SELinux treats this as a filesystem:getattr operations between the current process and the specified mount. In both cases I can see that being the right approach for reading a list of child mounts off of a root mount. Does that sound good? I'm guessing that's okay since that was how you wrote it in your original patch, but there has been a lot of discussion since then :) --=20 paul-moore.com