* [PATCH] fs: block pipe_write() on a frozen filesystem @ 2012-09-27 15:47 Eric Sandeen 2012-10-01 15:34 ` Jan Kara 2013-04-02 12:38 ` [PATCH] fs: block pipe_write() on a frozen filesystem PING Dmitry Monakhov 0 siblings, 2 replies; 5+ messages in thread From: Eric Sandeen @ 2012-09-27 15:47 UTC (permalink / raw) To: linux-fsdevel@vger.kernel.org Cc: Jan Kara, Fernando Luis Vazquez Cao, Al Viro I noticed that this can sneak past a frozen filesystem: # mkfifo /mnt/test/fifo # echo foo > /mnt/test/fifo & # fsfreeze -f /mnt/test # cat /mnt/test/fifo and we get a warning that jbd2 has entered a transaction while frozen: WARNING: at fs/ext4/super.c:240 ext4_journal_start_sb+0xce/0xe0 [ext4]() (Not tainted) which is: WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE); and we get there via the file_update_time() path in pipe_write(). Signed-off-by: Eric Sandeen <sandeen@redhat.com> --- Is this too big a hammer? file_update_time() is conditional... diff --git a/fs/pipe.c b/fs/pipe.c index 8d85d70..d19a709 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -501,6 +501,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov, do_wakeup = 0; ret = 0; + sb_start_write(inode->i_sb); mutex_lock(&inode->i_mutex); pipe = inode->i_pipe; @@ -659,6 +660,7 @@ out: if (err) ret = err; } + sb_end_write(inode->i_sb); return ret; } ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] fs: block pipe_write() on a frozen filesystem 2012-09-27 15:47 [PATCH] fs: block pipe_write() on a frozen filesystem Eric Sandeen @ 2012-10-01 15:34 ` Jan Kara 2013-04-02 12:38 ` [PATCH] fs: block pipe_write() on a frozen filesystem PING Dmitry Monakhov 1 sibling, 0 replies; 5+ messages in thread From: Jan Kara @ 2012-10-01 15:34 UTC (permalink / raw) To: Eric Sandeen Cc: linux-fsdevel@vger.kernel.org, Jan Kara, Fernando Luis Vazquez Cao, Al Viro On Thu 27-09-12 10:47:59, Eric Sandeen wrote: > I noticed that this can sneak past a frozen filesystem: > > # mkfifo /mnt/test/fifo > # echo foo > /mnt/test/fifo & > # fsfreeze -f /mnt/test > # cat /mnt/test/fifo > > and we get a warning that jbd2 has entered a transaction while frozen: > > WARNING: at fs/ext4/super.c:240 ext4_journal_start_sb+0xce/0xe0 [ext4]() (Not tainted) > > which is: WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE); > > and we get there via the file_update_time() path in pipe_write(). > > Signed-off-by: Eric Sandeen <sandeen@redhat.com> > --- > > Is this too big a hammer? file_update_time() is conditional... I think your patch is fine. Just skipping update of mtime could cause userspace issues (although they seem rather unlikely to me). So you can add Reviewed-by: Jan Kara <jack@suse.cz> Honza > > diff --git a/fs/pipe.c b/fs/pipe.c > index 8d85d70..d19a709 100644 > --- a/fs/pipe.c > +++ b/fs/pipe.c > @@ -501,6 +501,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov, > > do_wakeup = 0; > ret = 0; > + sb_start_write(inode->i_sb); > mutex_lock(&inode->i_mutex); > pipe = inode->i_pipe; > > @@ -659,6 +660,7 @@ out: > if (err) > ret = err; > } > + sb_end_write(inode->i_sb); > return ret; > } > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fs: block pipe_write() on a frozen filesystem PING.. 2012-09-27 15:47 [PATCH] fs: block pipe_write() on a frozen filesystem Eric Sandeen 2012-10-01 15:34 ` Jan Kara @ 2013-04-02 12:38 ` Dmitry Monakhov 2013-04-02 19:57 ` Al Viro 1 sibling, 1 reply; 5+ messages in thread From: Dmitry Monakhov @ 2013-04-02 12:38 UTC (permalink / raw) To: Eric Sandeen, linux-fsdevel@vger.kernel.org Cc: Jan Kara, Fernando Luis Vazquez Cao, Al Viro On Thu, 27 Sep 2012 10:47:59 -0500, Eric Sandeen <sandeen@redhat.com> wrote: > I noticed that this can sneak past a frozen filesystem: Ping.. any body want to take care about that patch? > > # mkfifo /mnt/test/fifo > # echo foo > /mnt/test/fifo & > # fsfreeze -f /mnt/test > # cat /mnt/test/fifo > > and we get a warning that jbd2 has entered a transaction while frozen: > > WARNING: at fs/ext4/super.c:240 ext4_journal_start_sb+0xce/0xe0 [ext4]() (Not tainted) > > which is: WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE); > > and we get there via the file_update_time() path in pipe_write(). > > Signed-off-by: Eric Sandeen <sandeen@redhat.com> > --- > > Is this too big a hammer? file_update_time() is conditional... > > diff --git a/fs/pipe.c b/fs/pipe.c > index 8d85d70..d19a709 100644 > --- a/fs/pipe.c > +++ b/fs/pipe.c > @@ -501,6 +501,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov, > > do_wakeup = 0; > ret = 0; > + sb_start_write(inode->i_sb); > mutex_lock(&inode->i_mutex); > pipe = inode->i_pipe; > > @@ -659,6 +660,7 @@ out: > if (err) > ret = err; > } > + sb_end_write(inode->i_sb); > return ret; > } > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fs: block pipe_write() on a frozen filesystem PING.. 2013-04-02 12:38 ` [PATCH] fs: block pipe_write() on a frozen filesystem PING Dmitry Monakhov @ 2013-04-02 19:57 ` Al Viro 2013-04-02 20:30 ` Dmitry Monakhov 0 siblings, 1 reply; 5+ messages in thread From: Al Viro @ 2013-04-02 19:57 UTC (permalink / raw) To: Dmitry Monakhov Cc: Eric Sandeen, linux-fsdevel@vger.kernel.org, Jan Kara, Fernando Luis Vazquez Cao On Tue, Apr 02, 2013 at 04:38:22PM +0400, Dmitry Monakhov wrote: > On Thu, 27 Sep 2012 10:47:59 -0500, Eric Sandeen <sandeen@redhat.com> wrote: > > I noticed that this can sneak past a frozen filesystem: > Ping.. any body want to take care about that patch? NAK. Note that writing to FIFO that sits on filesystem that is outright read-only is allowed just fine; blocking it for frozen ones is bogus. IOW, it should be treated the same way we treat touch_atime(). Moreover, it should only be done around file_update_time(). With trylock. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fs: block pipe_write() on a frozen filesystem PING.. 2013-04-02 19:57 ` Al Viro @ 2013-04-02 20:30 ` Dmitry Monakhov 0 siblings, 0 replies; 5+ messages in thread From: Dmitry Monakhov @ 2013-04-02 20:30 UTC (permalink / raw) To: Al Viro Cc: Eric Sandeen, linux-fsdevel@vger.kernel.org, Jan Kara, Fernando Luis Vazquez Cao [-- Attachment #1: Type: text/plain, Size: 692 bytes --] On Tue, 2 Apr 2013 20:57:27 +0100, Al Viro <viro@ZenIV.linux.org.uk> wrote: > On Tue, Apr 02, 2013 at 04:38:22PM +0400, Dmitry Monakhov wrote: > > On Thu, 27 Sep 2012 10:47:59 -0500, Eric Sandeen <sandeen@redhat.com> wrote: > > > I noticed that this can sneak past a frozen filesystem: > > Ping.. any body want to take care about that patch? > > NAK. Note that writing to FIFO that sits on filesystem that is outright > read-only is allowed just fine; blocking it for frozen ones is bogus. > > IOW, it should be treated the same way we treat touch_atime(). Moreover, > it should only be done around file_update_time(). With trylock. Ok fair enough. Please take a look at updated version [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-PATCH-fs-skip-mtime-update-for-fifo-on-a-frozen-file.patch --] [-- Type: text/x-patch, Size: 1421 bytes --] >From c01acb73b8dc9e7a891b8f087ad3eb53bb06d270 Mon Sep 17 00:00:00 2001 From: Dmitry Monakhov <dmonakhov@openvz.org> Date: Wed, 3 Apr 2013 00:19:15 +0400 Subject: [PATCH] [PATCH] fs: skip mtime update for fifo on a frozen filesystem Eric noticed that this can sneak past a frozen filesystem: # mkfifo /mnt/test/fifo # echo foo > /mnt/test/fifo & # fsfreeze -f /mnt/test # cat /mnt/test/fifo and we get a warning that jbd2 has entered a transaction while frozen: WARNING: at fs/ext4/super.c:240 ext4_journal_start_sb+0xce/0xe0 [ext4]() (Not tainted) which is: WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE); and we get there via the file_update_time() path in pipe_write(). If filesystem is frozen we can block pipe_write() but this is not optimal because fifo is special_file so let's skip mtime update as we do with touch_atime() Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> --- fs/pipe.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 2234f3f..62f63d5 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -654,10 +654,11 @@ out: wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLRDNORM); kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); } - if (ret > 0) { + if (ret > 0 && sb_start_write_trylock(inode->i_sb)) { int err = file_update_time(filp); if (err) ret = err; + sb_end_write(inode->i_sb); } return ret; } -- 1.7.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-04-02 20:30 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-09-27 15:47 [PATCH] fs: block pipe_write() on a frozen filesystem Eric Sandeen 2012-10-01 15:34 ` Jan Kara 2013-04-02 12:38 ` [PATCH] fs: block pipe_write() on a frozen filesystem PING Dmitry Monakhov 2013-04-02 19:57 ` Al Viro 2013-04-02 20:30 ` Dmitry Monakhov
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).