Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3822639rdb; Thu, 14 Sep 2023 03:59:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELYPUQNJf1zhD8NpNeAVZP3cz0wR1C/EYsZTE4CxLCaIXRIKlcyExe90KgCiyh8r+Zhgzy X-Received: by 2002:a17:903:234f:b0:1c4:16f7:d95b with SMTP id c15-20020a170903234f00b001c416f7d95bmr632448plh.63.1694689154319; Thu, 14 Sep 2023 03:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694689154; cv=none; d=google.com; s=arc-20160816; b=QfVXjtR/s2MJeddt3GtwviceZyDINLk1HP/g9d5dhhS5jR3R6JAxRTdKbEVkXaPe+x ajeV13o+tmdil97uv8AbTrSFVkYWRK7P4QqITU8pTJxayXo1s1EdZlgdzNI8w5AFBRPP qK26Ner46aZ0H6Q8iExgZcWSV+n8CYuiPJM3xyJY+novi3sL94s0AQ5rLrqemxXdgZQP NmcMBhl4D4/p5UNSyCdHtZ99a08PRSYPp+Q929LSkY2xzHiu0ibOkx1rQd7JSeAQUskW EYFk+3LWdF/yzlfa3Zik2h9MgOF/H694wtOjzyWWTNea3+vKgLRNkUkMRwDMYqJtnqDu liJQ== 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=0iGA6NXjJU78GUhhpa0teVLwBab1iCm0bTOT2pd1PVQ=; fh=qZrxku8kW49vSc7OGEKdViz37ODtq55+Oh414iJhJvE=; b=ItQUq/tJefD3gnpbE5zKrUu7I9Ywu7RENuydDWlGYLw1D3W7aPY2HWN5Ocq5YOCXuf jAMujZ9EzlfAxuQoqT6e1XCf7dH2/JEvEiOFd4niaTUm5UnYTodg6xDTM5JT/cCfj3By xqDhV6qeuQJh/evyLEQXxQiEHvT6bWlPJiM/a/HRIU+7mKnl7N3Kx/lY6nYgSQHrn1oN Zjqx942tNytd52kGe0nIF3Qpuebl/IoXToM/TmwoCCvMGgAMOSFk+C5uktHaVC8Go4yc 4o6YBeElUdIhu1lB5c49OrX+W4pwceRGP8Acxzj0e0VpK5GYQLHOlvH9TPYbkyGKeRU+ 94iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BcGVVnF+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id o5-20020a17090323c500b001b025aba9f2si1432381plh.22.2023.09.14.03.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 03:59:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BcGVVnF+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 6A44C81BB0A0; Thu, 14 Sep 2023 03:01:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237606AbjINKBa (ORCPT + 99 others); Thu, 14 Sep 2023 06:01:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237585AbjINKBO (ORCPT ); Thu, 14 Sep 2023 06:01:14 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BCA71981; Thu, 14 Sep 2023 03:01:10 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8079C433C7; Thu, 14 Sep 2023 10:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694685669; bh=fZNCOSuOnW8qgFYbmpGKc3ZPkINzwR/JRzJy6TB6DLE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BcGVVnF+zgH7WPhoYtq83iUNmXp9AEyFnCb09pOFYhrpvWu0JtS/gUl3E1msCkPiL KyZSpbTFxBFPrT6NIlMWkxrK11OvL8M2p9BttSN8RWWBeBfhs1HPqtnrUVRG7pPis3 KOHzeQXHlNEFAbYjCze7yOlkql6Vk9XxZAdGEnIcB4LwI89G97oIimVoPzzfSe3tE2 2XIol3Dam9OtYTbS56sGbq2G2GOQ1QPlvPDsX2S9YzNV8KZVezt1k5MjgtLu/RDEla 0zkxpA86JWOOSzm8DbirZS3lTtrkg9nxxrq1DU1jY6Z3L67FDCYjXtSH1RYJvz7bmT IfihVbFi71Vfw== Date: Thu, 14 Sep 2023 12:01:04 +0200 From: Christian Brauner To: Miklos Szeredi Cc: Amir Goldstein , 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 Subject: Re: [RFC PATCH 3/3] add listmnt(2) syscall Message-ID: <20230914-umtriebe-fahrwasser-7c789fc442f7@brauner> References: <20230913152238.905247-1-mszeredi@redhat.com> <20230913152238.905247-4-mszeredi@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 03:01:37 -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 lipwig.vger.email On Thu, Sep 14, 2023 at 10:50:04AM +0200, Miklos Szeredi wrote: > On Thu, 14 Sept 2023 at 08:00, Amir Goldstein wrote: > > > > + if (ctr >= bufsize) > > > + return -EOVERFLOW; > > > + if (put_user(r->mnt_id_unique, buf + ctr)) > > > + return -EFAULT; > > > + ctr++; > > > + if (ctr < 0) > > > + return -ERANGE; > > > > I think it'd be good for userspace to be able to query required > > bufsize with NULL buf, listattr style, rather than having to > > guess and re-guess on EOVERFLOW. > > The getxattr/listxattr style encourages the following code: > > size = get(NULL, 0); > buf = alloc(size); > err = get(buf, size); > if (err) > /* failure */ > > Which is wrong, since the needed buffer size could change between the two calls. Not a fan of this either tbh. > > Doing it iteratively is the only correct way, and then adding > complexity to both userspace and the kernel for *optimizing* the > iteration is not really worth it, IMO. So realistically, userspace nows that an upper bound on the number of mounts in a mount namespace (expressed in /proc/sys/fs/mount-max usually 100000 - which is often too much ofc). This is probably insane but I'll power through it: ideally we'd have an iterator interface that keeps state between calls so we can continue iterating similar to how readdir/getdents does.