:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check warning: 
fs/cramfs/inode.c:889:25: warning: use of NULL where non-null expected 
[CWE-476] [-Wanalyzer-null-argument]"
:::::: 

CC: kbuild-...@lists.01.org
BCC: l...@intel.com
CC: linux-ker...@vger.kernel.org
TO: "Matthew Wilcox (Oracle)" <wi...@infradead.org>

tree:   git://git.infradead.org/users/willy/pagecache for-next
head:   03b33c09ea22fa89dd204ad0a2058e512c691b9f
commit: 0ba02b002594cc1809da3a05a44bb5b9654448f6 [44/79] cramfs: 
read_mapping_page() is synchronous
:::::: branch date: 2 days ago
:::::: commit date: 11 days ago
config: arm-randconfig-c002-20220707 
(https://download.01.org/0day-ci/archive/20220710/202207102236.ryhezn5p-...@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.3.0
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
        git remote add willy-pagecache 
git://git.infradead.org/users/willy/pagecache
        git fetch --no-tags willy-pagecache for-next
        git checkout 0ba02b002594cc1809da3a05a44bb5b9654448f6
        # save the config file
         ARCH=arm KBUILD_USERCFLAGS='-fanalyzer -Wno-error' 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <l...@intel.com>


gcc-analyzer warnings: (new ones prefixed by >>)
   fs/cramfs/inode.c: In function 'cramfs_read_folio':
>> fs/cramfs/inode.c:889:25: warning: use of NULL where non-null expected 
>> [CWE-476] [-Wanalyzer-null-argument]
     889 |                         memcpy(pgdata,
         |                         ^~~~~~~~~~~~~~
     890 |                                cramfs_read(sb, block_start, 
block_len),
         |                                
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     891 |                                block_len);
         |                                ~~~~~~~~~~
     'cramfs_read_folio': event 1
       |
       |  808 | static int cramfs_read_folio(struct file *file, struct folio 
*folio)
       |      |            ^~~~~~~~~~~~~~~~~
       |      |            |
       |      |            (1) entry to 'cramfs_read_folio'
       |
     'cramfs_read_folio': event 2
       |
       |include/linux/compiler.h:56:26:
       |   56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## 
__VA_ARGS__) ) )
       |      |                          ^
       |      |                          |
       |      |                          (2) following 'true' branch...
   fs/cramfs/inode.c:820:9: note: in expansion of macro 'if'
       |  820 |         if (page->index < maxblock) {
       |      |         ^~
       |
     'cramfs_read_folio': events 3-4
       |
       |  278 |                 return cramfs_blkdev_read(sb, offset, len);
       |      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                        |
       |      |                        (4) calling 'cramfs_blkdev_read' from 
'cramfs_read_folio'
       |......
       |  821 |                 struct super_block *sb = inode->i_sb;
       |      |                                     ^~
       |      |                                     |
       |      |                                     (3) ...to here
       |
       +--> 'cramfs_blkdev_read': event 5
              |
              |  182 | static void *cramfs_blkdev_read(struct super_block *sb, 
unsigned int offset,
              |      |              ^~~~~~~~~~~~~~~~~~
              |      |              |
              |      |              (5) entry to 'cramfs_blkdev_read'
              |
            'cramfs_blkdev_read': event 6
              |
              |include/linux/compiler.h:56:26:
              |   56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## 
__VA_ARGS__) ) )
              |      |                          ^
              |      |                          |
              |      |                          (6) following 'false' branch...
   fs/cramfs/inode.c:192:9: note: in expansion of macro 'if'
              |  192 |         if (!len)
              |      |         ^~
              |
            'cramfs_blkdev_read': events 7-8
              |
              |  194 |         blocknr = offset >> PAGE_SHIFT;
              |......
              |  198 |         for (i = 0; i < READ_BUFFERS; i++) {
              |      |                       ~
              |      |                       |
              |      |                       (8) following 'true' branch (when 
'i != 2')...
              |
            'cramfs_blkdev_read': event 9
              |
              |  201 |                 if (buffer_dev[i] != sb)
              |      |                     ~~~~~~~~~~^~~
              |      |                               |
              |      |                               (9) ...to here
   include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var'
              |   58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) 
? (cond) : __trace_if_value(cond))
              |      |                                                    ^~~~
   fs/cramfs/inode.c:201:17: note: in expansion of macro 'if'
              |  201 |                 if (buffer_dev[i] != sb)
              |      |                 ^~
              |
            'cramfs_blkdev_read': event 10
              |
              |include/linux/compiler.h:58:30:
              |   58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) 
? (cond) : __trace_if_value(cond))
              |      |                              ^
              |      |                              |
              |      |                              (10) following 'true' 
