This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Linux: Work around kernel bugs in chmod on /proc/self/fd paths
- From: Florian Weimer <fweimer at redhat dot com>
- To: Stefan Liebler <stli at linux dot ibm dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 05 Mar 2020 13:47:07 +0100
- Subject: Re: [PATCH] Linux: Work around kernel bugs in chmod on /proc/self/fd paths
- References: <87sgjfd04p.fsf@oldenburg2.str.redhat.com> <d3d43ae5-560d-894f-341b-69b9b7241cc6@linux.ibm.com> <87lfp0eyq1.fsf@oldenburg2.str.redhat.com> <0e138e0f-6062-9ac1-4aac-896377304130@linux.ibm.com> <07cadb1f-82ce-9f70-9040-291388f37ef6@linux.ibm.com>
* 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;