Linux-ext4 Archive on lore.kernel.org
 help / color / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Ext4 <linux-ext4@vger.kernel.org>, rebello.anthony@gmail.com
Subject: Re: Data exposure on IO error
Date: Sat, 1 Aug 2020 10:32:53 +0300
Message-ID: <CAOQ4uxgovoBjs5BnYdPyV6K9AP17fCaeVgZ=wQMfx4hAuAf5RQ@mail.gmail.com> (raw)
In-Reply-To: <20200731225621.GA7126@quack2.suse.cz>

On Sat, Aug 1, 2020 at 1:59 AM Jan Kara <jack@suse.cz> wrote:
>
> Hello!
>
> In bug 207729, Anthony reported a bug that can actually lead to a stale
> data exposure on IO error. The problem is relatively simple: Suppose we
> do:
>
>   fd = open("file", O_WRONLY | O_CREAT | O_TRUNC, 0644);
>   write(fd, buf, 4096);
>   fsync(fd);
>
> And IO error happens when fsync writes the block of "file". The IO error
> gets properly reported to userspace but otherwise the filesystem keeps
> running. So the transaction creating "file" and allocating block to it can
> commit. Then when page cache of "file" gets evicted, the user can read
> stale block contents (provided the IO error was just temporary or involving
> only writes).
>
> Now I understand in face of IO errors the behavior is really undefined but
> potential exposure of stale data seems worse than strictly necessary. Also
> if we run in data=ordered mode, especially if also data_err=abort is set,
> user would rightfully expect that the filesystem gets aborted when such IO
> error happens but that's not the case. Generally data_err=abort seems a bit
> misnamed (and the manpage is wrong about this mount option) since what it
> really does is that if jbd2 thread encounters error when writing back
> ordered data, the filesystem is aborted. However the ordered data can be
> written back by other processes as well and in that case the error is just
> lost / reported to userspace but the filesystem doesn't get aborted.
>
> As I was thinking about it, it seems to me that in data=ordered mode, we
> should just always abort the filesystem when writeback of newly allocated
> block fails to avoid the stale data exposure mentioned above. And then, we
> could just deprecate data_err= mount option because it wouldn't be any
> useful anymore... What do people think?
>

It sounds worse than strictly necessary.

In what way is that use case different from writing into a punched hole
in the middle of the file and getting an IO error on writeback?

It looks like ext4 already goes into a great deal of trouble to handle
extent conversion to init at io end.

So couldn't the described case be handled as a private case of
filling a hole at the end of the file?

Am I missing something beyond the fact that traditionally, extending
a file enjoyed the protection of i_disksize, so did not need to worry
about unwritten extents?

Thanks,
Amir.

  reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 22:56 Jan Kara
2020-08-01  7:32 ` Amir Goldstein [this message]
2020-08-03  7:57   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOQ4uxgovoBjs5BnYdPyV6K9AP17fCaeVgZ=wQMfx4hAuAf5RQ@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=rebello.anthony@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-ext4 Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-ext4/0 linux-ext4/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-ext4 linux-ext4/ https://lore.kernel.org/linux-ext4 \
		linux-ext4@vger.kernel.org
	public-inbox-index linux-ext4

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-ext4


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git