All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@redhat.com, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 2/7] xfs_repair: fix symlink target length checks by changing MAXPATHLEN to XFS_SYMLINK_MAXLEN
Date: Mon, 31 Jul 2017 14:07:01 -0700	[thread overview]
Message-ID: <150153522140.26081.14216937967974288340.stgit@magnolia> (raw)
In-Reply-To: <150153520589.26081.8786864874176090813.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

XFS has a maximum symlink target length of 1024 bytes; this is a
holdover from the Irix days.  Unfortunately, the constant establishing
this was 'MAXPATHLEN', and is /not/ the same as the Linux MAXPATHLEN,
which is 4096.

The kernel enforces its 1024 byte MAXPATHLEN on symlink targets, but
xfsprogs picks up the (Linux) system 4096 byte MAXPATHLEN, which means
that xfs_repair doesn't complain about oversized symlinks.

Since this is an on-disk format constraint, put the define in the XFS
namespace.  As a side effect of the rename, xfs_repair wil detect
oversized symlinks and clean them off the system.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 repair/dinode.c     |    6 +++---
 repair/xfs_repair.c |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/repair/dinode.c b/repair/dinode.c
index da87217..f005335 100644
--- a/repair/dinode.c
+++ b/repair/dinode.c
@@ -1259,7 +1259,7 @@ null_check(char *name, int length)
 {
 	int i;
 
-	ASSERT(length < MAXPATHLEN);
+	ASSERT(length < XFS_SYMLINK_MAXLEN);
 
 	for (i = 0; i < length; i++, name++)  {
 		if (*name == '\0')
@@ -1371,7 +1371,7 @@ process_symlink(
 	blkmap_t 	*blkmap)
 {
 	char			*symlink;
-	char			data[MAXPATHLEN];
+	char			data[XFS_SYMLINK_MAXLEN];
 
 	/*
 	 * check size against kernel symlink limits.  we know
@@ -1379,7 +1379,7 @@ process_symlink(
 	 * the inode is structurally ok so we don't have to check
 	 * for that
 	 */
-	if (be64_to_cpu(dino->di_size) >= MAXPATHLEN)  {
+	if (be64_to_cpu(dino->di_size) >= XFS_SYMLINK_MAXLEN)  {
 	       do_warn(_("symlink in inode %" PRIu64 " too long (%llu chars)\n"),
 		       lino, (unsigned long long) be64_to_cpu(dino->di_size));
 		return(1);
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index ab60c0f..b2dd91b 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -761,7 +761,7 @@ main(int argc, char **argv)
 	glob_agcount = mp->m_sb.sb_agcount;
 
 	chunks_pblock = mp->m_sb.sb_inopblock / XFS_INODES_PER_CHUNK;
-	max_symlink_blocks = libxfs_symlink_blocks(mp, MAXPATHLEN);
+	max_symlink_blocks = libxfs_symlink_blocks(mp, XFS_SYMLINK_MAXLEN);
 	inodes_per_cluster = MAX(mp->m_sb.sb_inopblock,
 			mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog);
 


  parent reply	other threads:[~2017-07-31 21:07 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-31 21:06 [PATCH 0/7] xfsprogs: 4.13 rollup Darrick J. Wong
2017-07-31 21:06 ` [PATCH 1/7] xfs: remove double-underscore integer types Darrick J. Wong
2017-07-31 21:23   ` Eric Sandeen
2017-07-31 21:25     ` Darrick J. Wong
2017-08-02  9:13   ` Carlos Maiolino
2017-08-02 16:01     ` Darrick J. Wong
2017-07-31 21:07 ` Darrick J. Wong [this message]
2017-07-31 21:42   ` [PATCH 2/7] xfs_repair: fix symlink target length checks by changing MAXPATHLEN to XFS_SYMLINK_MAXLEN Eric Sandeen
2017-08-02  9:14   ` Carlos Maiolino
2017-07-31 21:07 ` [PATCH 3/7] xfs_db: fix metadump redirection (again) Darrick J. Wong
2017-07-31 21:57   ` Eric Sandeen
2017-08-01 16:23   ` [PATCH v2 " Darrick J. Wong
2017-08-02  9:17     ` Carlos Maiolino
2017-07-31 21:07 ` [PATCH 4/7] xfs_db: dump dir/attr btrees Darrick J. Wong
2017-07-31 22:05   ` Eric Sandeen
2017-08-01 14:59     ` Darrick J. Wong
2017-08-01 15:40   ` [PATCH v2 " Darrick J. Wong
2017-08-01 16:21     ` Eric Sandeen
2017-08-02  9:22     ` Carlos Maiolino
2017-08-02  9:24     ` Carlos Maiolino
2017-08-02 16:03       ` Darrick J. Wong
2017-07-31 21:07 ` [PATCH 5/7] xfs_db: print attribute remote value blocks Darrick J. Wong
2017-08-01 17:15   ` Eric Sandeen
2017-08-01 20:29     ` Darrick J. Wong
2017-08-01 21:04   ` [PATCH v2 " Darrick J. Wong
2017-08-02  9:36     ` Carlos Maiolino
2017-07-31 21:07 ` [PATCH 6/7] xfs_db: write values into dir/attr blocks and recalculate CRCs Darrick J. Wong
2017-08-02  9:40   ` Carlos Maiolino
2017-08-03 16:02   ` Eric Sandeen
2017-08-03 16:40     ` Darrick J. Wong
2017-07-31 21:07 ` [PATCH 7/7] xfs_db: introduce fuzz command Darrick J. Wong
2017-08-02 11:06   ` Carlos Maiolino
2017-08-03 16:47   ` [PATCH 8/7] xfs_db: use TYP_F_CRC_FUNC for inodes & dquots Eric Sandeen
2017-08-03 16:58     ` Darrick J. Wong
2017-08-03 17:15     ` [PATCH 8/7 V2] " Eric Sandeen
2017-08-03 18:05       ` Darrick J. Wong
2017-08-03 17:04 ` [PATCH 9/7] xfs_db: btdump should avoid eval for push and pop of cursor Darrick J. Wong
2017-08-03 17:18   ` Eric Sandeen

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=150153522140.26081.14216937967974288340.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.