Re: usercopy whitelist woe in scsi_sense_cache

From: Kees Cook
Date: Tue Apr 17 2018 - 12:42:52 EST


On Mon, Apr 16, 2018 at 8:12 PM, Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> With a hardware watchpoint, I've isolated the corruption to here:
>
> bfq_dispatch_request+0x2be/0x1610:
> __bfq_dispatch_request at block/bfq-iosched.c:3902
> 3900 if (rq) {
> 3901 inc_in_driver_start_rq:
> 3902 bfqd->rq_in_driver++;
> 3903 start_rq:
> 3904 rq->rq_flags |= RQF_STARTED;
> 3905 }

FWIW, the stacktrace here (removing the ? lines) is:

[ 34.311980] RIP: 0010:bfq_dispatch_request+0x2be/0x1610
[ 34.452491] blk_mq_do_dispatch_sched+0x1d9/0x260
[ 34.454561] blk_mq_sched_dispatch_requests+0x3da/0x4b0
[ 34.458789] __blk_mq_run_hw_queue+0xae/0x130
[ 34.460001] __blk_mq_delay_run_hw_queue+0x192/0x280
[ 34.460823] blk_mq_run_hw_queue+0x10b/0x1b0
[ 34.463240] blk_mq_sched_insert_request+0x3bd/0x4d0
[ 34.467342] blk_execute_rq+0xcf/0x140
[ 34.468483] sg_io+0x2f7/0x730

Can anyone tell me more about the memory allocation layout of the
various variables here? It looks like struct request is a header in
front of struct scsi_request? How do struct elevator_queue, struct
blk_mq_ctx, and struct blk_mq_hw_ctx overlap these?

Regardless, I'll check for elevator data changing too...

-Kees

--
Kees Cook
Pixel Security