All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/1] xfs: online repair of symbolic links
Date: Wed, 28 Feb 2024 12:52:13 -0800	[thread overview]
Message-ID: <20240228205213.GS1927156@frogsfrogsfrogs> (raw)
In-Reply-To: <Zd-BHo96SoY4Camr@infradead.org>

On Wed, Feb 28, 2024 at 10:53:18AM -0800, Christoph Hellwig wrote:
> On Wed, Feb 28, 2024 at 10:37:40AM -0800, Darrick J. Wong wrote:
> > Going back to [1] from last year, I finally /did/ find a magic symlink
> > target that actually does trip EIO.  That solution is to set the buffer
> > contents to a string that is so long that it exceeds NAME_MAX.
> > Userspace can readlink this string, but it will never resolve anywhere
> > in the directory tree.
> > 
> > What if this unconditionally set the link target to DUMMY_TARGET instead
> > of salvaging partial targets?
> 
> Sounds good to me.

I overlooked something this morning -- if the caller passes in
XFS_SCRUB_IFLAG_FORCE_REBUILD, that might be the free space defragmenter
trying to get us to move the remote target block somewhere else.  For
that usecase, if the symlink scrub doesn't find any problems and we read
in exactly i_size bytes, I think we want to write that back to the
symlink, and not the DUMMY_TARGET.

Something like:

	if (FORCE_REBUILD && !CORRUPT) {
		if (sc->ip->i_df.if_format == XFS_DINODE_FMT_LOCAL)
			ret = xrep_symlink_salvage_inline(sc);
		else
			ret = xrep_symlink_salvage_remote(sc);
		if (ret < 0)
			return ret;

		if (ret != ip->i_disk_size)
			ret = 0;
	}

	target_buf[ret] = 0;

	/*
	 * Change an empty target into a dummy target and clear the symlink
	 * target zapped flag.
	 */
	if (target_buf[0] == 0) {
		sc->sick_mask |= XFS_SICK_INO_SYMLINK_ZAPPED;
		sprintf(target_buf, DUMMY_TARGET);
	}

Can we allow that without risking truncation making the symlink point to
some unintended place?

--D


  reply	other threads:[~2024-02-28 20:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27  2:18 [PATCHSET v29.['hch@lst.de'] 11/13] xfs: online repair of symbolic links Darrick J. Wong
2024-02-27  2:23 ` Darrick J. Wong
2024-02-27  2:32 ` [PATCH 1/1] " Darrick J. Wong
2024-02-28 17:26   ` Christoph Hellwig
2024-02-28 18:37     ` Darrick J. Wong
2024-02-28 18:53       ` Christoph Hellwig
2024-02-28 20:52         ` Darrick J. Wong [this message]
2024-02-28 22:10           ` Christoph Hellwig
2024-02-28 23:46             ` Darrick J. Wong
2024-02-29 13:25               ` Christoph Hellwig
2024-02-29 17:16                 ` Darrick J. Wong
2024-02-29 19:42                   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2024-03-27  1:49 [PATCHSET v30.1 12/15] " Darrick J. Wong
2024-03-27  2:05 ` [PATCH 1/1] " Darrick J. Wong
2024-03-27 16:53   ` Christoph Hellwig
2024-03-29 20:44     ` Darrick J. Wong
2024-03-29 20:58       ` Darrick J. Wong
2023-12-31 19:45 [PATCHSET v29.0 23/40] xfsprogs: " Darrick J. Wong
2023-12-31 22:35 ` [PATCH 1/1] xfs: " Darrick J. Wong
2023-12-31 19:31 [PATCHSET v29.0 24/28] " Darrick J. Wong
2023-12-31 20:39 ` [PATCH 1/1] " Darrick J. Wong
2023-05-26  0:36 [PATCHSET v25.0 0/1] " Darrick J. Wong
2023-05-26  1:36 ` [PATCH 1/1] " Darrick J. Wong
2022-12-30 22:14 [PATCHSET v24.0 0/1] " Darrick J. Wong
2022-12-30 22:14 ` [PATCH 1/1] " Darrick J. Wong

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=20240228205213.GS1927156@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=hch@infradead.org \
    --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 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.