mirror of
https://github.com/libfuse/libfuse.git
synced 2026-07-07 14:47:41 +08:00
libfuse: remove unmount command from the service api
Bernd received a complaint via github that the "unmount" command in the
new fuse service API is prone to malicious symlink creation races
because the umount2 call doesn't use UMOUNT_NOFOLLOW. Therefore, if you
can trick a fuse service into asking the mount service helper to undo
the mount just after you've replaced the mount with a symlink to a
sensitive mount (e.g. /sys) then you whack a system hard.
I don't know why this unmounting functionality exists in libfuse, and
apparently Bernd doesn't like it. Since the fuse service API has not
yet been released, let's just rip out the command and pretend it never
existed.
Fixes: 5d8b9a39a1 ("mount_service: add systemd socket service mounting helper")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
This commit is contained in:
committed by
Bernd Schubert
parent
d4e199cb63
commit
dc6ce72129
@@ -1128,57 +1128,6 @@ out_strings:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fuse_service_session_unmount(const struct fuse_service *sf)
|
||||
{
|
||||
struct fuse_service_simple_reply reply = { };
|
||||
struct fuse_service_unmount_command c = {
|
||||
.p.magic = htonl(FUSE_SERVICE_UNMOUNT_CMD),
|
||||
};
|
||||
ssize_t size;
|
||||
|
||||
/* already gone? */
|
||||
if (sf->sockfd < 0)
|
||||
return 0;
|
||||
|
||||
size = __send_packet(sf, &c, sizeof(c));
|
||||
if (size < 0) {
|
||||
int error = errno;
|
||||
|
||||
fuse_log(FUSE_LOG_ERR, "fuse: send service unmount: %s\n",
|
||||
strerror(error));
|
||||
return -error;
|
||||
}
|
||||
|
||||
size = __recv_packet(sf, &reply, sizeof(reply));
|
||||
if (size < 0) {
|
||||
int error = errno;
|
||||
|
||||
fuse_log(FUSE_LOG_ERR, "fuse: service unmount reply: %s\n",
|
||||
strerror(error));
|
||||
return -error;
|
||||
}
|
||||
if (size != sizeof(reply)) {
|
||||
fuse_log(FUSE_LOG_ERR, "fuse: wrong service unmount reply size %zd, expected %zd\n",
|
||||
size, sizeof(reply));
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
if (ntohl(reply.p.magic) != FUSE_SERVICE_SIMPLE_REPLY) {
|
||||
fuse_log(FUSE_LOG_ERR, "fuse: service unmount reply contains wrong magic!\n");
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
if (reply.error) {
|
||||
int error = ntohl(reply.error);
|
||||
|
||||
fuse_log(FUSE_LOG_ERR, "fuse: service unmount: %s\n",
|
||||
strerror(error));
|
||||
return -error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fuse_service_release(struct fuse_service *sf)
|
||||
{
|
||||
if (sf->owns_fusedevfd)
|
||||
|
||||
@@ -93,11 +93,6 @@ int fuse_service_session_mount(struct fuse_service *sf, struct fuse_session *se,
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int fuse_service_session_unmount(const struct fuse_service *sf)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
void fuse_service_release(struct fuse_service *sf)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -250,7 +250,6 @@ FUSE_3.19 {
|
||||
fuse_service_request_blockdev;
|
||||
fuse_service_send_goodbye;
|
||||
fuse_service_session_mount;
|
||||
fuse_service_session_unmount;
|
||||
fuse_req_secctx_count;
|
||||
fuse_req_secctx_reset;
|
||||
fuse_req_secctx_next;
|
||||
|
||||
Reference in New Issue
Block a user