ni_fname_name called ntfs_cmp_names_cpu which assumes that the first
string is in CPU byte order and the second one in little endian.
In this case both strings are little endian so ntfs_cmp_names is the
correct function to call.
Signed-off-by: Thomas Kühnel <[email protected]>
Reviewed-by: Nicolas Schier <[email protected]>
---
fs/ntfs3/frecord.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 6f47a9c17f89..f3afdc91af76 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -1588,6 +1588,7 @@ struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni,
{
struct ATTRIB *attr = NULL;
struct ATTR_FILE_NAME *fname;
+ struct le_str *fns;
*le = NULL;
@@ -1610,7 +1611,8 @@ struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni,
if (uni->len != fname->name_len)
goto next;
- if (ntfs_cmp_names_cpu(uni, (struct le_str *)&fname->name_len, NULL,
+ fns = (struct le_str *)&fname->name_len;
+ if (ntfs_cmp_names(uni->name, uni->len, fns->name, fns->len, NULL,
false))
goto next;
--
2.25.1
Hi "Thomas,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on 0fcfb00b28c0b7884635dacf38e46d60bf3d4eb1]
url: https://github.com/0day-ci/linux/commits/Thomas-K-hnel/fs-ntfs3-Fixes-for-big-endian-systems/20211207-184206
base: 0fcfb00b28c0b7884635dacf38e46d60bf3d4eb1
config: arm64-randconfig-s031-20211207 (https://download.01.org/0day-ci/archive/20211207/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/d2fb837ced1828c5a57feac3690d3cc8a36b2fdc
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Thomas-K-hnel/fs-ntfs3-Fixes-for-big-endian-systems/20211207-184206
git checkout d2fb837ced1828c5a57feac3690d3cc8a36b2fdc
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm64 SHELL=/bin/bash fs/ntfs3/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
sparse warnings: (new ones prefixed by >>)
>> fs/ntfs3/frecord.c:1615:28: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected restricted __le16 const [usertype] *s1 @@ got unsigned short const * @@
fs/ntfs3/frecord.c:1615:28: sparse: expected restricted __le16 const [usertype] *s1
fs/ntfs3/frecord.c:1615:28: sparse: got unsigned short const *
vim +1615 fs/ntfs3/frecord.c
1578
1579 /* ni_fname_name
1580 *
1581 * Return: File name attribute by its value.
1582 */
1583 struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni,
1584 const struct cpu_str *uni,
1585 const struct MFT_REF *home_dir,
1586 struct mft_inode **mi,
1587 struct ATTR_LIST_ENTRY **le)
1588 {
1589 struct ATTRIB *attr = NULL;
1590 struct ATTR_FILE_NAME *fname;
1591 struct le_str *fns;
1592
1593 *le = NULL;
1594
1595 /* Enumerate all names. */
1596 next:
1597 attr = ni_find_attr(ni, attr, le, ATTR_NAME, NULL, 0, NULL, mi);
1598 if (!attr)
1599 return NULL;
1600
1601 fname = resident_data_ex(attr, SIZEOF_ATTRIBUTE_FILENAME);
1602 if (!fname)
1603 goto next;
1604
1605 if (home_dir && memcmp(home_dir, &fname->home, sizeof(*home_dir)))
1606 goto next;
1607
1608 if (!uni)
1609 goto next;
1610
1611 if (uni->len != fname->name_len)
1612 goto next;
1613
1614 fns = (struct le_str *)&fname->name_len;
> 1615 if (ntfs_cmp_names(uni->name, uni->len, fns->name, fns->len, NULL,
1616 false))
1617 goto next;
1618
1619 return fname;
1620 }
1621
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
On 07.12.21 17:00, kernel test robot wrote:
> Hi "Thomas,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on 0fcfb00b28c0b7884635dacf38e46d60bf3d4eb1]
>
> url: https://github.com/0day-ci/linux/commits/Thomas-K-hnel/fs-ntfs3-Fixes-for-big-endian-systems/20211207-184206
> base: 0fcfb00b28c0b7884635dacf38e46d60bf3d4eb1
> config: arm64-randconfig-s031-20211207 (https://download.01.org/0day-ci/archive/20211207/[email protected]/config)
> compiler: aarch64-linux-gcc (GCC) 11.2.0
> reproduce:
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # apt-get install sparse
> # sparse version: v0.6.4-dirty
> # https://github.com/0day-ci/linux/commit/d2fb837ced1828c5a57feac3690d3cc8a36b2fdc
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Thomas-K-hnel/fs-ntfs3-Fixes-for-big-endian-systems/20211207-184206
> git checkout d2fb837ced1828c5a57feac3690d3cc8a36b2fdc
> # save the config file to linux build tree
> mkdir build_dir
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm64 SHELL=/bin/bash fs/ntfs3/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <[email protected]>
>
>
> sparse warnings: (new ones prefixed by >>)
>>> fs/ntfs3/frecord.c:1615:28: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected restricted __le16 const [usertype] *s1 @@ got unsigned short const * @@
> fs/ntfs3/frecord.c:1615:28: sparse: expected restricted __le16 const [usertype] *s1
> fs/ntfs3/frecord.c:1615:28: sparse: got unsigned short const *
>
> vim +1615 fs/ntfs3/frecord.c
>
> 1578
> 1579 /* ni_fname_name
> 1580 *
> 1581 * Return: File name attribute by its value.
> 1582 */
> 1583 struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni,
> 1584 const struct cpu_str *uni,
Changing the type of uni to struct le_str * should fix the warning.
I'll change this in the next version of this patch.
> 1585 const struct MFT_REF *home_dir,
> 1586 struct mft_inode **mi,
> 1587 struct ATTR_LIST_ENTRY **le)
> 1588 {
> 1589 struct ATTRIB *attr = NULL;
> 1590 struct ATTR_FILE_NAME *fname;
> 1591 struct le_str *fns;
> 1592
> 1593 *le = NULL;
> 1594
> 1595 /* Enumerate all names. */
> 1596 next:
> 1597 attr = ni_find_attr(ni, attr, le, ATTR_NAME, NULL, 0, NULL, mi);
> 1598 if (!attr)
> 1599 return NULL;
> 1600
> 1601 fname = resident_data_ex(attr, SIZEOF_ATTRIBUTE_FILENAME);
> 1602 if (!fname)
> 1603 goto next;
> 1604
> 1605 if (home_dir && memcmp(home_dir, &fname->home, sizeof(*home_dir)))
> 1606 goto next;
> 1607
> 1608 if (!uni)
> 1609 goto next;
> 1610
> 1611 if (uni->len != fname->name_len)
> 1612 goto next;
> 1613
> 1614 fns = (struct le_str *)&fname->name_len;
>> 1615 if (ntfs_cmp_names(uni->name, uni->len, fns->name, fns->len, NULL,
> 1616 false))
> 1617 goto next;
> 1618
> 1619 return fname;
> 1620 }
> 1621
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/[email protected]
>