linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <n.borisov.lkml@gmail.com>
To: stable@vger.kernel.org
Cc: darrick.wong@oracle.com, linux-xfs@vger.kernel.org, bfoster@redhat.com
Subject: Consider including ef388e2054fe ("xfs: don't allow di_size with high bit set") into stable releases
Date: Mon, 27 Mar 2017 10:43:31 +0300	[thread overview]
Message-ID: <53efcbd6-289e-3b71-3d47-73d2b06b98ba@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

Hello,


The patch in the subject applies cleanly on 4.4 and I have attached the
backport for 3.12. This causes hangs in both xfs/133 and xfs/134. As is
customary - a battery of xfstests have been run to ensure no regressions
were introduced.

Regards,
Nikolay

[-- Attachment #2: 0001-xfs-don-t-allow-di_size-with-high-bit-set.patch --]
[-- Type: text/x-patch, Size: 1454 bytes --]

>From a8581aae46a02f329fce5678a5932d99e1c188e0 Mon Sep 17 00:00:00 2001
From: "Darrick J. Wong" <darrick.wong@oracle.com>
Date: Mon, 5 Dec 2016 12:38:38 +1100
Subject: [PATCH] xfs: don't allow di_size with high bit set

The on-disk field di_size is used to set i_size, which is a signed
integer of loff_t.  If the high bit of di_size is set, we'll end up with
a negative i_size, which will cause all sorts of problems.  Since the
VFS won't let us create a file with such length, we should catch them
here in the verifier too.

[nborisov: Backported to 3.12]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/xfs/xfs_inode_buf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/xfs/xfs_inode_buf.c b/fs/xfs/xfs_inode_buf.c
index 4b1447b3a9e4..8cc193ab434a 100644
--- a/fs/xfs/xfs_inode_buf.c
+++ b/fs/xfs/xfs_inode_buf.c
@@ -301,6 +301,14 @@ xfs_dinode_verify(
 	if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC))
 		return false;
 
+	/* don't allow invalid i_size */
+	if (be64_to_cpu(dip->di_size) & (1ULL << 63))
+		return false;
+
+	/* No zero-length symlinks. */
+	if (S_ISLNK(be16_to_cpu(dip->di_mode)) && dip->di_size == 0)
+		return false;
+
 	/* only version 3 or greater inodes are extensively verified here */
 	if (dip->di_version < 3)
 		return true;
-- 
2.7.4


             reply	other threads:[~2017-03-27  7:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27  7:43 Nikolay Borisov [this message]
2017-03-27  8:18 ` Consider including ef388e2054fe ("xfs: don't allow di_size with high bit set") into stable releases Jiri Slaby

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=53efcbd6-289e-3b71-3d47-73d2b06b98ba@gmail.com \
    --to=n.borisov.lkml@gmail.com \
    --cc=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=stable@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).