* [PATCH] blk-mq: fix possible NULL pointer access in classic polling
@ 2022-12-16 15:06 huteng19901016
2022-12-16 15:15 ` Keith Busch
2022-12-16 15:15 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: huteng19901016 @ 2022-12-16 15:06 UTC (permalink / raw)
To: axboe; +Cc: linux-block, linux-kernel, huteng.ht
From: "huteng.ht" <huteng.ht@bytedance.com>
Since poll method in blk_mq_ops may not be implemented by driver,
add a judgement to avoid NULL pointer access.
Signed-off-by: huteng.ht <huteng.ht@bytedance.com>
---
block/blk-mq.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index c5cf0dbca1db..f58f166d1c75 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4897,6 +4897,8 @@ static int blk_mq_poll_classic(struct request_queue *q, blk_qc_t cookie,
int ret;
do {
+ if (!q->mq_ops->poll)
+ break;
ret = q->mq_ops->poll(hctx, iob);
if (ret > 0) {
__set_current_state(TASK_RUNNING);
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] blk-mq: fix possible NULL pointer access in classic polling
2022-12-16 15:06 [PATCH] blk-mq: fix possible NULL pointer access in classic polling huteng19901016
@ 2022-12-16 15:15 ` Keith Busch
2022-12-16 15:15 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2022-12-16 15:15 UTC (permalink / raw)
To: huteng19901016; +Cc: axboe, linux-block, linux-kernel, huteng.ht
On Fri, Dec 16, 2022 at 11:06:36PM +0800, huteng19901016@gmail.com wrote:
> From: "huteng.ht" <huteng.ht@bytedance.com>
>
> Since poll method in blk_mq_ops may not be implemented by driver,
> add a judgement to avoid NULL pointer access.
Have you actually observed this NULL pointer access occur? Because the
poll attempt should have been abandoned much earlier due to the queue
not having QUEUE_FLAG_POLL set. If a driver has that flag set without
actually implementing ->poll(), though, that'd be a different bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] blk-mq: fix possible NULL pointer access in classic polling
2022-12-16 15:06 [PATCH] blk-mq: fix possible NULL pointer access in classic polling huteng19901016
2022-12-16 15:15 ` Keith Busch
@ 2022-12-16 15:15 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2022-12-16 15:15 UTC (permalink / raw)
To: huteng19901016; +Cc: linux-block, linux-kernel, huteng.ht
On 12/16/22 8:06 AM, huteng19901016@gmail.com wrote:
> From: "huteng.ht" <huteng.ht@bytedance.com>
>
> Since poll method in blk_mq_ops may not be implemented by driver,
> add a judgement to avoid NULL pointer access.
So the queue has QUEUE_FLAG_POLL set, but no -mq_ops->poll() set?
That seems like the real bug.
Where did you see this oops?
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-16 15:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-16 15:06 [PATCH] blk-mq: fix possible NULL pointer access in classic polling huteng19901016
2022-12-16 15:15 ` Keith Busch
2022-12-16 15:15 ` 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).