branch...
   include/linux/compiler.h:56:28: note: in expansion of macro '__trace_if_var'
              |   56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## 
__VA_ARGS__) ) )
              |      |                            ^~~~~~~~~~~~~~
   fs/cramfs/inode.c:207:17: note: in expansion of macro 'if'
              |  207 |                 if (blk_offset > BUFFER_SIZE ||
              |      |                 ^~
              |
            'cramfs_blkdev_read': event 11
              |
              |include/linux/compiler.h:56:44:
              |   56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## 
__VA_ARGS__) ) )
              |      |                                            ^
              |      |                                            |
              |      |                                            (11) ...to 
here
   include/linux/compiler.h:58:61: note: in definition of macro '__trace_if_var'
              |   58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) 
? (cond) : __trace_if_value(cond))
              |      |                                                          
   ^~~~

vim +889 fs/cramfs/inode.c

^1da177e4c3f41 Linus Torvalds          2005-04-16  807  
5aab331ad68f7c Matthew Wilcox (Oracle  2022-04-29  808) static int 
cramfs_read_folio(struct file *file, struct folio *folio)
^1da177e4c3f41 Linus Torvalds          2005-04-16  809  {
5aab331ad68f7c Matthew Wilcox (Oracle  2022-04-29  810)         struct page 
*page = &folio->page;
^1da177e4c3f41 Linus Torvalds          2005-04-16  811          struct inode 
*inode = page->mapping->host;
98310e581e0985 David VomLehn           2009-04-02  812          u32 maxblock;
98310e581e0985 David VomLehn           2009-04-02  813          int 
bytes_filled;
^1da177e4c3f41 Linus Torvalds          2005-04-16  814          void *pgdata;
^1da177e4c3f41 Linus Torvalds          2005-04-16  815  
09cbfeaf1a5a67 Kirill A. Shutemov      2016-04-01  816          maxblock = 
(inode->i_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
^1da177e4c3f41 Linus Torvalds          2005-04-16  817          bytes_filled = 
0;
98310e581e0985 David VomLehn           2009-04-02  818          pgdata = 
kmap(page);
98310e581e0985 David VomLehn           2009-04-02  819  
^1da177e4c3f41 Linus Torvalds          2005-04-16  820          if (page->index 
< maxblock) {
^1da177e4c3f41 Linus Torvalds          2005-04-16  821                  struct 
super_block *sb = inode->i_sb;
^1da177e4c3f41 Linus Torvalds          2005-04-16  822                  u32 
blkptr_offset = OFFSET(inode) + page->index * 4;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  823                  u32 
block_ptr, block_start, block_len;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  824                  bool 
uncompressed, direct;
^1da177e4c3f41 Linus Torvalds          2005-04-16  825  
353ab6e97b8f20 Ingo Molnar             2006-03-26  826                  
mutex_lock(&read_mutex);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  827                  
block_ptr = *(u32 *) cramfs_read(sb, blkptr_offset, 4);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  828                  
uncompressed = (block_ptr & CRAMFS_BLK_FLAG_UNCOMPRESSED);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  829                  direct 
= (block_ptr & CRAMFS_BLK_FLAG_DIRECT_PTR);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  830                  
block_ptr &= ~CRAMFS_BLK_FLAGS;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  831  
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  832                  if 
(direct) {
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  833                          
/*
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  834                          
 * The block pointer is an absolute start pointer,
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  835                          
 * shifted by 2 bits. The size is included in the
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  836                          
 * first 2 bytes of the data block when compressed,
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  837                          
 * or PAGE_SIZE otherwise.
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  838                          
 */
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  839                          
block_start = block_ptr << CRAMFS_BLK_DIRECT_PTR_SHIFT;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  840                          
if (uncompressed) {
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  841                          
        block_len = PAGE_SIZE;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  842                          
        /* if last block: cap to file length */
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  843                          
        if (page->index == maxblock - 1)
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  844                          
                block_len =
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  845                          
                        offset_in_page(inode->i_size);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  846                          
} else {
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  847                          
        block_len = *(u16 *)
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  848                          
                cramfs_read(sb, block_start, 2);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  849                          
        block_start += 2;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  850                          
}
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  851                  } else {
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  852                          
/*
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  853                          
 * The block pointer indicates one past the end of
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  854                          
 * the current block (start of next block). If this
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  855                          
 * is the first block then it starts where the block
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  856                          
 * pointer table ends, otherwise its start comes
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  857                          
 * from the previous block's pointer.
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  858                          
 */
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  859                          
block_start = OFFSET(inode) + maxblock * 4;
^1da177e4c3f41 Linus Torvalds          2005-04-16  860                          
if (page->index)
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  861                          
        block_start = *(u32 *)
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  862                          
                cramfs_read(sb, blkptr_offset - 4, 4);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  863                          
/* Beware... previous ptr might be a direct ptr */
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  864                          
if (unlikely(block_start & CRAMFS_BLK_FLAG_DIRECT_PTR)) {
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  865                          
        /* See comments on earlier code. */
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  866                          
        u32 prev_start = block_start;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  867                          
        block_start = prev_start & ~CRAMFS_BLK_FLAGS;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  868                          
        block_start <<= CRAMFS_BLK_DIRECT_PTR_SHIFT;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  869                          
        if (prev_start & CRAMFS_BLK_FLAG_UNCOMPRESSED) {
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  870                          
                block_start += PAGE_SIZE;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  871                          
        } else {
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  872                          
                block_len = *(u16 *)
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  873                          
                        cramfs_read(sb, block_start, 2);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  874                          
                block_start += 2 + block_len;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  875                          
        }
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  876                          
}
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  877                          
block_start &= ~CRAMFS_BLK_FLAGS;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  878                          
block_len = block_ptr - block_start;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  879                  }
98310e581e0985 David VomLehn           2009-04-02  880  
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  881                  if 
(block_len == 0)
^1da177e4c3f41 Linus Torvalds          2005-04-16  882                          
; /* hole */
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  883                  else if 
(unlikely(block_len > 2*PAGE_SIZE ||
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  884                          
          (uncompressed && block_len > PAGE_SIZE))) {
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  885                          
mutex_unlock(&read_mutex);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  886                          
pr_err("bad data blocksize %u\n", block_len);
98310e581e0985 David VomLehn           2009-04-02  887                          
goto err;
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  888                  } else 
if (uncompressed) {
fd4f6f2a78aeae Nicolas Pitre           2017-10-12 @889                          
memcpy(pgdata,
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  890                          
       cramfs_read(sb, block_start, block_len),
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  891                          
       block_len);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  892                          
bytes_filled = block_len;
98310e581e0985 David VomLehn           2009-04-02  893                  } else {
^1da177e4c3f41 Linus Torvalds          2005-04-16  894                          
bytes_filled = cramfs_uncompress_block(pgdata,
09cbfeaf1a5a67 Kirill A. Shutemov      2016-04-01  895                          
         PAGE_SIZE,
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  896                          
         cramfs_read(sb, block_start, block_len),
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  897                          
         block_len);
fd4f6f2a78aeae Nicolas Pitre           2017-10-12  898                  }
353ab6e97b8f20 Ingo Molnar             2006-03-26  899                  
mutex_unlock(&read_mutex);
98310e581e0985 David VomLehn           2009-04-02  900                  if 
(unlikely(bytes_filled < 0))
98310e581e0985 David VomLehn           2009-04-02  901                          
goto err;
^1da177e4c3f41 Linus Torvalds          2005-04-16  902          }
98310e581e0985 David VomLehn           2009-04-02  903  
09cbfeaf1a5a67 Kirill A. Shutemov      2016-04-01  904          memset(pgdata + 
bytes_filled, 0, PAGE_SIZE - bytes_filled);
^1da177e4c3f41 Linus Torvalds          2005-04-16  905          
flush_dcache_page(page);
98310e581e0985 David VomLehn           2009-04-02  906          kunmap(page);
^1da177e4c3f41 Linus Torvalds          2005-04-16  907          
SetPageUptodate(page);
^1da177e4c3f41 Linus Torvalds          2005-04-16  908          
unlock_page(page);
^1da177e4c3f41 Linus Torvalds          2005-04-16  909          return 0;
98310e581e0985 David VomLehn           2009-04-02  910  
98310e581e0985 David VomLehn           2009-04-02  911  err:
98310e581e0985 David VomLehn           2009-04-02  912          kunmap(page);
98310e581e0985 David VomLehn           2009-04-02  913          
ClearPageUptodate(page);
98310e581e0985 David VomLehn           2009-04-02  914          
SetPageError(page);
98310e581e0985 David VomLehn           2009-04-02  915          
unlock_page(page);
98310e581e0985 David VomLehn           2009-04-02  916          return 0;
^1da177e4c3f41 Linus Torvalds          2005-04-16  917  }
^1da177e4c3f41 Linus Torvalds          2005-04-16  918  

:::::: The code at line 889 was first introduced by commit
:::::: fd4f6f2a78aeaebb7094c1bb9b30623d18a86e4c cramfs: implement uncompressed 
and arbitrary data block positioning

:::::: TO: Nicolas Pitre <nicolas.pi...@linaro.org>
:::::: CC: Al Viro <v...@zeniv.linux.org.uk>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to