linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: yangerkun <yangerkun@huawei.com>
Cc: <jack@suse.com>, <miaoxie@huawei.com>, <yi.zhang@huawei.com>,
	<houtao1@huawei.com>, <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH V2 4/4] ext4: add mask of ext4 flags to swap
Date: Mon, 11 Feb 2019 01:01:27 -0500	[thread overview]
Message-ID: <20190211060127.GM23000@mit.edu> (raw)
In-Reply-To: <20190122065823.67957-5-yangerkun@huawei.com>

Thanks, applied.

I've simplified the commit description, and also dropped the
compression related flags (which are not currently being used at all)
from the list of flags that should be swapped.

One of the reasons for simplifying the commit description is if the
goal is to make the EXT4_IOC_SWAP_BOOT proof against hostile/malicious
userspace, then we shouldn't allow inodes that have the
EXT4_JOURNAL_DATA_FL set from being used a source for the bootloader
inode.

That's because if inode A has the JOURNAL_DATA flag set and a block B
belonging to inode A is freshly written to it (and thus journalled),
and then we swap it into the bootloader inode, and then swap it back
out with inode C, which does not have the JOURNAL_DATA flag, and then
that inode is immediately deleted, we won't write a revoke record for
block B into the journal.  If that block gets reused, and then we
crash (or the malicious root user deliberately crashes the system),
when the journal is replayed, we could end up corrupting block B.

This can be dealt with (see ext4_change_inode_journal_flag) but doing
so requires doing some drastic things, and the simpler solution is to
simply prohibit using inodes that have the JOURNAL_DATA flag set from
being used by EXT4_IOC_SWAP_BOOT, since there's no real use for
allowing case anyway.

This may be overkill, since you have to be root to use
EXT4_IOC_SWAP_BOOT, and a malcious root user who is determined to
screw up the system can find much more simpler ways to do so.  On the
other hand there are programs run as root written by clueless
developers, and systems which simulate such developers (e.g.,
syzkaller :-).  Previously we were a bit less careful with
EXT4_IOC_SWAP_BOOT because it could only be used by root, and only
very specialized programs would need to use it, and it was kind of
assumed that those root users and such specialized programs wouldn't
be *trying* to mess things up.

Anway, I'll follow up your patch series with a patch which prohibits
files that have EXT4_JOURNAL_DATA_FL set from being used with
EXT4_IOC_SWAP_BOOT.

Cheers,

					- Ted

  reply	other threads:[~2019-02-11  6:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-22  6:58 [PATCH V2 0/4] fix bugs for ioctl EXT4_IOC_SWAP_BOOT yangerkun
2019-01-22  6:58 ` [PATCH V2 1/4] ext4: fix check of inode in swap_inode_boot_loader yangerkun
2019-02-11  5:02   ` Theodore Y. Ts'o
2019-01-22  6:58 ` [PATCH V2 2/4] ext4: cleanup pagecache before swap i_data yangerkun
2019-02-11  5:12   ` Theodore Y. Ts'o
2019-01-22  6:58 ` [PATCH V2 3/4] ext4: update quota information while swapping boot loader inode yangerkun
2019-02-11  5:16   ` Theodore Y. Ts'o
2019-01-22  6:58 ` [PATCH V2 4/4] ext4: add mask of ext4 flags to swap yangerkun
2019-02-11  6:01   ` Theodore Y. Ts'o [this message]
2019-01-31 11:43 ` [PATCH V2 0/4] fix bugs for ioctl EXT4_IOC_SWAP_BOOT yangerkun

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=20190211060127.GM23000@mit.edu \
    --to=tytso@mit.edu \
    --cc=houtao1@huawei.com \
    --cc=jack@suse.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).