cfq-iosched: handle failure of cfq group allocation
Subsystems (2)
PATCH 1/1 cfq-iosched: handle failure of cfq group allocation
Cfq_lookup_create_cfqg() allocates struct blkcg_gq using GFP_ATOMIC. In cfq_find_alloc_queue() possible allocation failure is not handled. As a result kernel oopses on NULL pointer dereference when cfq_link_cfqq_cfqg() calls cfqg_get() for NULL pointer.
Bug was introduced in v3.5 in commit cd1604fab4f9 ("blkcg: factor out blkio_group creation"). Prior to that commit cfq group lookup had returned pointer to root group as fallback.
This patch handles this error using existing fallback oom_cfqq.
--- block/cfq-iosched.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
block/cfq-iosched.c +6 -1
@@ -3590,6 +3590,11 @@ retry: blkcg =bio_blkcg (bio); cfqg =cfq_lookup_create_cfqg (cfqd, blkcg); +if (!cfqg) { + cfqq = &cfqd->oom_cfqq; + goto out; + } + cfqq =cic_to_cfqq (cic, is_sync);/*
@@ -3626,7 +3631,7 @@ retry: }else cfqq = &cfqd->oom_cfqq; } - +out:if (new_cfqq)kmem_cache_free (cfq_pool, new_cfqq);
Quoted 5 lines · Konstantin Khlebnikov
Cfq_lookup_create_cfqg()allocates structblkcg_gqusingGFP_ATOMIC. Incfq_find_alloc_queue()possible allocation failure is not handled. As a result kernel oopses on NULL pointer dereference whencfq_link_cfqq_cfqg()callscfqg_get()for NULL pointer.
Quoted 7 lines
Bug was introduced in v3.5 in commit
cd1604fab4f9("blkcg: factor outblkio_groupcreation"). Prior to that commit cfq group lookup had returned pointer to root group as fallback.This patch handles this error using existing fallback
oom_cfqq.Signed-off-by Konstantin Khlebnikov <[email protected]>
Oops,
Thanks.
Signature · 1 line
tejun
Quoted 9 lines · Konstantin Khlebnikov
Cfq_lookup_create_cfqg()allocates structblkcg_gqusingGFP_ATOMIC. Incfq_find_alloc_queue()possible allocation failure is not handled. As a result kernel oopses on NULL pointer dereference whencfq_link_cfqq_cfqg()callscfqg_get()for NULL pointer.Bug was introduced in v3.5 in commit
cd1604fab4f9("blkcg: factor outblkio_groupcreation"). Prior to that commit cfq group lookup had returned pointer to root group as fallback.
Quoted 6 lines
This patch handles this error using existing fallback
oom_cfqq.Signed-off-by Konstantin Khlebnikov <[email protected]>--- block/cfq-iosched.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Looks good to me. Thanks for the patch.
Vivek
Quoted 26 lines
block/cfq-iosched.c +6
-1@@ -3590,6 +3590,11 @@ retry: blkcg =bio_blkcg (bio); cfqg =cfq_lookup_create_cfqg (cfqd, blkcg); +if (!cfqg) { + cfqq = &cfqd->oom_cfqq; + goto out; + } + cfqq =cic_to_cfqq (cic, is_sync);/* @@ -3626,7 +3631,7 @@ retry: }else cfqq = &cfqd->oom_cfqq; } - +out:if (new_cfqq)kmem_cache_free (cfq_pool, new_cfqq);
Jens Axboe
maintainerQuoted 10 lines · Konstantin Khlebnikov
Cfq_lookup_create_cfqg()allocates structblkcg_gqusingGFP_ATOMIC. Incfq_find_alloc_queue()possible allocation failure is not handled. As a result kernel oopses on NULL pointer dereference whencfq_link_cfqq_cfqg()callscfqg_get()for NULL pointer.Bug was introduced in v3.5 in commit
cd1604fab4f9("blkcg: factor outblkio_groupcreation"). Prior to that commit cfq group lookup had returned pointer to root group as fallback.This patch handles this error using existing fallback
oom_cfqq.
Thanks, added and marked for stable as well.
Signature · 1 line
Jens Axboe