Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp590284ybz; Wed, 15 Apr 2020 14:41:00 -0700 (PDT) X-Google-Smtp-Source: APiQypJo7XeTbL0Uf2oTf6RSUYgJWuGATzkGL7y4XaUbqWQDrZyCJP4cFxCL7QDHq8f1uxQPko5C X-Received: by 2002:a17:906:6444:: with SMTP id l4mr6642707ejn.313.1586986859952; Wed, 15 Apr 2020 14:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586986859; cv=none; d=google.com; s=arc-20160816; b=jEq7sd+ndsGMrbNjH0jv8C/bSnH/W37wKjGr9wZWxBGDeAF4Dh7HdIc1IFwQWB6Sww Oz//F7G5IxKZ/e7vAZXWKVGpyE8YjM+nKBu29py34XbkJ8j0JeqCo/4E5/lIYGoTni1f KVPCt3O3xLxdGorfB43zB6b6QaEqYo7UHvyYb5Svy39K66GiJWJ2BZ3msOTk3/6t0oCk ihxh5ipXpyW6T7vgn12j4fyUGkI708oQkDv7XDNhqt+oKy8LodFQqSlhrVCCMz/6ibh3 M+wgn16ipS2Uh4QKh3qRPOclJpWA9iLyxoPSOs0ZDOly7b3Kre2k7mC7db1wzcU+h4qo r+yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=YCu8SmZlQQrvTwGnZEBEHTSKRA9LI4WZwU6LxVhIW2I=; b=DE6h42wgTcT6tkWcuqRnh9B8A0BQ0QNqc2BSKH199Ui/5QVOn94ywqsYAwIZQ4Pksl Bh2R2hW0hNDyEK5TiZ/8nh1Q0KIcFP07F4qMKMnX9N++5UsM3D1f2K2SsgSr48oBE2+K mqyUvy4PHdTxyEtoYRguDFxY4kyXT2r/MxgoCzv210OFcgpmfcqzuVdrxSVbmL+nFMVO LFTH1mJw+lB18Q2XfCg4+fPhT+PGcNEDyFohYhg5hZ5nOdrfGJEMIPK9d7BC6u/BHU0I iVV3YMt3zM/aagLITUiHvz3kZNP2n/0sxBuCQV3fTLF3CMQ+XJFfh1IzcS043ikUixTL Mh1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=hX+v2xex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o25si2116635ejh.73.2020.04.15.14.40.36; Wed, 15 Apr 2020 14:40:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=hX+v2xex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407270AbgDNPGN (ORCPT + 99 others); Tue, 14 Apr 2020 11:06:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407186AbgDNPFz (ORCPT ); Tue, 14 Apr 2020 11:05:55 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1193C061A0C for ; Tue, 14 Apr 2020 08:05:54 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id x25so13345545wmc.0 for ; Tue, 14 Apr 2020 08:05:54 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=YCu8SmZlQQrvTwGnZEBEHTSKRA9LI4WZwU6LxVhIW2I=; b=hX+v2xexC+JxczsTf+vhb6u9QmWqqrDpHDHNVBzS6+xYJkukYlaXeHNMAIkS2Lk8/r sV23hdRSmBOCGVk4yRYPpVppXxgzy6FpFSZJyPfK+b35VJBPGr3zRCv4WDvhkLpbNy6N dbh8c6IsKzWMnkFeQd+BGgH/0RGhVr1spwyb2hvTSdBf66pfHJEHOhXRbQtqdLuPcC3i 4ijIrOYZFMURcp85P1uMKJHCbW9BXJeiT8LhFf8IqSUDSBiEjcETq5nmHQUR0t016qRc 4pHJIG1yn+pxEvPL0UuCPpSYVvvOuTK6f2xl0ImHvrS7viyq0ud4jCOPbMZTm91BJXnI UXeA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=YCu8SmZlQQrvTwGnZEBEHTSKRA9LI4WZwU6LxVhIW2I=; b=Dy+QoQ99jwE0UHs2OgL3t8nf0GcVBVx/WkTyhepSrynSaS3IlS3He8ano4X4opK535 jGmAdfzMj8kCL+jvNqbxZPe881922/WPQrmU0sXHqrFKe4UFQcaYKFWEjj4V+3nEaaxx saj7FPY0MGtT4vaxx5eHx49K8iM2XXWlMLh3rj5Md1IQZ66FnDeL3YBPq8i6IqEuIYZG 3MsKWDkPK73eTOW1ML42CG59faF4Bv+o0+RHkrI+YNdT7EfZmwfeW9kEYM89VPJSRAqJ ftwc7uaxzBjChSbIRj1sH0+PKlN/89Rfg9THlmSnheKvSG6ndNVvzTHIdZO+Q/WZaUJs C9KQ== X-Gm-Message-State: AGi0Pubst79lL9zLOC4rTYxdRnO1eNgWMe9mNTXUBwK0TgTzC+Z6Qe0U Jlqhzp3cT8+dYKkAdpZxqf8= X-Received: by 2002:a1c:e203:: with SMTP id z3mr307985wmg.71.1586876753226; Tue, 14 Apr 2020 08:05:53 -0700 (PDT) Received: from luca020400-arch.lan ([2001:b07:5d33:19f:e2b6:8927:31e7:d93f]) by smtp.googlemail.com with ESMTPSA id q143sm20078133wme.31.2020.04.14.08.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 08:05:52 -0700 (PDT) From: Luca Stefani Cc: Luca Stefani , freak07 , Anton Altaparmakov , linux-ntfs-dev@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v2] ntfs: Fix ntfs_test_inode and ntfs_init_locked_inode function type Date: Tue, 14 Apr 2020 17:05:51 +0200 Message-Id: <20200414150551.625799-1-luca.stefani.ge1@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200414145903.GA11720@infradead.org> References: <20200414145903.GA11720@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the kernel is built with CFI we hit a __cfi_check_fail while mounting a partition Call trace: __cfi_check_fail+0x1c/0x24 name_to_dev_t+0x0/0x404 iget5_locked+0x594/0x5e8 ntfs_fill_super+0xbfc/0x43ec mount_bdev+0x30c/0x3cc ntfs_mount+0x18/0x24 mount_fs+0x1b0/0x380 vfs_kern_mount+0x90/0x398 do_mount+0x5d8/0x1a10 SyS_mount+0x108/0x144 el0_svc_naked+0x34/0x38 Fixing iget5_locked and ilookup5 callers seems enough Signed-off-by: Luca Stefani Tested-by: freak07 --- Changes in v2: * Addressed comments --- fs/ntfs/dir.c | 2 +- fs/ntfs/inode.c | 23 ++++++++++++----------- fs/ntfs/inode.h | 4 +--- fs/ntfs/mft.c | 4 ++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c index 3c4811469ae8..e278bfc5ee7f 100644 --- a/fs/ntfs/dir.c +++ b/fs/ntfs/dir.c @@ -1503,7 +1503,7 @@ static int ntfs_dir_fsync(struct file *filp, loff_t start, loff_t end, na.type = AT_BITMAP; na.name = I30; na.name_len = 4; - bmp_vi = ilookup5(vi->i_sb, vi->i_ino, (test_t)ntfs_test_inode, &na); + bmp_vi = ilookup5(vi->i_sb, vi->i_ino, ntfs_test_inode, &na); if (bmp_vi) { write_inode_now(bmp_vi, !datasync); iput(bmp_vi); diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index d4359a1df3d5..a5d3bebe7a85 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -30,7 +30,7 @@ /** * ntfs_test_inode - compare two (possibly fake) inodes for equality * @vi: vfs inode which to test - * @na: ntfs attribute which is being tested with + * @data: data which is being tested with * * Compare the ntfs attribute embedded in the ntfs specific part of the vfs * inode @vi for equality with the ntfs attribute @na. @@ -43,8 +43,9 @@ * NOTE: This function runs with the inode_hash_lock spin lock held so it is not * allowed to sleep. */ -int ntfs_test_inode(struct inode *vi, ntfs_attr *na) +int ntfs_test_inode(struct inode *vi, void *data) { + ntfs_attr *na = (ntfs_attr *)data; ntfs_inode *ni; if (vi->i_ino != na->mft_no) @@ -72,7 +73,7 @@ int ntfs_test_inode(struct inode *vi, ntfs_attr *na) /** * ntfs_init_locked_inode - initialize an inode * @vi: vfs inode to initialize - * @na: ntfs attribute which to initialize @vi to + * @data: data which to initialize @vi to * * Initialize the vfs inode @vi with the values from the ntfs attribute @na in * order to enable ntfs_test_inode() to do its work. @@ -87,8 +88,9 @@ int ntfs_test_inode(struct inode *vi, ntfs_attr *na) * NOTE: This function runs with the inode->i_lock spin lock held so it is not * allowed to sleep. (Hence the GFP_ATOMIC allocation.) */ -static int ntfs_init_locked_inode(struct inode *vi, ntfs_attr *na) +static int ntfs_init_locked_inode(struct inode *vi, void *data) { + ntfs_attr *na = (ntfs_attr *)data; ntfs_inode *ni = NTFS_I(vi); vi->i_ino = na->mft_no; @@ -131,7 +133,6 @@ static int ntfs_init_locked_inode(struct inode *vi, ntfs_attr *na) return 0; } -typedef int (*set_t)(struct inode *, void *); static int ntfs_read_locked_inode(struct inode *vi); static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi); static int ntfs_read_locked_index_inode(struct inode *base_vi, @@ -164,8 +165,8 @@ struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no) na.name = NULL; na.name_len = 0; - vi = iget5_locked(sb, mft_no, (test_t)ntfs_test_inode, - (set_t)ntfs_init_locked_inode, &na); + vi = iget5_locked(sb, mft_no, ntfs_test_inode, + ntfs_init_locked_inode, &na); if (unlikely(!vi)) return ERR_PTR(-ENOMEM); @@ -225,8 +226,8 @@ struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type, na.name = name; na.name_len = name_len; - vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode, - (set_t)ntfs_init_locked_inode, &na); + vi = iget5_locked(base_vi->i_sb, na.mft_no, ntfs_test_inode, + ntfs_init_locked_inode, &na); if (unlikely(!vi)) return ERR_PTR(-ENOMEM); @@ -280,8 +281,8 @@ struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name, na.name = name; na.name_len = name_len; - vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode, - (set_t)ntfs_init_locked_inode, &na); + vi = iget5_locked(base_vi->i_sb, na.mft_no, ntfs_test_inode, + ntfs_init_locked_inode, &na); if (unlikely(!vi)) return ERR_PTR(-ENOMEM); diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h index 98e670fbdd31..363e4e820673 100644 --- a/fs/ntfs/inode.h +++ b/fs/ntfs/inode.h @@ -253,9 +253,7 @@ typedef struct { ATTR_TYPE type; } ntfs_attr; -typedef int (*test_t)(struct inode *, void *); - -extern int ntfs_test_inode(struct inode *vi, ntfs_attr *na); +extern int ntfs_test_inode(struct inode *vi, void *data); extern struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no); extern struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type, diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 3aac5c917afe..58234b42d68f 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -958,7 +958,7 @@ bool ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, * dirty code path of the inode dirty code path when writing * $MFT occurs. */ - vi = ilookup5_nowait(sb, mft_no, (test_t)ntfs_test_inode, &na); + vi = ilookup5_nowait(sb, mft_no, ntfs_test_inode, &na); } if (vi) { ntfs_debug("Base inode 0x%lx is in icache.", mft_no); @@ -1019,7 +1019,7 @@ bool ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, vi = igrab(mft_vi); BUG_ON(vi != mft_vi); } else - vi = ilookup5_nowait(sb, na.mft_no, (test_t)ntfs_test_inode, + vi = ilookup5_nowait(sb, na.mft_no, ntfs_test_inode, &na); if (!vi) { /* -- 2.26.0