From: Lennart Poettering Date: Thu, 14 Jul 2022 09:30:27 +0000 (+0200) Subject: growfs: insist we open a directory when opening fs mount point X-Git-Tag: v252-rc1~653^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e7dd6682bc9da79d5249caa93ea1bde37a0f315;p=thirdparty%2Fsystemd.git growfs: insist we open a directory when opening fs mount point This is a simple safety check, since we shouldn't invoke ioctls on fds without being reasonably sure they are of the right type since ioctls are overloaded, and we might be tricked hence to execute an operation on an fd which means something different than what we expect. --- diff --git a/src/partition/growfs.c b/src/partition/growfs.c index 31dcf0ffdf1..d7069b8d082 100644 --- a/src/partition/growfs.c +++ b/src/partition/growfs.c @@ -225,7 +225,7 @@ static int run(int argc, char *argv[]) { if (r < 0) return r; - mountfd = open(arg_target, O_RDONLY|O_CLOEXEC); + mountfd = open(arg_target, O_RDONLY|O_CLOEXEC|O_DIRECTORY); if (mountfd < 0) return log_error_errno(errno, "Failed to open \"%s\": %m", arg_target);