[v2,6/6] stdlib: Assume FACCESSAT_NEVER_EOVERFLOWS on realpath

Message ID 20201228135944.1018303-6-adhemerval.zanella@linaro.org
State Superseded
Headers
Series None |

Commit Message

Adhemerval Zanella Netto Dec. 28, 2020, 1:59 p.m. UTC
  The faccessat (..., AT_EACCESS) on Linux fallback will either use
__NR_faccessat for __libc_enable_secure or LFS  fstatat call.  Neither
fallbacks returns EOVERFLOW in failure case.

Checked on x86_64-linux-gnu.
---
 stdlib/canonicalize.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
  

Comments

Paul Eggert Dec. 28, 2020, 9:14 p.m. UTC | #1
On 12/28/20 5:59 AM, Adhemerval Zanella wrote:
> The faccessat (..., AT_EACCESS) on Linux fallback will either use
> __NR_faccessat for __libc_enable_secure or LFS  fstatat call.  Neither
> fallbacks returns EOVERFLOW in failure case.
Argh, I had misread the glibc source code in this area. So I installed 
this further Gnulib patch:

https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=d82dfeb8a7c9b276c8c7db94d077eb7a43a6760c

which should result in even simpler code than the v2 6/6 patch.

So, to summarize this series of 6 patches to glibc:

* Patches 1, 2, and 3 are fine.

* Patch 4 (stdlib: Sync canonicalize with gnulib) can now sync with 
today's Gnulib instead.

* Patch 5 and 6 are no longer needed, since today's Gnulib subsumes them.
  
Adhemerval Zanella Netto Dec. 28, 2020, 9:50 p.m. UTC | #2
On 28/12/2020 18:14, Paul Eggert wrote:
> On 12/28/20 5:59 AM, Adhemerval Zanella wrote:
>> The faccessat (..., AT_EACCESS) on Linux fallback will either use
>> __NR_faccessat for __libc_enable_secure or LFS  fstatat call.  Neither
>> fallbacks returns EOVERFLOW in failure case.
> Argh, I had misread the glibc source code in this area. So I installed this further Gnulib patch:
> 
> https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=d82dfeb8a7c9b276c8c7db94d077eb7a43a6760c
> 
> which should result in even simpler code than the v2 6/6 patch.
> 
> So, to summarize this series of 6 patches to glibc:
> 
> * Patches 1, 2, and 3 are fine.
> 
> * Patch 4 (stdlib: Sync canonicalize with gnulib) can now sync with today's Gnulib instead.
> 
> * Patch 5 and 6 are no longer needed, since today's Gnulib subsumes them.

Right, I will sort this out and push a version synced with gnulib master.
I forgot to send a testcase for BZ#26341, which I will push as well.

Thanks for working on this to accommodate both gnulib and glibc requirements.
  

Patch

diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
index 69f978da78..5aac8d457c 100644
--- a/stdlib/canonicalize.c
+++ b/stdlib/canonicalize.c
@@ -44,15 +44,10 @@ 
 
 #ifdef _LIBC
 # include <shlib-compat.h>
-# include <sysdep.h>
-# ifdef __ASSUME_FACCESSAT2
-#  define FACCESSAT_NEVER_EOVERFLOWS __ASSUME_FACCESSAT2
-# else
-#  define FACCESSAT_NEVER_EOVERFLOWS true
-# endif
 # define GCC_LINT 1
 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
 # define FUNC_REALPATH_WORKS 1
+# define FACCESSAT_NEVER_EOVERFLOWS true
 #else
 # define __canonicalize_file_name canonicalize_file_name
 # define __realpath realpath
@@ -82,7 +77,7 @@ 
 # define __pathconf pathconf
 # define __rawmemchr rawmemchr
 # define __readlink readlink
-# define __stat stat
+# define FACCESSAT_NEVER_EOVERFLOWS false
 #endif
 
 /* Suppress bogus GCC -Wmaybe-uninitialized warnings.  */
@@ -95,9 +90,6 @@ 
 #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
 # define DOUBLE_SLASH_IS_DISTINCT_ROOT false
 #endif
-#ifndef FACCESSAT_NEVER_EOVERFLOWS
-# define FACCESSAT_NEVER_EOVERFLOWS false
-#endif
 
 #if !FUNC_REALPATH_WORKS || defined _LIBC