Re: [PATCH 5.4] bcache: initialize 'sb_page' in register_bcache()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 30, 2020 at 08:44:21AM +0200, Greg KH wrote:
> On Wed, Apr 29, 2020 at 06:38:17PM +0000, Tom Saeger wrote:
> > commit 393b8509be33 (bcache: rework error unwinding in register_bcache)
> > 
> > introduced compile warning:
> > warning: 'sb_page' may be used uninitialized in this function [-Wmaybe-uninitialized]
> > 
> > Use 'sb_page' initialization prior to 393b8509be33.
> > 
> > Fixes: 393b8509be33 (bcache: rework error unwinding in register_bcache)
> > Cc: <stable@xxxxxxxxxxxxxxx> # 5.4.x
> > Signed-off-by: Tom Saeger <tom.saeger@xxxxxxxxxx>
> > ---
> > 
> > This addresses warning only seen in 5.4.22+.  Upstream avoids
> > this in a different way.
> 
> What is the "different way"?

The mainline commits marked "+" below appear to go together.  Perhaps a
refactoring series?

git log upstream/master v5.4.. --format="%>(16)%h %<(30)%ae %s" -- drivers/md/bcache/super.c
    3d745ea5b095 hch@xxxxxx                     block: simplify queue allocation
    ff27668ce809 hch@xxxxxx                     bcache: pass the make_request methods to blk_queue_make_request
    309cc719a2c8 colyli@xxxxxxx                 bcache: Revert "bcache: shrink btree node cache after bch_btree_check()"
    49d08d596e85 colyli@xxxxxxx                 bcache: check return value of prio_read()
+   6321bef028de hch@xxxxxx                     bcache: use read_cache_page_gfp to read the superblock
+ - 475389ae5c08 hch@xxxxxx                     bcache: store a pointer to the on-disk sb in the cache and cached_dev structures
+ - cfa0c56db9c0 hch@xxxxxx                     bcache: return a pointer to the on-disk sb from read_super
+ - fc8f19cc5dce hch@xxxxxx                     bcache: transfer the sb_page reference to register_{bdev,cache}
+ - ae3cd299919a colyli@xxxxxxx                 bcache: fix use-after-free in register_bcache()
+ - 29cda393bcaa colyli@xxxxxxx                 bcache: properly initialize 'path' and 'err' in register_bcache()
+ - 50246693f81f hch@xxxxxx                     bcache: rework error unwinding in register_bcache
+   a702a692cd75 hch@xxxxxx                     bcache: use a separate data structure for the on-disk super block
    e8547d42095e liangchen.linux@xxxxxxxxx      bcache: cached_dev_free needs to put the sb page
    c5fcdedcee4e colyli@xxxxxxx                 bcache: add idle_max_writeback_rate sysfs interface
    84c529aea182 andrea.righi@xxxxxxxxxxxxx     bcache: fix deadlock in bcache_allocator
    aaf8dbeab586 colyli@xxxxxxx                 bcache: add more accurate error messages in read_super()
    2d8869518a52 colyli@xxxxxxx                 bcache: fix static checker warning in bcache_device_free()
    34cf78bf34d4 fangguoju@xxxxxxxxx            bcache: fix a lost wake-up problem caused by mca_cannibalize_lock

Bisecting these commits produced similar warnings.  Those marked "-"
all had warnings (for me), and all warnings were resolved with commit:

    6321bef028de hch@xxxxxx                     bcache: use read_cache_page_gfp to read the superblock


5.4 has 50246693f81f backported as 393b8509be3 (v5.4.22), but doesn't have:

+   6321bef028de hch@xxxxxx                     bcache: use read_cache_page_gfp to read the superblock
+ - 475389ae5c08 hch@xxxxxx                     bcache: store a pointer to the on-disk sb in the cache and cached_dev structures
+ - cfa0c56db9c0 hch@xxxxxx                     bcache: return a pointer to the on-disk sb from read_super
+ - fc8f19cc5dce hch@xxxxxx                     bcache: transfer the sb_page reference to register_{bdev,cache}

And perhaps 5.4 should continue to exclude these??

Thus the reason for my patch :)

5.6 already has 6321bef028de and won't see this issue.


> 
> And why am I not seeing this warning in my builds?  What version of gcc
> are you using?

Hmm - did I mention this was on arm64 system?

First I was using Oracle Linux 8 (gcc 8.3.1) aarch64.
But I've recreated the same using Fedora 31 (gcc 9.3.1) aarch64.

In file included from ./include/linux/export.h:42,
                 from ./include/linux/linkage.h:7,
                 from ./include/linux/fs.h:5,
                 from ./include/linux/highmem.h:5,
                 from ./include/linux/bio.h:8,
                 from drivers/md/bcache/bcache.h:182,
                 from drivers/md/bcache/super.c:10:
drivers/md/bcache/super.c: In function ‘register_bcache’:
./include/linux/compiler.h:188:26: warning: ‘sb_page’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  188 |  case 8: *(__u64 *)res = *(volatile __u64 *)p; break;  \
      |                          ^
drivers/md/bcache/super.c:2379:15: note: ‘sb_page’ was declared here
 2379 |  struct page *sb_page;
      |               ^~~~~~~
  AR      drivers/md/bcache/built-in.a

Let me know if you need more info.

Regards,

--Tom



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux