On Thu, Sep 07, 2023 at 02:51:38PM +0200, Gabriel de Perthuis wrote:
> Hello,
> UBSAN reports some errors with bcachefs; it would be worthwhile to
> enable it in the ktest CI.
> I have UBSAN enabled because I started out from an Ubuntu kernel config:
> grep UBSAN .config
> CONFIG_ARCH_HAS_UBSAN_SANITIZE
> _ALL=y
> CONFIG_UBSAN=y
> # CONFIG_UBSAN_TRAP is not set
> CONFIG_CC_HAS_UBSAN_BOUNDS_STRICT=y
> CONFIG_UBSAN_BOUNDS=y
> CONFIG_UBSAN_BOUNDS_STRICT=y
> CONFIG_UBSAN_SHIFT=y
> # CONFIG_UBSAN_DIV_ZERO is not set
> CONFIG_UBSAN_BOOL=y
> CONFIG_UBSAN_ENUM=y
> # CONFIG_UBSAN_ALIGNMENT is not set
> CONFIG_UBSAN_SANITIZE_ALL=y
> # CONFIG_TEST_UBSAN is not set
> 
> Currently it reports the following:
> (bcachefs master (d0fb567ff8e045149050a1e8f6646fa9c61dab7a) + linux 6.5.1)
> 
> journalctl -k --grep UBSAN -ojson --output-fields=MESSAGE |jq -r .MESSAGE 
> |uniq
> UBSAN: array-index-out-of-bounds in drivers/md/bcache/bset.c:1098:3
> UBSAN: array-index-out-of-bounds in drivers/md/bcache/bset.c:1207:3
> UBSAN: array-index-out-of-bounds in drivers/md/bcache/bset.c:1152:4
> UBSAN: array-index-out-of-bounds in drivers/md/bcache/bset.c:1150:4
> UBSAN: array-index-out-of-bounds in drivers/md/bcache/extents.c:291:4
> UBSAN: array-index-out-of-bounds in drivers/md/bcache/extents.c:281:4
> UBSAN: array-index-out-of-bounds in drivers/md/bcache/extents.c:291:4
> UBSAN: array-index-out-of-bounds in drivers/md/bcache/extents.c:36:18
> UBSAN: array-index-out-of-bounds in drivers/md/bcache/extents.c:281:4
> UBSAN: array-index-out-of-bounds in drivers/md/bcache/extents.c:301:5
> UBSAN: array-index-out-of-bounds in fs/bcachefs/bkey_sort.h:29:13
> UBSAN: array-index-out-of-bounds in fs/bcachefs/bkey_sort.c:25:47
> UBSAN: array-index-out-of-bounds in fs/bcachefs/bkey_sort.c:25:30
> UBSAN: array-index-out-of-bounds in fs/bcachefs/bkey_sort.c:27:3
> UBSAN: array-index-out-of-bounds in fs/bcachefs/bkey_sort.c:25:47
> UBSAN: array-index-out-of-bounds in fs/bcachefs/bkey_sort.c:27:3
> UBSAN: array-index-out-of-bounds in fs/bcachefs/bkey_sort.c:25:30
> UBSAN: array-index-out-of-bounds in fs/bcachefs/bkey_sort.c:27:3
> 
> This started happening earlier, I have one boot based on 6.5.0
> (bcachefs master 493c276ead0e516ff3eca8d13b820d31afd62524) reporting
> similar errors, whereas the one based on 6.4 (bcachefs master
> 117cd823d2d77dd8db1ec35b5819e1668c736b31 merged with stable 6.4.12)
> didn't.
> 
> The errors are of the form (indices vary)
> index 44 is out of range for type 'sort_iter_set [4]'
> index 4 is out of range for type 'btree_iter_set [4]'
> 
> Uploaded a fuller log:
> journalctl -k -ojson --output-fields=MESSAGE |jq -r .MESSAGE |grep -B1
> -A100 UBSAN |grep -v '^Hardware name:' \
>   |awk '/UBSAN: array-index-out-of-bounds/,/=========/' >
> bcachefs-6.5.1.ubsan.errors
> 
> https://pb.envs.net/?399630cde0c62c76#4zUPPizf68bXGVoyxedZawKGVswrX4JaoeTJ5shKLvfJ

These should be fixed in master now.

Reply via email to