summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemengine_unix.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-01-07 15:32:35 -0600
committerThiago Macieira <thiago.macieira@intel.com>2018-03-14 19:26:02 +0000
commit8eb3944dac81b8c51d7bac7784204d457551b50c (patch)
tree863c9db0660ea4671e600a5d4cc8dd474ef3a1fa /src/corelib/io/qfilesystemengine_unix.cpp
parent96ba39b1ee095e814587c760dc83add03ee67232 (diff)
Disable statx(2) and renameat2(2) system calls on Android
Many Android systems come with a locked down system call list, causing the statx(2) system call to fail with an unexpected error code or by delivering a signal to the application. Because of the signal, we can't do runtime detection... This is not our bug: it's obviously a mistake in the SECCOMP rules in Android. But we work around the issue. Unfortunately, because of a few manufacturers who can't configure their rules properly, everyone will suffer. Task-number: QTBUG-64490 Change-Id: I39332e0a867442d58082fffd1507a49415917384 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index b974af80dc..b8cf42a2e9 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -91,26 +91,35 @@ extern "C" NSString *NSTemporaryDirectory();
# include <sys/syscall.h>
# include <sys/sendfile.h>
# include <linux/fs.h>
+# include <linux/stat.h>
// in case linux/fs.h is too old and doesn't define it:
#ifndef FICLONE
# define FICLONE _IOW(0x94, 9, int)
#endif
-# if !QT_CONFIG(renameat2) && defined(SYS_renameat2)
+# if defined(Q_OS_ANDROID)
+// renameat2() and statx() are disabled on Android because quite a few systems
+// come with sandboxes that kill applications that make system calls outside a
+// whitelist and several Android vendors can't be bothered to update the list.
+# undef SYS_renameat2
+# undef SYS_statx
+# undef STATX_BASIC_STATS
+# else
+# if !QT_CONFIG(renameat2) && defined(SYS_renameat2)
static int renameat2(int oldfd, const char *oldpath, int newfd, const char *newpath, unsigned flags)
{ return syscall(SYS_renameat2, oldfd, oldpath, newfd, newpath, flags); }
-# endif
+# endif
-# if !QT_CONFIG(statx) && defined(SYS_statx) && QT_HAS_INCLUDE(<linux/stat.h>)
-# include <linux/stat.h>
+# if !QT_CONFIG(statx) && defined(SYS_statx)
static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struct statx *statxbuf)
{ return syscall(SYS_statx, dirfd, pathname, flag, mask, statxbuf); }
-# endif
+# endif
+# endif // !Q_OS_ANDROID
#endif
-#ifndef STATX_BASIC_STATS
-struct statx { mode_t stx_mode; };
+#ifndef STATX_ALL
+struct statx { mode_t stx_mode; }; // dummy
#endif
QT_BEGIN_NAMESPACE