From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 42FF03858D38 for ; Mon, 20 Feb 2023 17:55:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 42FF03858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676915727; 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=sXPCjhcwHaJPT+hpQpdUM3J0kFBZykIf1wK3uXa2rQA=; b=TALq9r8fnGcMBKczZMRvMEwX3250+QdT1iCb2uNOtl4q0kA47/XLLHyu1gSpyjye+X3Uhr CpAMjoLU5bRbqp+GcD8Exrk7KtwTEdiyuZ29vmPHnE8AExKd8VmXyWHyDN6hGxQEUvhgNk SuVOKZjaP3rUjfx8C2mLxIDFv3bYvBs= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-fyoSeHe6O5mS8hDWQayrrA-1; Mon, 20 Feb 2023 12:55:24 -0500 X-MC-Unique: fyoSeHe6O5mS8hDWQayrrA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 74EC73806720; Mon, 20 Feb 2023 17:55:24 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 27B9F2026D4B; Mon, 20 Feb 2023 17:55:22 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: libc-alpha@sourceware.org, "Andreas K . Huettel" , Paul Eggert Subject: Re: [PATCH v5 1/5] linux: Use getdents64 on non-LFS readdir References: <20230127172834.391311-1-adhemerval.zanella@linaro.org> <20230127172834.391311-2-adhemerval.zanella@linaro.org> <875ybwh3a5.fsf@oldenburg.str.redhat.com> Date: Mon, 20 Feb 2023 18:55:21 +0100 In-Reply-To: <875ybwh3a5.fsf@oldenburg.str.redhat.com> (Florian Weimer's message of "Mon, 20 Feb 2023 14:31:14 +0100") Message-ID: <87v8jwdxx2.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Florian Weimer: >> diff --git a/sysdeps/unix/sysv/linux/readdir.c b/sysdeps/unix/sysv/linux/readdir.c >> index 4a4c00ea07..cd0ccaf33a 100644 >> --- a/sysdeps/unix/sysv/linux/readdir.c >> +++ b/sysdeps/unix/sysv/linux/readdir.c >> @@ -21,42 +21,71 @@ >> #if !_DIRENT_MATCHES_DIRENT64 >> #include >> >> +/* Translate the DP64 entry to the non-LFS one in the translation entry >> + at dirstream DS. Return true is the translation was possible or >> + false if either an internal field can not be represented in the non-LFS >> + entry or if the name is too long. */ >> +static bool >> +dirstream_entry (struct __dirstream *ds, const struct dirent64 *dp64) >> +{ >> + /* Check for overflow. */ >> + if (!in_off_t_range (dp64->d_off) || !in_ino_t_range (dp64->d_ino)) >> + return false; >> + >> + /* And if name is too large. */ >> + if (dp64->d_reclen - offsetof (struct dirent64, d_name) > NAME_MAX) >> + return false; > > Sorry, I don't think this is the direction we should be going. In > readdir_r, we at least delay the NAME_MAX error to the end of the > directory. This just adds another rare case where 32-bit code fails and > 64-bit code works. > > struct dirent is always shorter than struct dirent64, right? It should > be possible to do the translation in-place. Or turn tdp into a pointer > and reallocate as needed. > > However, I think we should fix only readdir64, not readdir. It's simply > not possible to fix readdir fully because of d_ino, so applications > which use readdir instead of readdir64 will remain buggy even with this > change. Meh, during a walk it occurred tome that 64-bit d_ino is far less common than 64-bit d_off. So we really need all this rewriting. 8-( Could you do it in-place at least? To address the d_name sizing issue? Thanks, Florian