:::::: :::::: Manual check reason: "low confidence static check warning: arch/x86/kernel/fpu/xstate.c:1785:3: warning: Value stored to 'guest' is never read [clang-analyzer-deadcode.DeadStores]" :::::: BCC: lkp@intel.com CC: llvm@lists.linux.dev CC: oe-kbuild-all@lists.linux.dev CC: linux-kernel@vger.kernel.org TO: Thomas Gleixner CC: Paolo Bonzini CC: Jing Liu CC: Yang Zhong tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: a4412fdd49dc011bcc2c0d81ac4cab7457092650 commit: 980fe2fddcff21937c93532b4597c8ea450346c1 x86/fpu: Extend fpu_xstate_prctl() with guest permissions date: 11 months ago :::::: branch date: 14 hours ago :::::: commit date: 11 months ago config: i386-randconfig-c001-20221128 compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=980fe2fddcff21937c93532b4597c8ea450346c1 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git fetch --no-tags linus master git checkout 980fe2fddcff21937c93532b4597c8ea450346c1 # save the config file COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot clang_analyzer warnings: (new ones prefixed by >>) update_dotdot = (is_dir && old_dir != new_dir); ^ fs/fat/namei_vfat.c:922:6: note: 'update_dotdot' is 0 if (update_dotdot) { ^~~~~~~~~~~~~ fs/fat/namei_vfat.c:922:2: note: Taking false branch if (update_dotdot) { ^ fs/fat/namei_vfat.c:930:6: note: Assuming 'new_inode' is non-null if (new_inode) { ^~~~~~~~~ fs/fat/namei_vfat.c:930:2: note: Taking true branch if (new_inode) { ^ fs/fat/namei_vfat.c:931:7: note: 'is_dir' is 0 if (is_dir) { ^~~~~~ fs/fat/namei_vfat.c:931:3: note: Taking false branch if (is_dir) { ^ fs/fat/namei_vfat.c:949:6: note: Assuming the condition is true if (IS_DIRSYNC(new_dir)) { ^ include/linux/fs.h:2272:28: note: expanded from macro 'IS_DIRSYNC' #define IS_DIRSYNC(inode) (__IS_FLG(inode, SB_SYNCHRONOUS|SB_DIRSYNC) || \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/fs.h:2266:31: note: expanded from macro '__IS_FLG' #define __IS_FLG(inode, flg) ((inode)->i_sb->s_flags & (flg)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/fat/namei_vfat.c:949:6: note: Left side of '||' is true if (IS_DIRSYNC(new_dir)) { ^ include/linux/fs.h:2272:71: note: expanded from macro 'IS_DIRSYNC' #define IS_DIRSYNC(inode) (__IS_FLG(inode, SB_SYNCHRONOUS|SB_DIRSYNC) || \ ^ fs/fat/namei_vfat.c:951:7: note: Assuming 'err' is 0 if (err) ^~~ fs/fat/namei_vfat.c:951:3: note: Taking false branch if (err) ^ fs/fat/namei_vfat.c:956:6: note: 'update_dotdot' is 0 if (update_dotdot) { ^~~~~~~~~~~~~ fs/fat/namei_vfat.c:956:2: note: Taking false branch if (update_dotdot) { ^ fs/fat/namei_vfat.c:971:6: note: Assuming 'err' is not equal to 0 if (err) ^~~ fs/fat/namei_vfat.c:971:2: note: Taking true branch if (err) ^ fs/fat/namei_vfat.c:972:3: note: Control jumps to line 996 goto error_dotdot; ^ fs/fat/namei_vfat.c:998:6: note: 'update_dotdot' is 0 if (update_dotdot) { ^~~~~~~~~~~~~ fs/fat/namei_vfat.c:998:2: note: Taking false branch if (update_dotdot) { ^ fs/fat/namei_vfat.c:1006:6: note: 'new_inode' is non-null if (new_inode) { ^~~~~~~~~ fs/fat/namei_vfat.c:1006:2: note: Taking true branch if (new_inode) { ^ fs/fat/namei_vfat.c:1008:7: note: 'corrupt' is 1 if (corrupt) ^~~~~~~ fs/fat/namei_vfat.c:1008:3: note: Taking true branch if (corrupt) ^ fs/fat/namei_vfat.c:1020:6: note: Assuming 'corrupt' is < 0 if (corrupt < 0) { ^~~~~~~~~~~ fs/fat/namei_vfat.c:1020:2: note: Taking true branch if (corrupt < 0) { ^ fs/fat/namei_vfat.c:1021:3: note: 5th function call argument is an uninitialized value fat_fs_error(new_dir->i_sb, ^ fs/fat/fat.h:433:2: note: expanded from macro 'fat_fs_error' __fat_fs_error(sb, 1, fmt , ## args) ^ ~~~~ 2 warnings generated. security/keys/request_key.c:119:21: warning: Value stored to 'cred' during its initialization is never read [clang-analyzer-deadcode.DeadStores] const struct cred *cred = current_cred(); ^~~~ security/keys/request_key.c:119:21: note: Value stored to 'cred' during its initialization is never read const struct cred *cred = current_cred(); ^~~~ security/keys/request_key.c:510:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores] ret = 0; ^ ~ security/keys/request_key.c:510:3: note: Value stored to 'ret' is never read ret = 0; ^ ~ 1 warning generated. >> arch/x86/kernel/fpu/xstate.c:1785:3: warning: Value stored to 'guest' is never read [clang-analyzer-deadcode.DeadStores] guest = true; ^ ~~~~ arch/x86/kernel/fpu/xstate.c:1785:3: note: Value stored to 'guest' is never read guest = true; ^ ~~~~ 8 warnings generated. arch/x86/kernel/cpu/cacheinfo.c:764:5: warning: Value stored to 'l2_id' is never read [clang-analyzer-deadcode.DeadStores] l2_id = c->apicid & ~((1 << index_msb) - 1); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:764:5: note: Value stored to 'l2_id' is never read l2_id = c->apicid & ~((1 << index_msb) - 1); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:764:30: warning: The result of the left shift is undefined due to shifting by '4294967295', which is greater or equal to the width of type 'int' [clang-analyzer-core.UndefinedBinaryOperatorResult] l2_id = c->apicid & ~((1 << index_msb) - 1); ^ ~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:732:6: note: Assuming field 'cpuid_level' is > 3 if (c->cpuid_level > 3) { ^~~~~~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:732:2: note: Taking true branch if (c->cpuid_level > 3) { ^ arch/x86/kernel/cpu/cacheinfo.c:735:7: note: 'is_initialized' is equal to 0 if (is_initialized == 0) { ^~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:735:3: note: Taking true branch if (is_initialized == 0) { ^ arch/x86/kernel/cpu/cacheinfo.c:745:15: note: Assuming 'i' is < 'num_cache_leaves' for (i = 0; i < num_cache_leaves; i++) { ^~~~~~~~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:745:3: note: Loop condition is true. Entering loop body for (i = 0; i < num_cache_leaves; i++) { ^ arch/x86/kernel/cpu/cacheinfo.c:750:8: note: Assuming 'retval' is >= 0 if (retval < 0) ^~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:750:4: note: Taking false branch if (retval < 0) ^ arch/x86/kernel/cpu/cacheinfo.c:753:4: note: Control jumps to 'case 2:' at line 760 switch (this_leaf.eax.split.level) { ^ arch/x86/kernel/cpu/cacheinfo.c:763:17: note: Calling 'get_count_order' index_msb = get_count_order(num_threads_sharing); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/bitops.h:195:6: note: Assuming 'count' is equal to 0 if (count == 0) ^~~~~~~~~~ include/linux/bitops.h:195:2: note: Taking true branch if (count == 0) ^ include/linux/bitops.h:196:3: note: Returning the value -1 return -1; ^~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:763:17: note: Returning from 'get_count_order' index_msb = get_count_order(num_threads_sharing); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:763:5: note: The value 4294967295 is assigned to 'index_msb' index_msb = get_count_order(num_threads_sharing); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:764:30: note: The result of the left shift is undefined due to shifting by '4294967295', which is greater or equal to the width of type 'int' l2_id = c->apicid & ~((1 << index_msb) - 1); ^ ~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:770:5: warning: Value stored to 'l3_id' is never read [clang-analyzer-deadcode.DeadStores] l3_id = c->apicid & ~((1 << index_msb) - 1); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:770:5: note: Value stored to 'l3_id' is never read l3_id = c->apicid & ~((1 << index_msb) - 1); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:770:30: warning: The result of the left shift is undefined due to shifting by '4294967295', which is greater or equal to the width of type 'int' [clang-analyzer-core.UndefinedBinaryOperatorResult] l3_id = c->apicid & ~((1 << index_msb) - 1); ^ ~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:732:6: note: Assuming field 'cpuid_level' is > 3 if (c->cpuid_level > 3) { ^~~~~~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:732:2: note: Taking true branch if (c->cpuid_level > 3) { ^ arch/x86/kernel/cpu/cacheinfo.c:735:7: note: 'is_initialized' is equal to 0 if (is_initialized == 0) { ^~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:735:3: note: Taking true branch if (is_initialized == 0) { ^ arch/x86/kernel/cpu/cacheinfo.c:745:15: note: Assuming 'i' is < 'num_cache_leaves' for (i = 0; i < num_cache_leaves; i++) { ^~~~~~~~~~~~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:745:3: note: Loop condition is true. Entering loop body for (i = 0; i < num_cache_leaves; i++) { ^ arch/x86/kernel/cpu/cacheinfo.c:750:8: note: Assuming 'retval' is >= 0 if (retval < 0) ^~~~~~~~~~ arch/x86/kernel/cpu/cacheinfo.c:750:4: note: Taking false branch if (retval < 0) ^ arch/x86/kernel/cpu/cacheinfo.c:753:4: note: Control jumps to 'case 3:' at line 766 switch (this_leaf.eax.split.level) { ^ arch/x86/kernel/cpu/cacheinfo.c:769:17: note: Calling 'get_count_order' vim +/guest +1785 arch/x86/kernel/fpu/xstate.c 980fe2fddcff21 Thomas Gleixner 2022-01-05 1736 db8268df0983ad Chang S. Bae 2021-10-21 1737 /** db8268df0983ad Chang S. Bae 2021-10-21 1738 * fpu_xstate_prctl - xstate permission operations db8268df0983ad Chang S. Bae 2021-10-21 1739 * @tsk: Redundant pointer to current db8268df0983ad Chang S. Bae 2021-10-21 1740 * @option: A subfunction of arch_prctl() db8268df0983ad Chang S. Bae 2021-10-21 1741 * @arg2: option argument db8268df0983ad Chang S. Bae 2021-10-21 1742 * Return: 0 if successful; otherwise, an error code db8268df0983ad Chang S. Bae 2021-10-21 1743 * db8268df0983ad Chang S. Bae 2021-10-21 1744 * Option arguments: db8268df0983ad Chang S. Bae 2021-10-21 1745 * db8268df0983ad Chang S. Bae 2021-10-21 1746 * ARCH_GET_XCOMP_SUPP: Pointer to user space u64 to store the info db8268df0983ad Chang S. Bae 2021-10-21 1747 * ARCH_GET_XCOMP_PERM: Pointer to user space u64 to store the info db8268df0983ad Chang S. Bae 2021-10-21 1748 * ARCH_REQ_XCOMP_PERM: Facility number requested db8268df0983ad Chang S. Bae 2021-10-21 1749 * db8268df0983ad Chang S. Bae 2021-10-21 1750 * For facilities which require more than one XSTATE component, the request db8268df0983ad Chang S. Bae 2021-10-21 1751 * must be the highest state component number related to that facility, db8268df0983ad Chang S. Bae 2021-10-21 1752 * e.g. for AMX which requires XFEATURE_XTILE_CFG(17) and db8268df0983ad Chang S. Bae 2021-10-21 1753 * XFEATURE_XTILE_DATA(18) this would be XFEATURE_XTILE_DATA(18). db8268df0983ad Chang S. Bae 2021-10-21 1754 */ db8268df0983ad Chang S. Bae 2021-10-21 1755 long fpu_xstate_prctl(struct task_struct *tsk, int option, unsigned long arg2) db8268df0983ad Chang S. Bae 2021-10-21 1756 { db8268df0983ad Chang S. Bae 2021-10-21 1757 u64 __user *uptr = (u64 __user *)arg2; db8268df0983ad Chang S. Bae 2021-10-21 1758 u64 permitted, supported; db8268df0983ad Chang S. Bae 2021-10-21 1759 unsigned long idx = arg2; 980fe2fddcff21 Thomas Gleixner 2022-01-05 1760 bool guest = false; db8268df0983ad Chang S. Bae 2021-10-21 1761 db8268df0983ad Chang S. Bae 2021-10-21 1762 if (tsk != current) db8268df0983ad Chang S. Bae 2021-10-21 1763 return -EPERM; db8268df0983ad Chang S. Bae 2021-10-21 1764 db8268df0983ad Chang S. Bae 2021-10-21 1765 switch (option) { db8268df0983ad Chang S. Bae 2021-10-21 1766 case ARCH_GET_XCOMP_SUPP: db8268df0983ad Chang S. Bae 2021-10-21 1767 supported = fpu_user_cfg.max_features | fpu_user_cfg.legacy_features; db8268df0983ad Chang S. Bae 2021-10-21 1768 return put_user(supported, uptr); db8268df0983ad Chang S. Bae 2021-10-21 1769 db8268df0983ad Chang S. Bae 2021-10-21 1770 case ARCH_GET_XCOMP_PERM: db8268df0983ad Chang S. Bae 2021-10-21 1771 /* db8268df0983ad Chang S. Bae 2021-10-21 1772 * Lockless snapshot as it can also change right after the db8268df0983ad Chang S. Bae 2021-10-21 1773 * dropping the lock. db8268df0983ad Chang S. Bae 2021-10-21 1774 */ db8268df0983ad Chang S. Bae 2021-10-21 1775 permitted = xstate_get_host_group_perm(); db8268df0983ad Chang S. Bae 2021-10-21 1776 permitted &= XFEATURE_MASK_USER_SUPPORTED; db8268df0983ad Chang S. Bae 2021-10-21 1777 return put_user(permitted, uptr); db8268df0983ad Chang S. Bae 2021-10-21 1778 980fe2fddcff21 Thomas Gleixner 2022-01-05 1779 case ARCH_GET_XCOMP_GUEST_PERM: 980fe2fddcff21 Thomas Gleixner 2022-01-05 1780 permitted = xstate_get_guest_group_perm(); 980fe2fddcff21 Thomas Gleixner 2022-01-05 1781 permitted &= XFEATURE_MASK_USER_SUPPORTED; 980fe2fddcff21 Thomas Gleixner 2022-01-05 1782 return put_user(permitted, uptr); 980fe2fddcff21 Thomas Gleixner 2022-01-05 1783 980fe2fddcff21 Thomas Gleixner 2022-01-05 1784 case ARCH_REQ_XCOMP_GUEST_PERM: 980fe2fddcff21 Thomas Gleixner 2022-01-05 @1785 guest = true; 980fe2fddcff21 Thomas Gleixner 2022-01-05 1786 fallthrough; 980fe2fddcff21 Thomas Gleixner 2022-01-05 1787 db8268df0983ad Chang S. Bae 2021-10-21 1788 case ARCH_REQ_XCOMP_PERM: db8268df0983ad Chang S. Bae 2021-10-21 1789 if (!IS_ENABLED(CONFIG_X86_64)) db8268df0983ad Chang S. Bae 2021-10-21 1790 return -EOPNOTSUPP; db8268df0983ad Chang S. Bae 2021-10-21 1791 980fe2fddcff21 Thomas Gleixner 2022-01-05 1792 return xstate_request_perm(idx, guest); db8268df0983ad Chang S. Bae 2021-10-21 1793 db8268df0983ad Chang S. Bae 2021-10-21 1794 default: db8268df0983ad Chang S. Bae 2021-10-21 1795 return -EINVAL; db8268df0983ad Chang S. Bae 2021-10-21 1796 } db8268df0983ad Chang S. Bae 2021-10-21 1797 } db8268df0983ad Chang S. Bae 2021-10-21 1798 -- 0-DAY CI Kernel Test Service https://01.org/lkp