Linux Overlay Filesystem development
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2 3/6] ovl: fix GPF in swapfile_activate of file from overlayfs over xfs
Date: Mon, 27 Aug 2018 13:43:09 +1000	[thread overview]
Message-ID: <20180827034309.GX31495@dastard> (raw)
In-Reply-To: <1535300717-26686-4-git-send-email-amir73il@gmail.com>

On Sun, Aug 26, 2018 at 07:25:14PM +0300, Amir Goldstein wrote:
> Since overlayfs implements stacked file operations, the underlying
> filesystems are not supposed to be exposed to the overlayfs file,
> whose f_inode is an overlayfs inode.
> 
> Assigning an overlayfs file to swap_file results in an attempt of xfs
> code to dereference an xfs_inode struct from an ovl_inode pointer:
> 
>  CPU: 0 PID: 2462 Comm: swapon Not tainted
>  4.18.0-xfstests-12721-g33e17876ea4e #3402
>  RIP: 0010:xfs_find_bdev_for_inode+0x23/0x2f
>  Call Trace:
>   xfs_iomap_swapfile_activate+0x1f/0x43
>   __se_sys_swapon+0xb1a/0xee9
> 
> Fix this by not assigning the real inode mapping to f_mapping, which
> will cause swapon() to return an error (-EINVAL). Although it makes
> sense not to allow setting swpafile on an overlayfs file, some users
> may depend on it, so we may need to fix this up in the future.
> 
> Keeping f_mapping pointing to overlay inode mapping will cause O_DIRECT
> open to fail. Fix this by installing ovl_aops with noop_direct_IO in
> overlay inode mapping.

Ummm - shouldn't ovl be checking the real inode's .direct_IO method
and returning status based on that? i.e. if the underlying fs
doesn't support O_DIRECT, neither should ovl...

> +const struct address_space_operations ovl_aops = {
> +	/* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO */
> +	.direct_IO		= noop_direct_IO,
> +};
> +
>  /*
>   * It is possible to stack overlayfs instance on top of another
>   * overlayfs instance as lower layer. We need to annonate the
> @@ -575,6 +580,7 @@ static void ovl_fill_inode(struct inode *inode, umode_t mode, dev_t rdev,
>  	case S_IFREG:
>  		inode->i_op = &ovl_file_inode_operations;
>  		inode->i_fop = &ovl_file_operations;
> +		inode->i_mapping->a_ops = &ovl_aops;
>  		break;

So you put an ovl interposer in the way here - it needs to pass
through *everything* to the the real inode's aops, right?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2018-08-27  3:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-26 16:25 [PATCH v2 0/6] Overlayfs stacked f_op fixes Amir Goldstein
2018-08-26 16:25 ` [PATCH v2 1/6] vfs: add helper to get "real" overlayfs file Amir Goldstein
2018-08-26 16:25 ` [PATCH v2 2/6] ovl: respect FIEMAP_FLAG_SYNC flag Amir Goldstein
2018-08-26 19:26   ` Miklos Szeredi
2018-08-27  3:38   ` Dave Chinner
2018-08-27  6:20     ` Amir Goldstein
2018-08-27 23:05       ` Dave Chinner
2018-08-26 16:25 ` [PATCH v2 3/6] ovl: fix GPF in swapfile_activate of file from overlayfs over xfs Amir Goldstein
2018-08-27  3:43   ` Dave Chinner [this message]
2018-08-27  6:34     ` Amir Goldstein
2018-08-27  9:49       ` Miklos Szeredi
2018-08-26 16:25 ` [PATCH v2 4/6] vfs: fix readahead syscall on an overlayfs file Amir Goldstein
2018-08-26 16:25 ` [PATCH v2 5/6] vfs: fix fadvise64 " Amir Goldstein
2018-08-26 19:30   ` Miklos Szeredi
2018-08-26 21:23     ` Amir Goldstein
2018-08-26 16:25 ` [PATCH v2 6/6] vfs: fix sync_file_range " Amir Goldstein
2018-08-26 19:34   ` Miklos Szeredi
2018-08-26 21:55     ` Amir Goldstein
2018-08-27  4:23       ` Dave Chinner
2018-08-27  6:37         ` Amir Goldstein

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=20180827034309.GX31495@dastard \
    --to=david@fromorbit.com \
    --cc=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=viro@zeniv.linux.org.uk \
    /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