From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 4F2973858D37 for ; Thu, 30 Nov 2023 11:51:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F2973858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4F2973858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1029 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701345115; cv=none; b=o4YVLeCjfh0vbNF1JtTWsl2mEwaieybi++tfNp9A1z1xuKht5jeOc4njrD5qHSSqcVvvqj/Fhy/1WSxynn2zm+02dfbksAtAS8n226kvbS08VATPmGMmLa4spzaLUbwdfH15HdQfQzcqEZDSxYU1OimXrIH2QdO0yqrwc+r0GCo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701345115; c=relaxed/simple; bh=xWBKLgFVwd9R7K020D7U/yy0bJVWpXAIl0s8OZh3hAM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=DvgDGqKDA6peds92JpubVTjp7M8eNf4TCbVODJo/R/44/Ot3teryVcu3SD0OTipnDHmiMM1ZhEg+V83hpitKXBqMlk3ioHckSjGr+0vXhmJNVJG/rbUD4MFJXjZe02S33uyxXh2336Eqxfpmq2uJV+h7kaC/HyNwI2zAYEH3FN0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2859c011cb0so857161a91.1 for ; Thu, 30 Nov 2023 03:51:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701345113; x=1701949913; darn=sourceware.org; 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=3X+vtPASUuPYxkR4d3+AQaAqlzWkNipCMdTmneNbOdE=; b=mql3ezknVfq8UOvkL8tbdUGFcYm5Q4tD70DnDul5CSGSrjZWu+2a0iBWNhLNUWK0Nj zVmzdMyDFT/AWOegTBSzipWeCP/Stzt/WPM98xagdtBkRp7lo1SplC+PZSc8ZZQNy6in I3zYoyTEnHnqCd2f3puqhc/JJsVl5NhaX+S/LcskME+E7PNJWIIJGeFG0j3OJl2RoenX qI35pvd/SFR3wHEj6CKudRt/DUKa/EKtS1mdECQ0qx74r/avm/j//q01FSCdL+S4mHPo acRbljo+QrdMJAd7vEHKcdyztXB8sqCZH3lNQouGLvJHtVSmcrEMNzCe6TmR1Pzm34+g XhAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701345113; x=1701949913; 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=3X+vtPASUuPYxkR4d3+AQaAqlzWkNipCMdTmneNbOdE=; b=iQy7MxZBlrAI+Y7d03anOmB9zjk2pQ99l+YiIj0NDdjj7+Klujmd7hsjUN3fTegJjB lrnM0iXd2x++oJBqI/LK14o2MjisDox+advQ/Zx1NXtdua9QJODUfqmVpfHDj2CW+CjG Kjq5F7L1svlVjTKSrHA0f5UOYsKI2RfzTPLVG2MTw/ayEeuwztBZpQ6OsDlvetGTItTP ExyjfZq1pg710JQbxx6+0S+DZVG/Hk1Qo6SjLvjPnuDXt9JiAiZSgtE/JEjDIMEW2E3N W2WilJjIw1xoxXAupgjDvI2euTb9Livce2yUzJIX3MxbX8hGgSNvWUhnMGlteUhC9dlv M5rg== X-Gm-Message-State: AOJu0YzNfTpBtRuLE5jIS8dDlMTAELFq20xDLF0yYxNwA6FvacCHp3ur M5Wq1s3KiO14wtoRHBXuQ19mm431hq4qJxmoAU4SNw== X-Google-Smtp-Source: AGHT+IE2DF0/TlR1Xq5Kb3g7BNnfZT7b/6yXvzt7kqJJHSzg6QxnFHVNqaNE79WcTO700SoiZPxZPg== X-Received: by 2002:a17:90b:1c8c:b0:280:c98f:2092 with SMTP id oo12-20020a17090b1c8c00b00280c98f2092mr21539744pjb.33.1701345112895; Thu, 30 Nov 2023 03:51:52 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c2:bcdb:cd60:ab60:c05:7aa0? ([2804:1b3:a7c2:bcdb:cd60:ab60:c05:7aa0]) by smtp.gmail.com with ESMTPSA id 12-20020a17090a034c00b0028571e2a759sm3301570pjf.48.2023.11.30.03.51.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Nov 2023 03:51:52 -0800 (PST) Message-ID: <34dac04c-4bc6-46cd-96d7-4e1ebe4d1f18@linaro.org> Date: Thu, 30 Nov 2023 08:51:49 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] linux: Make fdopendir fail with O_PATH (BZ 30373) Content-Language: en-US To: Florian Weimer , Adhemerval Zanella via Libc-alpha Cc: Paul Eggert References: <20230901122651.59253-1-adhemerval.zanella@linaro.org> <875y1jwopw.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <875y1jwopw.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 30/11/23 06:54, Florian Weimer wrote: > * Adhemerval Zanella via Libc-alpha: > >> diff --git a/sysdeps/unix/sysv/linux/fdopendir.c b/sysdeps/unix/sysv/linux/fdopendir.c >> index 861345396c..707fb5960e 100644 >> --- a/sysdeps/unix/sysv/linux/fdopendir.c >> +++ b/sysdeps/unix/sysv/linux/fdopendir.c >> @@ -37,10 +37,16 @@ __fdopendir (int fd) >> return NULL; >> } >> >> - /* Make sure the descriptor allows for reading. */ >> int flags = __fcntl64_nocancel (fd, F_GETFL); >> if (__glibc_unlikely (flags == -1)) >> return NULL; >> + /* Fail early for descriptors opened with O_PATH. */ >> + if (__glibc_unlikely (flags & O_PATH)) >> + { >> + __set_errno (EBADF); >> + return NULL; >> + } > > Should we fail with EINVAL instead of EBADF? POSIX states it should be EBADF indeed, as Paul has noted [1]. The EINVAL returns is a different issue. > > Maybe add a comment that EBADF matches what readdir will fail with? > > Otherwise: > > Reviewed-by: Florian Weimer Thanks. > > Thanks, > Florian > [1] https://sourceware.org/pipermail/libc-alpha/2023-September/151302.html