]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
block: nr_sects_write(): Disable preemption on seqcount write
authorAhmed S. Darwish <a.darwish@linutronix.de>
Wed, 3 Jun 2020 14:49:48 +0000 (16:49 +0200)
committerKhalid Elmously <khalid.elmously@canonical.com>
Sat, 8 Aug 2020 05:53:12 +0000 (01:53 -0400)
commit88251317b10e384fa8a62b10e11eda1d8ee90d21
treeec263f3899684e1b428d4d3ebc4b1997004969c9
parent93e8e5ff2bac73d7570db38677974a2e97aa900b
block: nr_sects_write(): Disable preemption on seqcount write

BugLink: https://bugs.launchpad.net/bugs/1885322
[ Upstream commit 15b81ce5abdc4b502aa31dff2d415b79d2349d2f ]

For optimized block readers not holding a mutex, the "number of sectors"
64-bit value is protected from tearing on 32-bit architectures by a
sequence counter.

Disable preemption before entering that sequence counter's write side
critical section. Otherwise, the read side can preempt the write side
section and spin for the entire scheduler tick. If the reader belongs to
a real-time scheduling class, it can spin forever and the kernel will
livelock.

Fixes: c83f6bf98dc1 ("block: add partition resize function to blkpg ioctl")
Cc: <stable@vger.kernel.org>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
include/linux/genhd.h