From 7ba964cc3f23e843fda0ac328997e25e54c79acb Mon Sep 17 00:00:00 2001 From: loli10K Date: Wed, 13 Nov 2019 19:19:06 +0100 Subject: [PATCH] Prevent NULL pointer dereference in blkg_tryget() on EL8 kernels blkg_tryget() as shipped in EL8 kernels does not seem to handle NULL @blkg as input; this is different from its mainline counterpart where NULL is accepted. To prevent dereferencing a NULL pointer when dealing with block devices which do not set a root_blkg on the request queue perform the NULL check in vdev_bio_associate_blkg(). Reviewed-by: Brian Behlendorf Reviewed-by: Kjeld Schouten Reviewed-by: Tony Hutter Signed-off-by: loli10K Closes #9546 Closes #9577 --- module/os/linux/zfs/vdev_disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index ed0e7a1731..328e47f522 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -530,7 +530,7 @@ vdev_bio_associate_blkg(struct bio *bio) ASSERT3P(q, !=, NULL); ASSERT3P(bio->bi_blkg, ==, NULL); - if (blkg_tryget(q->root_blkg)) + if (q->root_blkg && blkg_tryget(q->root_blkg)) bio->bi_blkg = q->root_blkg; } #define bio_associate_blkg vdev_bio_associate_blkg