Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1931168rdh; Tue, 26 Sep 2023 07:40:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaVZa3jU+Dwh7L2YaCBRi1PPaYPVApkuiUTHcwPdFQztAYuIXtwKYfyZaBF1ZnLm9zDuxH X-Received: by 2002:a17:90b:1916:b0:26b:c3f:1503 with SMTP id mp22-20020a17090b191600b0026b0c3f1503mr9773641pjb.17.1695739213781; Tue, 26 Sep 2023 07:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695739213; cv=none; d=google.com; s=arc-20160816; b=cp//6SMGqtSOidhsyfFLa7qjR6MzkHmh0JW0Ab+lY6fnPHIaMtvpshiwoFECSZAIC3 PSuK4+WZ0J9KrJ39syrT3CB7IuXPuJT+UV1M8g5TBF9whp8V+eykCM1gsG2k8HHr/fsL QKpl7odOhKJN1npdDeKB6dnhzVYOa8Q0mCnzkS4CqSDvAHnYiu7F+5J8wr21lV4XMycF /RabMWDyvtyPsn6zRVOJC2FJesqG663OqWcCWf3BRAwPzZquvOGzaTVLzbiuNB+C1vRj 6fFGRXqYLb/Sal83/IO84nnGxMelipsaumzuZsSpbTJAAE3Xje36MezcHY15oftWMepn AGvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=XllbBqxTvNzfuhH1RFsYE8Y8P6H7hYsJSRNMnTexg+M=; fh=GIEBknSoYkKw8qkoUJqS/tSoQT824HIc6B13M+w0+0M=; b=IiWMQMIhDlzZJcLqHd9yqdUytmA7bSgjL1LwFUSyld/GT6HChrwbqNYC6R6YDpiQ/7 zfo9qejGVRGFOAml7Sv/ag9QkR85LsEkCdJ6XMY/1AWukiDd1VYhecZqHDg7V1nxxHLM PeNBVSNowcbYnC850eIf1V8e/tkz+ycNRJICxVI6Re03d+M3+vO5zfQA6ro6KJyxZksV fnSUiAMS0Xl/tbyw8+61i8IDwhwTCrtGxgKrabQNEcKMSZxjVJLB9sVh6Lsd8Jk63jL7 sAqj++tAgNalvGaCqh7teAFwms5OyejP2AWcm5ELki/Kw+/tMbnDGzfh0pvQR8Y1jdiB +/cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GC5kb3tV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id mh5-20020a17090b4ac500b00276df8c5b83si7261158pjb.143.2023.09.26.07.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 07:40:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GC5kb3tV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 18CBC8092CA0; Tue, 26 Sep 2023 07:40:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234902AbjIZOkF (ORCPT + 99 others); Tue, 26 Sep 2023 10:40:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234911AbjIZOkB (ORCPT ); Tue, 26 Sep 2023 10:40:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 032F8121 for ; Tue, 26 Sep 2023 07:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695739151; 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: in-reply-to:in-reply-to:references:references; bh=XllbBqxTvNzfuhH1RFsYE8Y8P6H7hYsJSRNMnTexg+M=; b=GC5kb3tVC7t/WmGQ3HfCI6ZTrylsPE2nFdWqFwbunBsjUIzF+vbL/E0qXXUlWwtRBmOK46 xNpJaqWy0VVn4Kl2lyb33ZyD+zOwU67STyv51Iq2dBcvzUqy2N1uN4cb6S28HmAQynVtlu rCQsPI3LJ2XRKFEmxfCfhlC7xAjaxbs= 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-182-Fk0Y759GO-SfTiZBEIRSlA-1; Tue, 26 Sep 2023 10:39:08 -0400 X-MC-Unique: Fk0Y759GO-SfTiZBEIRSlA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0CB3F8039D2; Tue, 26 Sep 2023 14:39:07 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 268471004058; Tue, 26 Sep 2023 14:39:05 +0000 (UTC) From: Florian Weimer To: Miklos Szeredi Cc: Miklos Szeredi , Christian Brauner , Linus Torvalds , 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 , Al Viro , Christian Brauner , Amir Goldstein Subject: Re: [RFC PATCH 2/3] add statmnt(2) syscall References: <20230913152238.905247-1-mszeredi@redhat.com> <20230913152238.905247-3-mszeredi@redhat.com> <20230914-salzig-manifest-f6c3adb1b7b4@brauner> <20230914-lockmittel-verknallen-d1a18d76ba44@brauner> <20230918-grafik-zutreffen-995b321017ae@brauner> <871qeloxj0.fsf@oldenburg.str.redhat.com> <87wmwdnhj1.fsf@oldenburg.str.redhat.com> Date: Tue, 26 Sep 2023 16:39:03 +0200 In-Reply-To: (Miklos Szeredi's message of "Tue, 26 Sep 2023 16:33:50 +0200") Message-ID: <87bkdpngmw.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 26 Sep 2023 07:40:09 -0700 (PDT) * Miklos Szeredi: > On Tue, 26 Sept 2023 at 16:19, Florian Weimer wrote: > >> getdents gets away with this buffer size because applications can copy >> out all the data from struct dirent if they need long-term storage. >> They have to do that because the usual readdir interface overwrites the >> buffer, potentially at the next readdir call. This means the buffer >> size does not introduce an amount of memory fragmention that is >> dependent on the directory size. >> >> With an opaque, pointer-carrying struct, copying out the data is not >> possible in a generic fashion. Only the parts that the application >> knows about can be copied out. So I think it's desirable to have a >> fairly exact allocation. > > Okay, so let's add a 'size' field to the struct, which is set to the > size used (as opposed to the size of the buffer). That should solve > copying without wasting a single byte of memory. That would be helpful. > Otherwise the format is fully copyable, since the strings are denoted > with an offset, which doesn't change after the buffer is copied. I missed the development in that direction. Yes, offsets would work nicely in this context. They help with compat syscalls, too. If the buffer is relocatable like that, we can even try first with a reasonably sized on-stack buffer and create an exactly-sized heap allocation from that. Thanks, Florian