From: yangerkun <yangerkun@huawei.com>
To: <linux-ext4@vger.kernel.org>
Cc: <miaoxie@huawei.com>, <houtao1@huawei.com>, <yi.zhang@huawei.com>,
<yangerkun@huawei.com>
Subject: [PATCH 1/4] ext4: fix check of inode in swap_inode_boot_loader
Date: Thu, 10 Jan 2019 11:36:47 +0800 [thread overview]
Message-ID: <20190110033650.108403-2-yangerkun@huawei.com> (raw)
In-Reply-To: <20190110033650.108403-1-yangerkun@huawei.com>
What there need to be checked should be protected by inode lock.
Signed-off-by: yangerkun <yangerkun@huawei.com>
---
fs/ext4/ioctl.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 0edee31..579ebe5 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -116,15 +116,6 @@ static long swap_inode_boot_loader(struct super_block *sb,
struct inode *inode_bl;
struct ext4_inode_info *ei_bl;
- if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode) ||
- IS_SWAPFILE(inode) || IS_ENCRYPTED(inode) ||
- ext4_has_inline_data(inode))
- return -EINVAL;
-
- if (IS_RDONLY(inode) || IS_APPEND(inode) || IS_IMMUTABLE(inode) ||
- !inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN))
- return -EPERM;
-
inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO);
if (IS_ERR(inode_bl))
return PTR_ERR(inode_bl);
@@ -137,6 +128,19 @@ static long swap_inode_boot_loader(struct super_block *sb,
* that only 1 swap_inode_boot_loader is running. */
lock_two_nondirectories(inode, inode_bl);
+ if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode) ||
+ IS_SWAPFILE(inode) || IS_ENCRYPTED(inode) ||
+ ext4_has_inline_data(inode)) {
+ err = -EINVAL;
+ goto journal_err_out;
+ }
+
+ if (IS_RDONLY(inode) || IS_APPEND(inode) || IS_IMMUTABLE(inode) ||
+ !inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN)) {
+ err = -EPERM;
+ goto journal_err_out;
+ }
+
/* Wait for all existing dio workers */
inode_dio_wait(inode);
inode_dio_wait(inode_bl);
--
2.9.5
next prev parent reply other threads:[~2019-01-10 3:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 3:36 [PATCH 0/4] fix bugs for ioctl EXT4_IOC_SWAP_BOOT yangerkun
2019-01-10 3:36 ` yangerkun [this message]
2019-01-10 3:36 ` [PATCH 2/4] ext4: cleanup pagecache before swap i_data yangerkun
2019-01-10 3:36 ` [PATCH 3/4] ext4: update quota information while swapping boot loader inode yangerkun
2019-01-10 3:36 ` [PATCH 4/4] ext4: add mask of ext4 flags to swap 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=20190110033650.108403-2-yangerkun@huawei.com \
--to=yangerkun@huawei.com \
--cc=houtao1@huawei.com \
--cc=linux-ext4@vger.kernel.org \
--cc=miaoxie@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).