* [PATCH] autofs: clear O_NONBLOCK on the pipe.
@ 2019-02-10 23:37 NeilBrown
2019-02-11 5:31 ` Ian Kent
0 siblings, 1 reply; 3+ messages in thread
From: NeilBrown @ 2019-02-10 23:37 UTC (permalink / raw)
To: Ian Kent, Andrew Morton; +Cc: autofs, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 938 bytes --]
autofs does not expect the pipe it is given
to have O_NONBLOCK set - specifically if __kernel_write()
in autofs_write() returns -EAGAIN, this is treated
as a fatal error and the pipe is closed.
For safety autofs should, therefore, clear the O_NONBLOCK flag.
Releases of systemd prior to 8th February 2019 used
pipe2(p, O_NONBLOCK|O_CLOEXEC)
and thus (inadvertently) set this flag.
Signed-off-by: NeilBrown <neilb@suse.com>
---
fs/autofs/autofs_i.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index 3e59f0ed777b..331192bed0d5 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -215,6 +215,8 @@ static inline int autofs_prepare_pipe(struct file *pipe)
return -EINVAL;
/* We want a packet pipe */
pipe->f_flags |= O_DIRECT;
+ /* We don't expect -EAGAIN */
+ pipe->f_flags &= ~O_NONBLOCK;
return 0;
}
--
2.14.0.rc0.dirty
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] autofs: clear O_NONBLOCK on the pipe.
2019-02-10 23:37 [PATCH] autofs: clear O_NONBLOCK on the pipe NeilBrown
@ 2019-02-11 5:31 ` Ian Kent
0 siblings, 0 replies; 3+ messages in thread
From: Ian Kent @ 2019-02-11 5:31 UTC (permalink / raw)
To: NeilBrown, Andrew Morton; +Cc: autofs, linux-kernel
On Mon, 2019-02-11 at 10:37 +1100, NeilBrown wrote:
> autofs does not expect the pipe it is given
> to have O_NONBLOCK set - specifically if __kernel_write()
> in autofs_write() returns -EAGAIN, this is treated
> as a fatal error and the pipe is closed.
>
> For safety autofs should, therefore, clear the O_NONBLOCK flag.
>
> Releases of systemd prior to 8th February 2019 used
> pipe2(p, O_NONBLOCK|O_CLOEXEC)
> and thus (inadvertently) set this flag.
Thanks Neil, this does look like an obvious problem.
>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
> fs/autofs/autofs_i.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
> index 3e59f0ed777b..331192bed0d5 100644
> --- a/fs/autofs/autofs_i.h
> +++ b/fs/autofs/autofs_i.h
> @@ -215,6 +215,8 @@ static inline int autofs_prepare_pipe(struct file *pipe)
> return -EINVAL;
> /* We want a packet pipe */
> pipe->f_flags |= O_DIRECT;
> + /* We don't expect -EAGAIN */
> + pipe->f_flags &= ~O_NONBLOCK;
> return 0;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] autofs: clear O_NONBLOCK on the pipe.
@ 2019-02-12 1:38 Ian Kent
0 siblings, 0 replies; 3+ messages in thread
From: Ian Kent @ 2019-02-12 1:38 UTC (permalink / raw)
To: Andrew Morton
Cc: autofs mailing list, linux-fsdevel, Kernel Mailing List, NeilBrown
From: NeilBrown <neilb@suse.com>
autofs does not expect the pipe it is given
to have O_NONBLOCK set - specifically if __kernel_write()
in autofs_write() returns -EAGAIN, this is treated
as a fatal error and the pipe is closed.
For safety autofs should, therefore, clear the O_NONBLOCK flag.
Releases of systemd prior to 8th February 2019 used
pipe2(p, O_NONBLOCK|O_CLOEXEC)
and thus (inadvertently) set this flag.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
fs/autofs/autofs_i.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index b735f2b1e462..70c132acdab1 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -216,6 +216,8 @@ static inline int autofs_prepare_pipe(struct file *pipe)
return -EINVAL;
/* We want a packet pipe */
pipe->f_flags |= O_DIRECT;
+ /* We don't expect -EAGAIN */
+ pipe->f_flags &= ~O_NONBLOCK;
return 0;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-12 1:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-10 23:37 [PATCH] autofs: clear O_NONBLOCK on the pipe NeilBrown
2019-02-11 5:31 ` Ian Kent
2019-02-12 1:38 Ian Kent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).