tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 5c92ddca1053df02387e8006d06094e18cc8538a commit: 0d19f3d71394b0b03b8775c958b3354fa2259609 [7355/7594] fs/ntfs3: Add system.ntfs_attrib_be extended attribute config: mips-randconfig-s051-20221114 compiler: mips-linux-gcc (GCC) 12.1.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-39-gce1a6720-dirty # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=0d19f3d71394b0b03b8775c958b3354fa2259609 git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git fetch --no-tags linux-next master git checkout 0d19f3d71394b0b03b8775c958b3354fa2259609 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=mips SHELL=/bin/bash fs/ntfs3/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) >> fs/ntfs3/xattr.c:811:48: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] @@ got restricted __be32 [usertype] @@ fs/ntfs3/xattr.c:811:48: sparse: expected unsigned int [usertype] fs/ntfs3/xattr.c:811:48: sparse: got restricted __be32 [usertype] >> fs/ntfs3/xattr.c:901:34: sparse: sparse: cast to restricted __be32 vim +811 fs/ntfs3/xattr.c 778 779 static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de, 780 struct inode *inode, const char *name, void *buffer, 781 size_t size) 782 { 783 int err; 784 struct ntfs_inode *ni = ntfs_i(inode); 785 786 /* Dispatch request. */ 787 if (!strcmp(name, SYSTEM_DOS_ATTRIB)) { 788 /* system.dos_attrib */ 789 if (!buffer) { 790 err = sizeof(u8); 791 } else if (size < sizeof(u8)) { 792 err = -ENODATA; 793 } else { 794 err = sizeof(u8); 795 *(u8 *)buffer = le32_to_cpu(ni->std_fa); 796 } 797 goto out; 798 } 799 800 if (!strcmp(name, SYSTEM_NTFS_ATTRIB) || 801 !strcmp(name, SYSTEM_NTFS_ATTRIB_BE)) { 802 /* system.ntfs_attrib */ 803 if (!buffer) { 804 err = sizeof(u32); 805 } else if (size < sizeof(u32)) { 806 err = -ENODATA; 807 } else { 808 err = sizeof(u32); 809 *(u32 *)buffer = le32_to_cpu(ni->std_fa); 810 if (!strcmp(name, SYSTEM_NTFS_ATTRIB_BE)) > 811 *(u32 *)buffer = cpu_to_be32(*(u32 *)buffer); 812 } 813 goto out; 814 } 815 816 if (!strcmp(name, SYSTEM_NTFS_SECURITY)) { 817 /* system.ntfs_security*/ 818 struct SECURITY_DESCRIPTOR_RELATIVE *sd = NULL; 819 size_t sd_size = 0; 820 821 if (!is_ntfs3(ni->mi.sbi)) { 822 /* We should get nt4 security. */ 823 err = -EINVAL; 824 goto out; 825 } else if (le32_to_cpu(ni->std_security_id) < 826 SECURITY_ID_FIRST) { 827 err = -ENOENT; 828 goto out; 829 } 830 831 err = ntfs_get_security_by_id(ni->mi.sbi, ni->std_security_id, 832 &sd, &sd_size); 833 if (err) 834 goto out; 835 836 if (!is_sd_valid(sd, sd_size)) { 837 ntfs_inode_warn( 838 inode, 839 "looks like you get incorrect security descriptor id=%u", 840 ni->std_security_id); 841 } 842 843 if (!buffer) { 844 err = sd_size; 845 } else if (size < sd_size) { 846 err = -ENODATA; 847 } else { 848 err = sd_size; 849 memcpy(buffer, sd, sd_size); 850 } 851 kfree(sd); 852 goto out; 853 } 854 855 #ifdef CONFIG_NTFS3_FS_POSIX_ACL 856 if (!strcmp(name, XATTR_NAME_POSIX_ACL_ACCESS) || 857 !strcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT)) { 858 /* TODO: init_user_ns? */ 859 err = ntfs_xattr_get_acl( 860 &init_user_ns, inode, 861 strlen(name) == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 862 ? ACL_TYPE_ACCESS 863 : ACL_TYPE_DEFAULT, 864 buffer, size); 865 goto out; 866 } 867 #endif 868 /* Deal with NTFS extended attribute. */ 869 err = ntfs_get_ea(inode, name, strlen(name), buffer, size, NULL); 870 871 out: 872 return err; 873 } 874 875 /* 876 * ntfs_setxattr - inode_operations::setxattr 877 */ 878 static noinline int ntfs_setxattr(const struct xattr_handler *handler, 879 struct user_namespace *mnt_userns, 880 struct dentry *de, struct inode *inode, 881 const char *name, const void *value, 882 size_t size, int flags) 883 { 884 int err = -EINVAL; 885 struct ntfs_inode *ni = ntfs_i(inode); 886 enum FILE_ATTRIBUTE new_fa; 887 888 /* Dispatch request. */ 889 if (!strcmp(name, SYSTEM_DOS_ATTRIB)) { 890 if (sizeof(u8) != size) 891 goto out; 892 new_fa = cpu_to_le32(*(u8 *)value); 893 goto set_new_fa; 894 } 895 896 if (!strcmp(name, SYSTEM_NTFS_ATTRIB) || 897 !strcmp(name, SYSTEM_NTFS_ATTRIB_BE)) { 898 if (size != sizeof(u32)) 899 goto out; 900 if (!strcmp(name, SYSTEM_NTFS_ATTRIB_BE)) > 901 new_fa = cpu_to_le32(be32_to_cpu(*(u32 *)value)); 902 else 903 new_fa = cpu_to_le32(*(u32 *)value); 904 905 if (S_ISREG(inode->i_mode)) { 906 /* Process compressed/sparsed in special way. */ 907 ni_lock(ni); 908 err = ni_new_attr_flags(ni, new_fa); 909 ni_unlock(ni); 910 if (err) 911 goto out; 912 } 913 set_new_fa: 914 /* 915 * Thanks Mark Harmstone: 916 * Keep directory bit consistency. 917 */ 918 if (S_ISDIR(inode->i_mode)) 919 new_fa |= FILE_ATTRIBUTE_DIRECTORY; 920 else 921 new_fa &= ~FILE_ATTRIBUTE_DIRECTORY; 922 923 if (ni->std_fa != new_fa) { 924 ni->std_fa = new_fa; 925 if (new_fa & FILE_ATTRIBUTE_READONLY) 926 inode->i_mode &= ~0222; 927 else 928 inode->i_mode |= 0222; 929 /* Std attribute always in primary record. */ 930 ni->mi.dirty = true; 931 mark_inode_dirty(inode); 932 } 933 err = 0; 934 935 goto out; 936 } 937 938 if (!strcmp(name, SYSTEM_NTFS_SECURITY)) { 939 /* system.ntfs_security*/ 940 __le32 security_id; 941 bool inserted; 942 struct ATTR_STD_INFO5 *std; 943 944 if (!is_ntfs3(ni->mi.sbi)) { 945 /* 946 * We should replace ATTR_SECURE. 947 * Skip this way cause it is nt4 feature. 948 */ 949 err = -EINVAL; 950 goto out; 951 } 952 953 if (!is_sd_valid(value, size)) { 954 err = -EINVAL; 955 ntfs_inode_warn( 956 inode, 957 "you try to set invalid security descriptor"); 958 goto out; 959 } 960 961 err = ntfs_insert_security(ni->mi.sbi, value, size, 962 &security_id, &inserted); 963 if (err) 964 goto out; 965 966 ni_lock(ni); 967 std = ni_std5(ni); 968 if (!std) { 969 err = -EINVAL; 970 } else if (std->security_id != security_id) { 971 std->security_id = ni->std_security_id = security_id; 972 /* Std attribute always in primary record. */ 973 ni->mi.dirty = true; 974 mark_inode_dirty(&ni->vfs_inode); 975 } 976 ni_unlock(ni); 977 goto out; 978 } 979 -- 0-DAY CI Kernel Test Service https://01.org/lkp