CC: kbuild-...@lists.01.org
CC: Linux Memory Management List <linux...@kvack.org>
TO: David Hildenbrand <da...@redhat.com>
CC: Andrew Morton <a...@linux-foundation.org>
CC: Linux Memory Management List <linux...@kvack.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
master
head:   d61c8b66c84080ecf8f9f4d9272ab4ec78029a59
commit: 8474e978a98cef8dd44860efbed3c757e3912c71 [10122/12612] mm/madvise: 
introduce MADV_POPULATE_(READ|WRITE) to prefault page tables
:::::: branch date: 7 hours ago
:::::: commit date: 6 days ago
config: powerpc64-randconfig-m031-20210622 (attached as .config)
compiler: powerpc64le-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>
Reported-by: Dan Carpenter <dan.carpen...@oracle.com>

New smatch warnings:
mm/madvise.c:845 madvise_populate() warn: variable dereferenced before check 
'vma' (see line 833)

Old smatch warnings:
arch/powerpc/include/asm/book3s/64/pgtable.h:787 pte_swp_soft_dirty() warn: 
bitwise AND condition is false here

vim +/vma +845 mm/madvise.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  826  
8474e978a98cef David Hildenbrand 2021-06-17  827  static long 
madvise_populate(struct vm_area_struct *vma,
8474e978a98cef David Hildenbrand 2021-06-17  828                             
struct vm_area_struct **prev,
8474e978a98cef David Hildenbrand 2021-06-17  829                             
unsigned long start, unsigned long end,
8474e978a98cef David Hildenbrand 2021-06-17  830                             
int behavior)
8474e978a98cef David Hildenbrand 2021-06-17  831  {
8474e978a98cef David Hildenbrand 2021-06-17  832        const bool write = 
behavior == MADV_POPULATE_WRITE;
8474e978a98cef David Hildenbrand 2021-06-17 @833        struct mm_struct *mm = 
vma->vm_mm;
8474e978a98cef David Hildenbrand 2021-06-17  834        unsigned long tmp_end;
8474e978a98cef David Hildenbrand 2021-06-17  835        int locked = 1;
8474e978a98cef David Hildenbrand 2021-06-17  836        long pages;
8474e978a98cef David Hildenbrand 2021-06-17  837  
8474e978a98cef David Hildenbrand 2021-06-17  838        *prev = vma;
8474e978a98cef David Hildenbrand 2021-06-17  839  
8474e978a98cef David Hildenbrand 2021-06-17  840        while (start < end) {
8474e978a98cef David Hildenbrand 2021-06-17  841                /*
8474e978a98cef David Hildenbrand 2021-06-17  842                 * We might 
have temporarily dropped the lock. For example,
8474e978a98cef David Hildenbrand 2021-06-17  843                 * our VMA 
might have been split.
8474e978a98cef David Hildenbrand 2021-06-17  844                 */
8474e978a98cef David Hildenbrand 2021-06-17 @845                if (!vma || 
start >= vma->vm_end) {
8474e978a98cef David Hildenbrand 2021-06-17  846                        vma = 
find_vma(mm, start);
8474e978a98cef David Hildenbrand 2021-06-17  847                        if 
(!vma || start < vma->vm_start)
8474e978a98cef David Hildenbrand 2021-06-17  848                                
return -ENOMEM;
8474e978a98cef David Hildenbrand 2021-06-17  849                }
8474e978a98cef David Hildenbrand 2021-06-17  850  
8474e978a98cef David Hildenbrand 2021-06-17  851                tmp_end = 
min_t(unsigned long, end, vma->vm_end);
8474e978a98cef David Hildenbrand 2021-06-17  852                /* Populate 
(prefault) page tables readable/writable. */
8474e978a98cef David Hildenbrand 2021-06-17  853                pages = 
faultin_vma_page_range(vma, start, tmp_end, write,
8474e978a98cef David Hildenbrand 2021-06-17  854                                
               &locked);
8474e978a98cef David Hildenbrand 2021-06-17  855                if (!locked) {
8474e978a98cef David Hildenbrand 2021-06-17  856                        
mmap_read_lock(mm);
8474e978a98cef David Hildenbrand 2021-06-17  857                        locked 
= 1;
8474e978a98cef David Hildenbrand 2021-06-17  858                        *prev = 
NULL;
8474e978a98cef David Hildenbrand 2021-06-17  859                        vma = 
NULL;
8474e978a98cef David Hildenbrand 2021-06-17  860                }
8474e978a98cef David Hildenbrand 2021-06-17  861                if (pages < 0) {
8474e978a98cef David Hildenbrand 2021-06-17  862                        switch 
(pages) {
8474e978a98cef David Hildenbrand 2021-06-17  863                        case 
-EINTR:
8474e978a98cef David Hildenbrand 2021-06-17  864                                
return -EINTR;
8474e978a98cef David Hildenbrand 2021-06-17  865                        case 
-EFAULT: /* Incompatible mappings / permissions. */
8474e978a98cef David Hildenbrand 2021-06-17  866                                
return -EINVAL;
8474e978a98cef David Hildenbrand 2021-06-17  867                        case 
-EHWPOISON:
8474e978a98cef David Hildenbrand 2021-06-17  868                                
return -EHWPOISON;
8474e978a98cef David Hildenbrand 2021-06-17  869                        default:
8474e978a98cef David Hildenbrand 2021-06-17  870                                
pr_warn_once("%s: unhandled return value: %ld\n",
8474e978a98cef David Hildenbrand 2021-06-17  871                                
             __func__, pages);
8474e978a98cef David Hildenbrand 2021-06-17  872                                
fallthrough;
8474e978a98cef David Hildenbrand 2021-06-17  873                        case 
-ENOMEM:
8474e978a98cef David Hildenbrand 2021-06-17  874                                
return -ENOMEM;
8474e978a98cef David Hildenbrand 2021-06-17  875                        }
8474e978a98cef David Hildenbrand 2021-06-17  876                }
8474e978a98cef David Hildenbrand 2021-06-17  877                start += pages 
* PAGE_SIZE;
8474e978a98cef David Hildenbrand 2021-06-17  878        }
8474e978a98cef David Hildenbrand 2021-06-17  879        return 0;
8474e978a98cef David Hildenbrand 2021-06-17  880  }
8474e978a98cef David Hildenbrand 2021-06-17  881  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to