* [PATCH BUGFIX] block, bfq: use pointer entity->sched_data only if set
@ 2017-05-09 9:37 Paolo Valente
2017-05-09 14:53 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Valente @ 2017-05-09 9:37 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
Paolo Valente
In the function __bfq_deactivate_entity, the pointer
entity->sched_data could happen to be used before being properly
initialized. This led to a NULL pointer dereference. This commit fixes
this bug by just using this pointer only where it is safe to do so.
Reported-by: Tom Harrison <l12436.tw@gmail.com>
Tested-by: Tom Harrison <l12436.tw@gmail.com>
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
---
block/bfq-wf2q.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
index b4fc3e4..8726ede 100644
--- a/block/bfq-wf2q.c
+++ b/block/bfq-wf2q.c
@@ -1114,12 +1114,21 @@ static void bfq_activate_requeue_entity(struct bfq_entity *entity,
bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree)
{
struct bfq_sched_data *sd = entity->sched_data;
- struct bfq_service_tree *st = bfq_entity_service_tree(entity);
- int is_in_service = entity == sd->in_service_entity;
+ struct bfq_service_tree *st;
+ bool is_in_service;
if (!entity->on_st) /* entity never activated, or already inactive */
return false;
+ /*
+ * If we get here, then entity is active, which implies that
+ * bfq_group_set_parent has already been invoked for the group
+ * represented by entity. Therefore, the field
+ * entity->sched_data has been set, and we can safely use it.
+ */
+ st = bfq_entity_service_tree(entity);
+ is_in_service = entity == sd->in_service_entity;
+
if (is_in_service)
bfq_calc_finish(entity, entity->service);
--
2.10.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH BUGFIX] block, bfq: use pointer entity->sched_data only if set
2017-05-09 9:37 [PATCH BUGFIX] block, bfq: use pointer entity->sched_data only if set Paolo Valente
@ 2017-05-09 14:53 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2017-05-09 14:53 UTC (permalink / raw)
To: Paolo Valente
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie
On 05/09/2017 03:37 AM, Paolo Valente wrote:
> In the function __bfq_deactivate_entity, the pointer
> entity->sched_data could happen to be used before being properly
> initialized. This led to a NULL pointer dereference. This commit fixes
> this bug by just using this pointer only where it is safe to do so.
Added, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-09 14:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09 9:37 [PATCH BUGFIX] block, bfq: use pointer entity->sched_data only if set Paolo Valente
2017-05-09 14:53 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).