In the Linux kernel, the following vulnerability has been resolved:
virtio-blk: Avoid use-after-free on suspend/resume
hctx->userdata is set to vq in virtblkinithctx(). However, vq is freed on suspend and reallocated on resume. So, hctx->userdata is invalid after resume, and it will cause use-after-free accessing which will result in the kernel crash something like below:
[ 22.428391] Call Trace: [ 22.428899] <TASK> [ 22.429339] virtqueueaddsplit+0x3eb/0x620 [ 22.430035] ? _blkmqallocrequests+0x17f/0x2d0 [ 22.430789] ? kvmclockgetcycles+0x14/0x30 [ 22.431496] virtqueueaddsgs+0xad/0xd0 [ 22.432108] virtblkaddreq+0xe8/0x150 [ 22.432692] virtioqueuerqs+0xeb/0x210 [ 22.433330] blkmqflushpluglist+0x1b8/0x280 [ 22.434059] _blkflushplug+0xe1/0x140 [ 22.434853] blkfinishplug+0x20/0x40 [ 22.435512] readpages+0x20a/0x2e0 [ 22.436063] ? folioaddlru+0x62/0xa0 [ 22.436652] pagecacheraunbounded+0x112/0x160 [ 22.437365] filemapgetpages+0xe1/0x5b0 [ 22.437964] ? contexttosid+0x70/0x100 [ 22.438580] ? sidtabcontexttosid+0x32/0x400 [ 22.439979] filemapread+0xcd/0x3d0 [ 22.440917] xfsfilebufferedread+0x4a/0xc0 [ 22.441984] xfsfilereaditer+0x65/0xd0 [ 22.442970] _kernelread+0x160/0x2e0 [ 22.443921] bprmexecve+0x21b/0x640 [ 22.444809] doexecveatcommon.isra.0+0x1a8/0x220 [ 22.446008] _x64sysexecve+0x2d/0x40 [ 22.446920] dosyscall64+0x37/0x90 [ 22.447773] entrySYSCALL64afterhwframe+0x63/0xcd
This patch fixes this issue by getting vq from vblk, and removes virtblkinithctx().