From: Eric Sandeen <sandeen@redhat.com>
To: Eric Sandeen <sandeen@redhat.com>, linux-xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH 2/2 V2] xfs: verify size-vs-format for symlinks & dirs
Date: Mon, 10 Sep 2018 17:24:17 -0500 [thread overview]
Message-ID: <d2648726-e4f9-a5a7-c9b1-560ad03d3e67@redhat.com> (raw)
In-Reply-To: <0c8c405b-8929-82a6-5c9a-f5965da2c464@redhat.com>
Today, xfs_ifork_verify_data() will simply skip verification if the inode
claims to be in non-local format. However, nothing catches the case where
the size for the format is too small to be non-local. xfs_repair tests
for this mismatch in process_check_inode_sizes(), so do the same in this
verifier.
Reported-by: Xu, Wen <wen.xu@gatech.edu>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200925
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
V2: restructure code & tests per Dave's suggestion on the V1 patch.
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 183ec0cb8921..d6a137f5e207 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -732,12 +732,32 @@ xfs_ifork_verify_data(
struct xfs_inode *ip,
struct xfs_ifork_ops *ops)
{
- /* Non-local data fork, we're done. */
- if (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL)
+ struct xfs_mount *mp = ip->i_mount;
+ int mode = VFS_I(ip)->i_mode;
+
+ if (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) {
+ /*
+ * types that can be in local form need size checks
+ * to ensure they have the right amount of data in
+ * them to be in non-local form
+ */
+ switch (mode & S_IFMT) {
+ case S_IFDIR:
+ if (ip->i_d.di_size < mp->m_dir_geo->blksize)
+ return __this_address;
+ break;
+ case S_IFLNK:
+ if (ip->i_d.di_size <= XFS_IFORK_DSIZE(ip))
+ return __this_address;
+ break;
+ default:
+ break;
+ }
return NULL;
+ }
/* Check the inline data fork if there is one. */
- switch (VFS_I(ip)->i_mode & S_IFMT) {
+ switch (mode & S_IFMT) {
case S_IFDIR:
return ops->verify_dir(ip);
case S_IFLNK:
next prev parent reply other threads:[~2018-09-11 3:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-10 22:18 [PATCH 0/2] xfs: validate size vs format, take 2 Eric Sandeen
2018-09-10 22:22 ` [PATCH 1/2] xfs: validate inode di_forkoff Eric Sandeen
2018-09-24 17:04 ` Brian Foster
2018-09-25 2:50 ` Eric Sandeen
2018-09-10 22:24 ` Eric Sandeen [this message]
2018-09-24 17:06 ` [PATCH 2/2 V2] xfs: verify size-vs-format for symlinks & dirs Brian Foster
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=d2648726-e4f9-a5a7-c9b1-560ad03d3e67@redhat.com \
--to=sandeen@redhat.com \
--cc=linux-xfs@vger.kernel.org \
/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).