ntfs: Fix ntfs_test_inode and ntfs_init_locked_inode function type
PATCH v2 1/1 ntfs: Fix ntfs_test_inode and ntfs_init_locked_inode function type
In reply to a message not in the archiveIf 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 <[email protected]>
Tested-by freak07 <[email protected]>
---
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(-)
fs/ntfs/dir.c +1 -1
@@ -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);
fs/ntfs/inode.c +12 -11
@@ -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 );
fs/ntfs/inode.h +1 -3
@@ -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,
fs/ntfs/mft.c +2 -2
@@ -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) {/*
Signature · 1 line
2.26.0
PATCH v2 1/1 ntfs: Fix ntfs_test_inode and ntfs_init_locked_inode function type
In reply to a message not in the archiveIf 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 <[email protected]>
Tested-by freak07 <[email protected]>
--- fs/ntfs/dir.c | 2 +- fs/ntfs/inode.c | 23 ++++++++++++----------- fs/ntfs/inode.h | 4 +--- fs/ntfs/mft.c | 5 ++--- 4 files changed, 16 insertions(+), 18 deletions(-)
fs/ntfs/dir.c +1 -1
@@ -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);
fs/ntfs/inode.c +12 -11
@@ -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 = 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 = 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 );
fs/ntfs/inode.h +1 -3
@@ -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,
fs/ntfs/mft.c +2 -3
@@ -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,8 +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, - &na); + vi =ilookup5_nowait (sb, na.mft_no, ntfs_test_inode, &na);if (!vi) {/* * The base inode is not in icache, write this extent mft
Signature · 1 line
2.26.0
PATCH 1/1 ntfs: Fix ntfs_test_inode and ntfs_init_locked_inode function type
In reply to Luca StefaniIf 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 <[email protected]>
Tested-by freak07 <[email protected]>
--- fs/ntfs/dir.c | 2 +- fs/ntfs/inode.c | 23 ++++++++++++----------- fs/ntfs/inode.h | 4 +--- fs/ntfs/mft.c | 5 ++--- 4 files changed, 16 insertions(+), 18 deletions(-)
fs/ntfs/dir.c +1 -1
@@ -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);
fs/ntfs/inode.c +12 -11
@@ -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 = 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 = 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 );
fs/ntfs/inode.h +1 -3
@@ -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,
fs/ntfs/mft.c +2 -3
@@ -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,8 +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, - &na); + vi =ilookup5_nowait (sb, na.mft_no, ntfs_test_inode, &na);if (!vi) {/* * The base inode is not in icache, write this extent mft
Signature · 1 line
2.27.0