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@vger.kernel.org # 5.4.x Signed-off-by: Tom Saeger tom.saeger@oracle.com ---
This addresses warning only seen in 5.4.22+. Upstream avoids this in a different way.
Compile test case:
cp arch/arm64/configs/defconfig .config ./scripts/config -e BCACHE make ARCH=arm64 olddefconfig make ARCH=arm64 -j $(nproc)
Regards, --Tom
drivers/md/bcache/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 658b0f4a01f5..25cbc9e2f8e3 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -2376,7 +2376,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, char *path = NULL; struct cache_sb *sb; struct block_device *bdev = NULL; - struct page *sb_page; + struct page *sb_page = NULL; ssize_t ret;
ret = -EBUSY;
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@vger.kernel.org # 5.4.x Signed-off-by: Tom Saeger tom.saeger@oracle.com
This addresses warning only seen in 5.4.22+. Upstream avoids this in a different way.
What is the "different way"?
And why am I not seeing this warning in my builds? What version of gcc are you using?
thanks,
greg k-h
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@vger.kernel.org # 5.4.x Signed-off-by: Tom Saeger tom.saeger@oracle.com
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@lst.de block: simplify queue allocation ff27668ce809 hch@lst.de bcache: pass the make_request methods to blk_queue_make_request 309cc719a2c8 colyli@suse.de bcache: Revert "bcache: shrink btree node cache after bch_btree_check()" 49d08d596e85 colyli@suse.de bcache: check return value of prio_read() + 6321bef028de hch@lst.de bcache: use read_cache_page_gfp to read the superblock + - 475389ae5c08 hch@lst.de bcache: store a pointer to the on-disk sb in the cache and cached_dev structures + - cfa0c56db9c0 hch@lst.de bcache: return a pointer to the on-disk sb from read_super + - fc8f19cc5dce hch@lst.de bcache: transfer the sb_page reference to register_{bdev,cache} + - ae3cd299919a colyli@suse.de bcache: fix use-after-free in register_bcache() + - 29cda393bcaa colyli@suse.de bcache: properly initialize 'path' and 'err' in register_bcache() + - 50246693f81f hch@lst.de bcache: rework error unwinding in register_bcache + a702a692cd75 hch@lst.de bcache: use a separate data structure for the on-disk super block e8547d42095e liangchen.linux@gmail.com bcache: cached_dev_free needs to put the sb page c5fcdedcee4e colyli@suse.de bcache: add idle_max_writeback_rate sysfs interface 84c529aea182 andrea.righi@canonical.com bcache: fix deadlock in bcache_allocator aaf8dbeab586 colyli@suse.de bcache: add more accurate error messages in read_super() 2d8869518a52 colyli@suse.de bcache: fix static checker warning in bcache_device_free() 34cf78bf34d4 fangguoju@gmail.com 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@lst.de 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@lst.de bcache: use read_cache_page_gfp to read the superblock + - 475389ae5c08 hch@lst.de bcache: store a pointer to the on-disk sb in the cache and cached_dev structures + - cfa0c56db9c0 hch@lst.de bcache: return a pointer to the on-disk sb from read_super + - fc8f19cc5dce hch@lst.de 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
On Fri, May 01, 2020 at 01:13:19AM +0000, Tom Saeger wrote:
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]
FWIW - 8f6a84167e86 (Stop the ad-hoc games with -Wno-maybe-initialized)
successfully squelched the warning I previously reported. Still shows up with W=2 for me on FC31 (gcc9.3.1), but this is probably moot at this point.
--Tom
linux-stable-mirror@lists.linaro.org