Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3841560rdb; Thu, 14 Sep 2023 04:35:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwfo7T6kUrZxS1nmj52f0N0/scB82Zrc56fuqd2pk75NMdoPsqZU+jl/OE7wzOigWmWodX X-Received: by 2002:a05:6e02:1542:b0:34f:7779:df7f with SMTP id j2-20020a056e02154200b0034f7779df7fmr6374387ilu.0.1694691301656; Thu, 14 Sep 2023 04:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694691301; cv=none; d=google.com; s=arc-20160816; b=SJS8sl/oKKUhcWffMDzl9/ix0ZbajniaBTApNiyP6lk6DjoyFrDfKYPH74rtWgLDui kmekpU1TsiRLPNAxrQkL8aPm1tY2pjuHcRQ5vIFWPtZQsDIVLYrIRUaEvQm7cgwXa1lk P2R+z+etKkobJGAHIDC8hV7UFxLY8y/2yRktUmoajmdhtX/ibFDU2mtemaFDd91kR11e UVRq4I5vjowcbGScAeq7NPM1i5XsOZRHa0HIy9jfXfID4ekTW2qHCiTMXsL+B/VsG8fM +IHpVB/NFPXXkjCbMBFAPnOtXPqqy3kEVr+jPspzzLUErrDm+TIcaAvi21ZcHqhRKT4s OQgQ== 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=AGNKandpT5NJQi5/AVhbxV6HoTTqbRKSZ06ZbK3/luU=; fh=8tT678c9lVji7TzuBjFkIffME8SFJsDjEwwQ3yj1UwY=; b=QQTU/ddb6PZsUX7iTG2qMsr+vaBm5goV8MaxxmPV+U4Cpz6vvKtCLvdwCrkQWSkPNC DftDHGNzSxkGVXTBMdYNOWyS8qF56ncwTFjj7jyQUZLaO19s58URD7bG8LXd3xnkxAQc mjJXGXJRk4ATT4TKqzWx/3Sht8u4Z9HrkdASg3YQHoiz3XzAHXwjIlyy6tG1PkSE1gI2 XtRJl/qdEBqVo7HbtnmY0J6p+ygo4IcdwvNq9nppiF1oUmCYSPDbYeP8tRbe4YK3iDul 5HAzG04eHehEMNFKVjDItzHjQ8LMx8F1QB6uSqwY/FGsuPc309oOcZZ3aeBnvdGZt4LG dpEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@szeredi.hu header.s=google header.b=EuckalfX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=szeredi.hu Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id z185-20020a6333c2000000b00577dd005706si1209763pgz.779.2023.09.14.04.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 04:35:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@szeredi.hu header.s=google header.b=EuckalfX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=szeredi.hu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 04C4F805F2EF; Thu, 14 Sep 2023 02:31:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237065AbjINJa6 (ORCPT + 99 others); Thu, 14 Sep 2023 05:30:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236830AbjINJaw (ORCPT ); Thu, 14 Sep 2023 05:30:52 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DF7B1BF2 for ; Thu, 14 Sep 2023 02:30:48 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-99bdeae1d0aso96137466b.1 for ; Thu, 14 Sep 2023 02:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; t=1694683847; x=1695288647; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=AGNKandpT5NJQi5/AVhbxV6HoTTqbRKSZ06ZbK3/luU=; b=EuckalfXH1JT3XTkUzTWkewdpQFiWl9xm/X1oFwXOucRbqaQYrGTv5pRzINx2+JbVB GN/RhmMwwvCunOdM4h/yE/8V3FHdy/1e405EOc4Uy9+7IgnDHytdaEbkjOK6ixXStyyg grBK+M9EhO4xMbIgTqOJbnPleXeJou4ay6rYc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694683847; x=1695288647; h=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=AGNKandpT5NJQi5/AVhbxV6HoTTqbRKSZ06ZbK3/luU=; b=SWW0Myd7FIy7ODC7VWLk/qLNBbf6Zlv+rJDDihvBxzVfdI+ZszVv6trhrSSA6uJoPX TrUMgE7AC/KBnUD9iIxHYXP0/RlOgXr7RDWeLzDecHN3a1sK8sT3MjGCc/A1ocwv7zb+ bN9SWBKi0IlZZNipQNQvXZoVGaa/+istgBcbsNgjqBdicXoCv0qWrKM//0TR4LmmD0WO cJLnlfK+EFfsedZldXziVnREPRTZQRe3EeUOtKnsIbph9oScJy4bU2pgIB/+j68eUcLa ERR9Jp9jYxrXFeTIreptTFNxNbyfXLwnEow0b21Dq/UM2UqJd4jCNqNMrbEugMhmnTOM jeQQ== X-Gm-Message-State: AOJu0YzBNnj3M88/i6SebnMUfy6/bZ5BJ5sxGdkqtVdvF5VVCXh5904N uhBhG6R+OofqO8VtObHxuPv5AOnqTcjPTWHPoZFC4w== X-Received: by 2002:a17:907:1c8e:b0:9a1:edb0:2a7f with SMTP id nb14-20020a1709071c8e00b009a1edb02a7fmr5062869ejc.6.1694683846431; Thu, 14 Sep 2023 02:30:46 -0700 (PDT) MIME-Version: 1.0 References: <20230913152238.905247-1-mszeredi@redhat.com> <20230913152238.905247-2-mszeredi@redhat.com> <20230914-himmel-imposant-546bd73250a8@brauner> In-Reply-To: <20230914-himmel-imposant-546bd73250a8@brauner> From: Miklos Szeredi Date: Thu, 14 Sep 2023 11:30:34 +0200 Message-ID: Subject: Re: [RFC PATCH 1/3] add unique mount ID To: Christian Brauner Cc: 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 , Ian Kent , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein Content-Type: text/plain; charset="UTF-8" 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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:31:05 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 morse.vger.email On Thu, 14 Sept 2023 at 11:04, Christian Brauner wrote: > > 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. Yes, one concern is that humans confuse the old and the new ID. I also think it makes sense to allow the new interfaces to look up the mount based on either the old or the new ID. But I could be wrong there, since that might encourage bad code. Maybe the new interface should only use take the new ID, which means no mixed use of /proc/$$/mountinfo and statmnt/listmnt. > > 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. This is wasting a quarter of a billionth of the ID space. We are surely not concerned about that. Thanks, Miklos