CC: [email protected]
CC: [email protected]
In-Reply-To: 
<6afcbd1fda5f9c7c24f320d26a98188c727ceec3.1639623751.git.baolin.w...@linux.alibaba.com>
References: 
<6afcbd1fda5f9c7c24f320d26a98188c727ceec3.1639623751.git.baolin.w...@linux.alibaba.com>
TO: Baolin Wang <[email protected]>

Hi Baolin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on hnaz-mm/master]

url:    
https://github.com/0day-ci/linux/commits/Baolin-Wang/mm-damon-Add-access-checking-for-hugetlb-pages/20211216-183925
base:   https://github.com/hnaz/linux-mm master
:::::: branch date: 13 days ago
:::::: commit date: 13 days ago
config: riscv-randconfig-c006-20211228 
(https://download.01.org/0day-ci/archive/20211229/[email protected]/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 
7171af744543433ac75b232eb7dfdaef7efd4d7a)
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
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # 
https://github.com/0day-ci/linux/commit/468a013161dfcf6a8631ea645ea9e1ec461d7c59
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review 
Baolin-Wang/mm-damon-Add-access-checking-for-hugetlb-pages/20211216-183925
        git checkout 468a013161dfcf6a8631ea645ea9e1ec461d7c59
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
   drivers/mtd/ubi/build.c:643:7: note: Calling 'is_power_of_2'
           if (!is_power_of_2(ubi->min_io_size)) {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/log2.h:47:10: note: Assuming 'n' is not equal to 0
           return (n != 0 && ((n & (n - 1)) == 0));
                   ^~~~~~
   include/linux/log2.h:47:10: note: Left side of '&&' is true
   include/linux/log2.h:47:21: note: Assuming the condition is true
           return (n != 0 && ((n & (n - 1)) == 0));
                              ^~~~~~~~~~~~~~~~~~
   include/linux/log2.h:47:2: note: Returning the value 1, which participates 
in a condition later
           return (n != 0 && ((n & (n - 1)) == 0));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/mtd/ubi/build.c:643:7: note: Returning from 'is_power_of_2'
           if (!is_power_of_2(ubi->min_io_size)) {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/mtd/ubi/build.c:643:2: note: Taking false branch
           if (!is_power_of_2(ubi->min_io_size)) {
           ^
   drivers/mtd/ubi/build.c:649:13: note: Assuming field 'hdrs_min_io_size' is 
<= 0
           ubi_assert(ubi->hdrs_min_io_size > 0);
                      ^
   drivers/mtd/ubi/debug.h:18:17: note: expanded from macro 'ubi_assert'
           if (unlikely(!(expr))) {                                             
\
                          ^~~~
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   drivers/mtd/ubi/build.c:649:2: note: Taking true branch
           ubi_assert(ubi->hdrs_min_io_size > 0);
           ^
   drivers/mtd/ubi/debug.h:18:2: note: expanded from macro 'ubi_assert'
           if (unlikely(!(expr))) {                                             
\
           ^
   drivers/mtd/ubi/build.c:649:2: note: Loop condition is false.  Exiting loop
           ubi_assert(ubi->hdrs_min_io_size > 0);
           ^
   drivers/mtd/ubi/debug.h:19:3: note: expanded from macro 'ubi_assert'
                   pr_crit("UBI assert failed in %s at %u (pid %d)\n",          
\
                   ^
   include/linux/printk.h:479:2: note: expanded from macro 'pr_crit'
           printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
           ^
   include/linux/printk.h:446:26: note: expanded from macro 'printk'
   #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
                            ^
   include/linux/printk.h:417:3: note: expanded from macro 'printk_index_wrap'
                   __printk_index_emit(_fmt, NULL, NULL);                  \
                   ^
   include/linux/printk.h:392:34: note: expanded from macro 
'__printk_index_emit'
   #define __printk_index_emit(...) do {} while (0)
                                    ^
   drivers/mtd/ubi/build.c:649:2: note: Loop condition is false.  Exiting loop
           ubi_assert(ubi->hdrs_min_io_size > 0);
           ^
   drivers/mtd/ubi/debug.h:17:27: note: expanded from macro 'ubi_assert'
   #define ubi_assert(expr)  do {                                               
\
                             ^
   drivers/mtd/ubi/build.c:650:18: note: Field 'hdrs_min_io_size' is <= field 
'min_io_size'
           ubi_assert(ubi->hdrs_min_io_size <= ubi->min_io_size);
                           ^
   drivers/mtd/ubi/build.c:650:2: note: Taking false branch
           ubi_assert(ubi->hdrs_min_io_size <= ubi->min_io_size);
           ^
   drivers/mtd/ubi/debug.h:18:2: note: expanded from macro 'ubi_assert'
           if (unlikely(!(expr))) {                                             
\
           ^
   drivers/mtd/ubi/build.c:650:2: note: Loop condition is false.  Exiting loop
           ubi_assert(ubi->hdrs_min_io_size <= ubi->min_io_size);
           ^
   drivers/mtd/ubi/debug.h:17:27: note: expanded from macro 'ubi_assert'
   #define ubi_assert(expr)  do {                                               
\
                             ^
   drivers/mtd/ubi/build.c:651:30: note: Division by zero
           ubi_assert(ubi->min_io_size % ubi->hdrs_min_io_size == 0);
                                       ^
   drivers/mtd/ubi/debug.h:18:17: note: expanded from macro 'ubi_assert'
           if (unlikely(!(expr))) {                                             
\
                          ^~~~
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   drivers/mtd/ubi/build.c:1401:2: warning: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(buf, val);
           ^~~~~~
   drivers/mtd/ubi/build.c:1401:2: note: Call to function 'strcpy' is insecure 
as it does not provide bounding of the memory buffer. Replace unbounded copy 
functions with analogous functions that support length arguments such as 
'strlcpy'. CWE-119
           strcpy(buf, val);
           ^~~~~~
   drivers/mtd/ubi/build.c:1416:2: warning: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(&p->name[0], tokens[0]);
           ^~~~~~
   drivers/mtd/ubi/build.c:1416:2: note: Call to function 'strcpy' is insecure 
as it does not provide bounding of the memory buffer. Replace unbounded copy 
functions with analogous functions that support length arguments such as 
'strlcpy'. CWE-119
           strcpy(&p->name[0], tokens[0]);
           ^~~~~~
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   5 warnings generated.
>> mm/damon/vaddr.c:402:17: warning: Value stored to 'h' during its 
>> initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct hstate *h = hstate_vma(vma);
                          ^   ~~~~~~~~~~~~~~~
   mm/damon/vaddr.c:402:17: note: Value stored to 'h' during its initialization 
is never read
           struct hstate *h = hstate_vma(vma);
                          ^   ~~~~~~~~~~~~~~~
   Suppressed 4 warnings (3 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   4 warnings generated.
   mm/memfd.c:281:2: warning: Call to function 'strcpy' is insecure as it does 
not provide bounding of the memory buffer. Replace unbounded copy functions 
with analogous functions that support length arguments such as 'strlcpy'. 
CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(name, MFD_NAME_PREFIX);
           ^~~~~~
   mm/memfd.c:281:2: note: Call to function 'strcpy' is insecure as it does not 
provide bounding of the memory buffer. Replace unbounded copy functions with 
analogous functions that support length arguments such as 'strlcpy'. CWE-119
           strcpy(name, MFD_NAME_PREFIX);
           ^~~~~~
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   4 warnings generated.
   drivers/gpu/drm/nouveau/nouveau_bo0039.c:55:6: warning: Value stored to 
'page_count' during its initialization is never read 
[clang-analyzer-deadcode.DeadStores]
           u32 page_count = new_reg->num_pages;
               ^~~~~~~~~~   ~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/nouveau/nouveau_bo0039.c:55:6: note: Value stored to 
'page_count' during its initialization is never read
           u32 page_count = new_reg->num_pages;
               ^~~~~~~~~~   ~~~~~~~~~~~~~~~~~~
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   6 warnings generated.
   drivers/usb/chipidea/otg_fsm.c:42:2: warning: Value stored to 'next' is 
never read [clang-analyzer-deadcode.DeadStores]
           next += t;
           ^       ~
   drivers/usb/chipidea/otg_fsm.c:42:2: note: Value stored to 'next' is never 
read
           next += t;
           ^       ~
   drivers/usb/chipidea/otg_fsm.c:91:2: warning: Value stored to 'next' is 
never read [clang-analyzer-deadcode.DeadStores]
           next += t;
           ^       ~
   drivers/usb/chipidea/otg_fsm.c:91:2: note: Value stored to 'next' is never 
read
           next += t;
           ^       ~
   drivers/usb/chipidea/otg_fsm.c:131:2: warning: Value stored to 'next' is 
never read [clang-analyzer-deadcode.DeadStores]
           next += t;

vim +/h +402 mm/damon/vaddr.c

3f49584b262cf8 SeongJae Park 2021-09-07  396  
468a013161dfcf Baolin Wang   2021-12-16  397  #ifdef CONFIG_HUGETLB_PAGE
468a013161dfcf Baolin Wang   2021-12-16  398  static void 
damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm,
468a013161dfcf Baolin Wang   2021-12-16  399                            struct 
vm_area_struct *vma, unsigned long addr)
468a013161dfcf Baolin Wang   2021-12-16  400  {
468a013161dfcf Baolin Wang   2021-12-16  401    bool referenced = false;
468a013161dfcf Baolin Wang   2021-12-16 @402    struct hstate *h = 
hstate_vma(vma);
468a013161dfcf Baolin Wang   2021-12-16  403    pte_t entry = 
huge_ptep_get(pte);
468a013161dfcf Baolin Wang   2021-12-16  404    struct page *page = 
pte_page(entry);
468a013161dfcf Baolin Wang   2021-12-16  405  
468a013161dfcf Baolin Wang   2021-12-16  406    if (!page)
468a013161dfcf Baolin Wang   2021-12-16  407            return;
468a013161dfcf Baolin Wang   2021-12-16  408  
468a013161dfcf Baolin Wang   2021-12-16  409    get_page(page);
468a013161dfcf Baolin Wang   2021-12-16  410  
468a013161dfcf Baolin Wang   2021-12-16  411    if (pte_young(entry)) {
468a013161dfcf Baolin Wang   2021-12-16  412            referenced = true;
468a013161dfcf Baolin Wang   2021-12-16  413            entry = 
pte_mkold(entry);
468a013161dfcf Baolin Wang   2021-12-16  414            
huge_ptep_set_access_flags(vma, addr, pte, entry,
468a013161dfcf Baolin Wang   2021-12-16  415                                    
   vma->vm_flags & VM_WRITE);
468a013161dfcf Baolin Wang   2021-12-16  416    }
468a013161dfcf Baolin Wang   2021-12-16  417  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to