From 1cae151d8e38d4017ccd65ed12c459774e537bb2 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 8 Feb 2019 09:44:06 +1100 Subject: [PATCH] automount: don't pass non-blocking pipe to kernel. Creating a pipe with O_NONBLOCK causes both the read and the write end to be marked as non-blocking. The "write" end is passed to the kernel autofs module, and it does not expect a non-blocking pipe. If it gets -EAGAIN when trying to write (which is unlikely, but not completely impossible), it will close the write end of the pipe, which leads to unexpected errors. So change the code to only set O_NONBLOCK on the "read" end of the pipe. This is the only end that systemd interacts with, so the only end it should be configuring. --- src/core/automount.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/automount.c b/src/core/automount.c index 6db13ab..6a83739 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -578,10 +578,13 @@ static void automount_enter_waiting(Automount *a) { goto fail; } - if (pipe2(p, O_NONBLOCK|O_CLOEXEC) < 0) { + if (pipe2(p, O_CLOEXEC) < 0) { r = -errno; goto fail; } + r = fd_nonblock(p[0], true); + if (r < 0) + goto fail; xsprintf(options, "fd=%i,pgrp="PID_FMT",minproto=5,maxproto=5,direct", p[1], getpgrp()); xsprintf(name, "systemd-"PID_FMT, getpid_cached()); -- 2.7.4