linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: fix GPF in swapfile_activate of file from overlayfs
@ 2018-08-24  9:02 Amir Goldstein
  2018-08-24 23:39 ` Dave Chinner
  0 siblings, 1 reply; 8+ messages in thread
From: Amir Goldstein @ 2018-08-24  9:02 UTC (permalink / raw)
  To: Darrick J . Wong, Dave Chinner
  Cc: Eryu Guan, Miklos Szeredi, linux-xfs, linux-fsdevel

Since overlayfs implements stacked file operations, f_inode
is no longer euqivalent to f_mapping->host and xfs should use
the latter, same as generic_swapfile_activate().

Using f_inode results in an attempt 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

Fixes: d1d04ef8572b ("ovl: stack file ops")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Darrick/Dave,

Running "./check -overlay" on master crashes kernel on swap tests.
Please send this fix for rc1/rc2 or ack it so Miklos could apply it.

Thanks,
Amir.

 fs/xfs/xfs_aops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 49f5f5896a43..09f093f89b19 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -1012,7 +1012,7 @@ xfs_iomap_swapfile_activate(
 	struct file			*swap_file,
 	sector_t			*span)
 {
-	sis->bdev = xfs_find_bdev_for_inode(file_inode(swap_file));
+	sis->bdev = xfs_find_bdev_for_inode(swap_file->f_mapping->host);
 	return iomap_swapfile_activate(sis, swap_file, span, &xfs_iomap_ops);
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-08-27 11:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-24  9:02 [PATCH] xfs: fix GPF in swapfile_activate of file from overlayfs Amir Goldstein
2018-08-24 23:39 ` Dave Chinner
2018-08-25 10:47   ` Amir Goldstein
2018-08-25 20:04     ` Miklos Szeredi
2018-08-26 11:32       ` Amir Goldstein
2018-08-26 22:59         ` Dave Chinner
2018-08-27  7:17           ` Amir Goldstein
2018-08-26 22:52     ` Dave Chinner

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).