summaryrefslogtreecommitdiff
path: root/src/basic/mount-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-03-01 17:35:05 +0100
committerSven Eden <yamakuzure@gmx.net>2017-07-17 17:58:36 +0200
commit897fa0c6abbc3ca06bbde9ec9f53f07ae24d8eba (patch)
treeb519365f64fb0b4ab9aed898d1dfa0e27bbe6be4 /src/basic/mount-util.c
parenteeb58b12cdce99bcbc654a9b89f9e7622ad3eb04 (diff)
mount-util: accept that name_to_handle_at() might fail with EPERM (#5499)
Container managers frequently block name_to_handle_at(), returning EACCES or EPERM when this is issued. Accept that, and simply fall back to to fdinfo-based checks. Note that we accept either EACCES or EPERM here, as container managers can choose the error code and aren't very good on agreeing on just one. (note that this is a non-issue with nspawn, as we permit name_to_handle_at() there, only block open_by_handle_at(), which should be sufficiently safe).
Diffstat (limited to 'src/basic/mount-util.c')
-rw-r--r--src/basic/mount-util.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c
index 402e55bcf..dc7b5b567 100644
--- a/src/basic/mount-util.c
+++ b/src/basic/mount-util.c
@@ -110,9 +110,10 @@ int fd_is_mount_point(int fd, const char *filename, int flags) {
r = name_to_handle_at(fd, filename, &h.handle, &mount_id, flags);
if (r < 0) {
- if (errno == ENOSYS)
- /* This kernel does not support name_to_handle_at()
- * fall back to simpler logic. */
+ if (IN_SET(errno, ENOSYS, EACCES, EPERM))
+ /* This kernel does not support name_to_handle_at() at all, or the syscall was blocked (maybe
+ * through seccomp, because we are running inside of a container?): fall back to simpler
+ * logic. */
goto fallback_fdinfo;
else if (errno == EOPNOTSUPP)
/* This kernel or file system does not support
@@ -161,7 +162,7 @@ int fd_is_mount_point(int fd, const char *filename, int flags) {
fallback_fdinfo:
r = fd_fdinfo_mnt_id(fd, filename, flags, &mount_id);
- if (IN_SET(r, -EOPNOTSUPP, -EACCES))
+ if (IN_SET(r, -EOPNOTSUPP, -EACCES, -EPERM))
goto fallback_fstat;
if (r < 0)
return r;