From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by sourceware.org (Postfix) with ESMTPS id 0B6B93858D33 for ; Wed, 1 Mar 2023 16:34:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B6B93858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-176261d7f45so2267047fac.11 for ; Wed, 01 Mar 2023 08:34:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677688444; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=gOv1vKfb7K67rCwkmhbibTlMWPwTN1gPGLj7hTXDQ0o=; b=rZfswVoPUvhchsGUaCuvlE5UuTU0FQkfzBfaJmdhVH1ANBvP+oWnjXLh5lrXvYbhSt IGXpiSPEtPU/IkRSNhR6gC+WWW/INkCiycfclynKUkv7N8XZaGhDTHaD7mHRQFmuPiJ5 Nzc5lYDmLkdvq19sP+8J6FktWYCId6PQplGvHcf1fTPHIaEx6wQKyLRdncirXnGcyN0T xuzP19hRwsdus2xPVek8pd0WsPOVo3GGhTpV8zENCHYAAgIitiwXQCZoTBCCrwSgyHwh LEIjHDNvoKAeIjDJE7GpTCbWMAiuI2aE5Tdt7cRiC2aS+thG/tUlT0qCZ7H0PHpchRa5 mB8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677688444; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gOv1vKfb7K67rCwkmhbibTlMWPwTN1gPGLj7hTXDQ0o=; b=cbP0aDWi7LNZw9BIDLpCcELvyZCfzTHn9Kh/ZFUdUEl5cHsoc61RcQcm0WdWoRgqh9 lJ9rmuC6lr3w7GCi9pcoMi+dqa2Gd+GdvDhER20eU05KrXPFsmBNC1rpq4J+TPmiAAam nuXMtr1srT293ZIvsqSpgL8NQH8ySLPU4SBWMC1nUGBXUJLJ9aYuzdOBgUeZvtnZmT7O G147JfLpDhY1VDQtuTfrB8SmECoFgAXyIB7WTtWtvglVRNKB21R2cf7XZRlVbv4ihTSn eAaKaDOsMjX5eO4crd0nS2v9T+a0QLm7EPQlLTifu4yp+kbX1ukpm+ClwVA2EGLkFWn/ wIJg== X-Gm-Message-State: AO0yUKW4jccbrV+VDleFQNpTysT63a4EJinJE0hHhtU/oV+bcaRBtmBE iw4y5uPkxqYfSZ1/BoQmWHUVCUX1o1p4Ir7iyEI= X-Google-Smtp-Source: AK7set95bBz6dl+1sp2CgWAfplkDGFRpRlilHrxAR9NnQ2QPtCNqi1vb+O7LTC79JwN9Ib/lKKltbQ== X-Received: by 2002:a05:6870:3414:b0:172:472b:9e23 with SMTP id g20-20020a056870341400b00172472b9e23mr3340213oah.4.1677688444223; Wed, 01 Mar 2023 08:34:04 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c3:d849:ed82:aa7c:6d0c:c8ba? ([2804:1b3:a7c3:d849:ed82:aa7c:6d0c:c8ba]) by smtp.gmail.com with ESMTPSA id v1-20020a056870e28100b00172473f9fe0sm4504712oad.13.2023.03.01.08.34.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Mar 2023 08:34:03 -0800 (PST) Message-ID: <4ac876de-f7e8-d641-4b98-bebd4c28f1e1@linaro.org> Date: Wed, 1 Mar 2023 13:34:00 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v5 1/5] linux: Use getdents64 on non-LFS readdir Content-Language: en-US To: Florian Weimer Cc: libc-alpha@sourceware.org, "Andreas K . Huettel" , Paul Eggert References: <20230127172834.391311-1-adhemerval.zanella@linaro.org> <20230127172834.391311-2-adhemerval.zanella@linaro.org> <875ybwh3a5.fsf@oldenburg.str.redhat.com> <87v8jwdxx2.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <87v8jwdxx2.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: On 20/02/23 14:55, Florian Weimer wrote: > * 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? I added the translation buffer only to simplify the copy logic, but it should be doable to do it in place (similar to what getdents64 for mips64 does).