From patchwork Fri Aug 24 09:02:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10574921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E71F17DF for ; Fri, 24 Aug 2018 09:01:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D58FA2C7E5 for ; Fri, 24 Aug 2018 09:01:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D39E82C900; Fri, 24 Aug 2018 09:01:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DAEE2C8D0 for ; Fri, 24 Aug 2018 09:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727019AbeHXMen (ORCPT ); Fri, 24 Aug 2018 08:34:43 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:50759 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726872AbeHXMen (ORCPT ); Fri, 24 Aug 2018 08:34:43 -0400 Received: by mail-wm0-f66.google.com with SMTP id s12-v6so881649wmc.0; Fri, 24 Aug 2018 02:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=3QE78XclAPczCMP8Xo3CswOIIvhitEsb3WdAX9tJU6c=; b=lNmE3Bhb7aZUz1GXSE5y/4NqYdKAWQ53aQvptjWcC7S/6NigivHqeJD3d4rk6hx9tD hW+GN3iEJOQ4MqBbZGIodgIJTxgzxM5MP3bJnY1/ZgQ46aFVkwi3h3TWYCd97KZDz4nk PgYeywmE3+wMM/yFncpfah7cYtUTFviBE5EODHtqGToeumfzJabQehRpVMmnJ3ptX02V JFRXyVq5IdimSWrzbtjSNc6Ant++LLlISe96LFap7hCqN/szj9leEJ8uAejPNqZU7hcM hGi/qzTXiB882JjXAr8JaRLfd+VEoE8PZ7CH6T99lk6JSeZGlfCUHJX7Gx6Ol8T8T0SI /Sdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3QE78XclAPczCMP8Xo3CswOIIvhitEsb3WdAX9tJU6c=; b=iwcMh1YJI1u0F8yrhUP23rWnbuSpCAJUhYpr3ktSR5BZj6CZOgRsMjQwZIUfLDue0y plZ7v0wcdAb9408CExVJYwfphs9zm0iNizLKDCGDVWvDFf5M0BHqfC6pj3aJ5pYJJstn wLIkQSiEJ8zCKi4a95Re/xUYxo8vz1CQCivoswTNyRA08eokVc0uhbP8untAuUjHPmSK lNQl5ktORM361w/4iA6gD0WEcl4+mzBHa1J5mhVnkOBCIA6CGQQDoD+mCpdF6m3+b7nU TgWVLEEj0wAe+mjZ5S8Ji8ycs/cWuLb1ZvPaEYjKjBMrs0ojek8ltPDc7+FcZ2TViyJo VA6g== X-Gm-Message-State: APzg51CFI9AWGgzmb+G4cZjDkjWxd5f1ddwSX2qG75EzB9WuJp4hmf+B pjEhEnOwm/tyi6M2KhPXYhQ= X-Google-Smtp-Source: ANB0VdZ+zx62G51ReF9ZDbTgKjhhBaeLN1R0r/NZ82FLEx2OF1WjSr7L6IGuHuaDwc+fIEmLlY9bDA== X-Received: by 2002:a1c:9b15:: with SMTP id d21-v6mr765650wme.45.1535101260442; Fri, 24 Aug 2018 02:01:00 -0700 (PDT) Received: from localhost.localdomain ([141.226.8.68]) by smtp.gmail.com with ESMTPSA id a6-v6sm1071059wmf.22.2018.08.24.02.00.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Aug 2018 02:00:59 -0700 (PDT) From: Amir Goldstein To: "Darrick J . Wong" , Dave Chinner Cc: Eryu Guan , Miklos Szeredi , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH] xfs: fix GPF in swapfile_activate of file from overlayfs Date: Fri, 24 Aug 2018 12:02:51 +0300 Message-Id: <1535101371-26461-1-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); }