Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3780810rdb; Thu, 14 Sep 2023 02:19:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcmSGZLJA8EqTn5DCo17MoJxn9SZ5AOO06dSRjJvQH7HJJM0o3lQNGeAz/t+xMu8085u/Q X-Received: by 2002:a17:902:eb46:b0:1c3:2fc8:1305 with SMTP id i6-20020a170902eb4600b001c32fc81305mr4558180pli.47.1694683164505; Thu, 14 Sep 2023 02:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694683164; cv=none; d=google.com; s=arc-20160816; b=0Uq0nZAlPECTaVnMTRWktIDUjVDGvu0WFS+yjDlgNr8+fpJ5NTJ8DdUlK+j1e8wNum 3haqhXoceanAwV4ym0SAezNn0NN0QdL6ReNtuBub1k3dKo74bKcFQ6ndNiEovKSlBYge jr60AUy3nKILo4/6QVpoBKejony1FfWeTNzkGVNThHOOlS8oj7z6SN3iem/+NiRfJDCT empuI6ysY8i6i6EcX5H2h+tQJfLpM/vdbRXa9Rm0HxKJfB7MwzEp/48VKngCVTrhR1/C sJGTSFm6elCND4XUQVDyk9LIW7Ez7YlBhsu2mgbDYOqu3PMQ5/UCHX7jYDIa/88w7w9x cuyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ctv3frgI8Y6Ekkav9VECZvYtR0M74Qz2airGyCQNBJE=; fh=14v87RRXjl/VdxG3aUgRI2BfotRSCP+R/H2CRFTM2BE=; b=diSy9GKcjy7XF23g4LJBY1eV24mqOb1krhY/jiYrsDvBuJCNexn/Xf9nZdbQ7TJXYv Mb66+GrerlwU9ZRbCkeTlG2mddVgGlghAlEdH4k6MQpzMbD/gyNwLt5+U6r0LGjlzYWT dYREmunMNzARrEqO9f4cVDzg7ClC+0c+UKdVNLEOQaTpH6lTVqBwi2y9W/vzVK0MTNRy elPEfEbZtNXmZU2UUdtz3o464ZIt5OokM4zzE+IIz8b/rdnqOHGAHJTO8hlTyCSh6WMU xxsY3zhxC4DPs+oFxWJWIR1FFtFVl76E5A+qJ3/mi9s0zsVw3vuRB39WpqbP8hwYJd6K 08Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F1JpLd35; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m3-20020a1709026bc300b001b876d46162si1260073plt.38.2023.09.14.02.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 02:19:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F1JpLd35; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 59E88830D624; Thu, 14 Sep 2023 02:03:28 -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 S236811AbjINJDV (ORCPT + 99 others); Thu, 14 Sep 2023 05:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236753AbjINJDT (ORCPT ); Thu, 14 Sep 2023 05:03:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 304AC1FCC; Thu, 14 Sep 2023 02:03:11 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC4E9C433C7; Thu, 14 Sep 2023 09:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694682190; bh=N3L2pkXgh4YQ+q9kocn04dm6+vzax3CnSl5k5mqxMJc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F1JpLd35kG+k5w2HwrVTXcTYX+6Ji/1OxwtWdQonj2MmciwX9HejiNUqcgcdBlqVc 7g/ld06TBJyz1O+7tDuQFAIqIbU2cHcENfi5QvVFd8BkJdSEKG5CYBYh6OLSAA3h6b woewGTeJ2wdl9ZKnPxb/3RIv9Z71x29qG+gVKhNJwgX6p0o+8PpMtQMh1YP/+5Ps4q xdnxukjG1qxW4WxEm9wiuugAbODwIrOF9gnV908DeR7K4rdQhbr6R8M9o2p8uzotvF EAHpim4dHU5Up9AAzkLMsMppquUALKM7aa/sLZGaUuBdNzJ7jQdL1+vK4jtDkQQIv8 4OtoWrDiP/OCw== Date: Thu, 14 Sep 2023 11:03:05 +0200 From: Christian Brauner To: Miklos Szeredi Cc: 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 , Ian Kent , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein Subject: Re: [RFC PATCH 1/3] add unique mount ID Message-ID: <20230914-himmel-imposant-546bd73250a8@brauner> References: <20230913152238.905247-1-mszeredi@redhat.com> <20230913152238.905247-2-mszeredi@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230913152238.905247-2-mszeredi@redhat.com> 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]); Thu, 14 Sep 2023 02:03:28 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email On Wed, Sep 13, 2023 at 05:22:34PM +0200, Miklos Szeredi wrote: > If a mount is released then it's mnt_id can immediately be reused. This is > bad news for user interfaces that want to uniquely identify a mount. > > Implementing a unique mount ID is trivial (use a 64bit counter). > Unfortunately userspace assumes 32bit size and would overflow after the > counter reaches 2^32. > > Introduce a new 64bit ID alongside the old one. Allow new interfaces to > work on both the old and new IDs by starting the counter from 2^32. > > Signed-off-by: Miklos Szeredi > --- > fs/mount.h | 3 ++- > fs/namespace.c | 4 ++++ > fs/stat.c | 9 +++++++-- > include/uapi/linux/stat.h | 1 + > 4 files changed, 14 insertions(+), 3 deletions(-) > > diff --git a/fs/mount.h b/fs/mount.h > index 130c07c2f8d2..a14f762b3f29 100644 > --- a/fs/mount.h > +++ b/fs/mount.h > @@ -72,7 +72,8 @@ struct mount { > struct fsnotify_mark_connector __rcu *mnt_fsnotify_marks; > __u32 mnt_fsnotify_mask; > #endif > - int mnt_id; /* mount identifier */ > + int mnt_id; /* mount identifier, reused */ > + u64 mnt_id_unique; /* mount ID unique until reboot */ > int mnt_group_id; /* peer group identifier */ > int mnt_expiry_mark; /* true if marked for expiry */ > struct hlist_head mnt_pins; > diff --git a/fs/namespace.c b/fs/namespace.c > index e157efc54023..de47c5f66e17 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c > @@ -68,6 +68,9 @@ static u64 event; > static DEFINE_IDA(mnt_id_ida); > static DEFINE_IDA(mnt_group_ida); > > +/* Don't allow confusion with mount ID allocated wit IDA */ > +static atomic64_t mnt_id_ctr = ATOMIC64_INIT(1ULL << 32); Hm, is your concern that userspace confuses these two values? If so, I think we shouldn't worry about this. If a userspace program retrieves a mntid and then confuses itself about what mnt id they're talking about something's very wrong anyway. So I'd rather not see us waste 32 bits just for that. Other than that this seems to implement what we agreed on at LSFMM so my hope is that this is fairly uncontroversial.