All of lore.kernel.org
 help / color / mirror / Atom feed
* UAF in blk_add_rq_to_plug()?
@ 2022-10-31 22:12 Al Viro
  2022-10-31 22:42 ` Jens Axboe
  0 siblings, 1 reply; 7+ messages in thread
From: Al Viro @ 2022-10-31 22:12 UTC (permalink / raw)
  To: linux-block

static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq)
{
        struct request *last = rq_list_peek(&plug->mq_list);

Suppose it's not NULL...

        if (!plug->rq_count) {
                trace_block_plug(rq->q);
        } else if (plug->rq_count >= blk_plug_max_rq_count(plug) ||
                   (!blk_queue_nomerges(rq->q) &&
                    blk_rq_bytes(last) >= BLK_PLUG_FLUSH_SIZE)) {
... and we went here:
                blk_mq_flush_plug_list(plug, false);
All requests, including the one last points to, might get fed ->queue_rq()
here.  At which point there seems to be nothing to prevent them getting
completed and freed on another CPU, possibly before we return here.

                trace_block_plug(rq->q);
        }

        if (!plug->multiple_queues && last && last->q != rq->q)
... and here we dereference last.

Shouldn't we reset last to NULL after the call of blk_mq_flush_plug_list()
above?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-01  2:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-31 22:12 UAF in blk_add_rq_to_plug()? Al Viro
2022-10-31 22:42 ` Jens Axboe
2022-10-31 23:35   ` Al Viro
2022-11-01  0:03     ` Jens Axboe
2022-11-01  0:06       ` Jens Axboe
2022-11-01  0:54         ` Al Viro
2022-11-01  2:23           ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.