|
|
7244374 |
From 14adc898a36948267bfe5c63b399996879e94c98 Mon Sep 17 00:00:00 2001
|
|
|
7244374 |
From: Andreas Gruenbacher <agruenba@redhat.com>
|
|
|
7244374 |
Date: Fri, 17 Aug 2018 14:07:31 +0200
|
|
|
7244374 |
Subject: [PATCH] Switch back to syscall()
|
|
|
7244374 |
|
|
|
7244374 |
Switch back to syscall() for the *xattr system calls. The current
|
|
|
7244374 |
mechanism of forwarding those calls to glibc breaks libraries like
|
|
|
7244374 |
libfakeroot (fakeroot) and libasan (the gcc address sanitizer; gcc
|
|
|
7244374 |
-fsanitize=address).
|
|
|
7244374 |
|
|
|
7244374 |
Those libraries provide wrappers for functions defined in other shared
|
|
|
7244374 |
libraries, usually glibc, do their own processing, and forward calls to
|
|
|
7244374 |
the original symbols looke dup via dlsym(RTLD_NEXT, "symbol_name"). In
|
|
|
7244374 |
our case, dlsym returns the libattr_*xattr wrappers. However, when our
|
|
|
7244374 |
wrappers try calling glibc, they end up calling the libfakeroot /
|
|
|
7244374 |
libasan wrappers instead because those override the original symbols =>
|
|
|
7244374 |
recursion.
|
|
|
7244374 |
|
|
|
7244374 |
The libattr_*xattr wrappers will only be used when symbols are looked up
|
|
|
7244374 |
at runtime (dlopen / dlsym). Programs linking against libattr will
|
|
|
7244374 |
directly use the glibc provided symbols. Therefore, the slightly worse
|
|
|
7244374 |
performance of syscall() won't affect any of the "normal" users of
|
|
|
7244374 |
libattr.
|
|
|
7244374 |
---
|
|
|
7244374 |
libattr/syscalls.c | 26 ++++++++++++++------------
|
|
|
7244374 |
1 file changed, 14 insertions(+), 12 deletions(-)
|
|
|
7244374 |
|
|
|
7244374 |
diff --git a/libattr/syscalls.c b/libattr/syscalls.c
|
|
|
7244374 |
index 3013aa0bb687..721ad7f33185 100644
|
|
|
7244374 |
--- a/libattr/syscalls.c
|
|
|
7244374 |
+++ b/libattr/syscalls.c
|
|
|
7244374 |
@@ -22,6 +22,8 @@
|
|
|
7244374 |
|
|
|
7244374 |
#include "config.h"
|
|
|
7244374 |
|
|
|
7244374 |
+#include <unistd.h>
|
|
|
7244374 |
+#include <sys/syscall.h>
|
|
|
7244374 |
#include <sys/xattr.h>
|
|
|
7244374 |
|
|
|
7244374 |
#ifdef HAVE_VISIBILITY_ATTRIBUTE
|
|
|
7244374 |
@@ -31,67 +33,67 @@
|
|
|
7244374 |
int libattr_setxattr(const char *path, const char *name,
|
|
|
7244374 |
void *value, size_t size, int flags)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return setxattr(path, name, value, size, flags);
|
|
|
7244374 |
+ return syscall(__NR_setxattr, path, name, value, size, flags);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
int libattr_lsetxattr(const char *path, const char *name,
|
|
|
7244374 |
void *value, size_t size, int flags)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return lsetxattr(path, name, value, size, flags);
|
|
|
7244374 |
+ return syscall(__NR_lsetxattr, path, name, value, size, flags);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
int libattr_fsetxattr(int filedes, const char *name,
|
|
|
7244374 |
void *value, size_t size, int flags)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return fsetxattr(filedes, name, value, size, flags);
|
|
|
7244374 |
+ return syscall(__NR_fsetxattr, filedes, name, value, size, flags);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
ssize_t libattr_getxattr(const char *path, const char *name,
|
|
|
7244374 |
void *value, size_t size)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return getxattr(path, name, value, size);
|
|
|
7244374 |
+ return syscall(__NR_getxattr, path, name, value, size);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
ssize_t libattr_lgetxattr(const char *path, const char *name,
|
|
|
7244374 |
void *value, size_t size)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return lgetxattr(path, name, value, size);
|
|
|
7244374 |
+ return syscall(__NR_lgetxattr, path, name, value, size);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
ssize_t libattr_fgetxattr(int filedes, const char *name,
|
|
|
7244374 |
void *value, size_t size)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return fgetxattr(filedes, name, value, size);
|
|
|
7244374 |
+ return syscall(__NR_fgetxattr, filedes, name, value, size);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
ssize_t libattr_listxattr(const char *path, char *list, size_t size)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return listxattr(path, list, size);
|
|
|
7244374 |
+ return syscall(__NR_listxattr, path, list, size);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
ssize_t libattr_llistxattr(const char *path, char *list, size_t size)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return llistxattr(path, list, size);
|
|
|
7244374 |
+ return syscall(__NR_llistxattr, path, list, size);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
ssize_t libattr_flistxattr(int filedes, char *list, size_t size)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return flistxattr(filedes, list, size);
|
|
|
7244374 |
+ return syscall(__NR_flistxattr, filedes, list, size);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
int libattr_removexattr(const char *path, const char *name)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return removexattr(path, name);
|
|
|
7244374 |
+ return syscall(__NR_removexattr, path, name);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
int libattr_lremovexattr(const char *path, const char *name)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return lremovexattr(path, name);
|
|
|
7244374 |
+ return syscall(__NR_lremovexattr, path, name);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
int libattr_fremovexattr(int filedes, const char *name)
|
|
|
7244374 |
{
|
|
|
7244374 |
- return fremovexattr(filedes, name);
|
|
|
7244374 |
+ return syscall(__NR_fremovexattr, filedes, name);
|
|
|
7244374 |
}
|
|
|
7244374 |
|
|
|
7244374 |
#ifdef HAVE_VISIBILITY_ATTRIBUTE
|
|
|
7244374 |
--
|
|
|
7244374 |
2.19.0.rc0
|
|
|
7244374 |
|