This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Linux: Work around kernel bugs in chmod on /proc/self/fd paths


* Stefan Liebler:

> On 2/18/20 5:50 PM, Matheus Castanho wrote:
> ...
>> On 2/18/20 11:50 AM, Florian Weimer wrote:
>>> Agreed, I've dropped it.
>>>
>>> New patch below.
>>>
>>> Florian
> ...
> ...
>> LGTM.
>>
>> Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
>>
>> --
>> Matheus Castanho
>>
>
> Hi Florian,
>
> I've just recognized that building with -Os fails with
> /usr/bin/ld: /path/to/glibc-build/libc_pic.os.clean: in function `fchmodat':
> (.text+0xb1c36): undefined reference to `fstatat64'
> collect2: error: ld returned 1 exit status
>
> This happens at least on x86_64 and s390x.
> I've bisected and this was the first bad commit.

Thanks.  This patch should fix building with -Os.

Florian

8<------------------------------------------------------------------8<
Subject: Linux: Use __fstatat64 in fchmodat implementation

fstatat64 depends on inlining to produce the desired __fxstatat64
call, which does not happen with -Os, leading to a link failure
with an undefined reference to fstatat64.  __fxstatat64 has a macro
definition in include/sys/stat.h and thus avoids the problem.

-----
 sysdeps/unix/sysv/linux/fchmodat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c
index 17eca54051..5531f1aa6f 100644
--- a/sysdeps/unix/sysv/linux/fchmodat.c
+++ b/sysdeps/unix/sysv/linux/fchmodat.c
@@ -48,7 +48,7 @@ fchmodat (int fd, const char *file, mode_t mode, int flag)
       /* Use fstatat because fstat does not work on O_PATH descriptors
 	 before Linux 3.6.  */
       struct stat64 st;
-      if (fstatat64 (pathfd, "", &st, AT_EMPTY_PATH) != 0)
+      if (__fstatat64 (pathfd, "", &st, AT_EMPTY_PATH) != 0)
 	{
 	  __close_nocancel (pathfd);
 	  return -1;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]