]> git.baikalelectronics.ru Git - kernel.git/commit
nbd: freeze the queue while we're adding connections
authorJosef Bacik <josef@toxicpanda.com>
Mon, 25 Jan 2021 17:21:02 +0000 (12:21 -0500)
committerJens Axboe <axboe@kernel.dk>
Mon, 25 Jan 2021 18:04:50 +0000 (11:04 -0700)
commit1d3b85a12052da8ccd82d4a7544329c7782a152a
treee93fee7dd3d2fe7f6af89de22cc35061bede0dc4
parentfe30c4dc6e9466fb0acb570b49f255571b9ba5bc
nbd: freeze the queue while we're adding connections

When setting up a device, we can krealloc the config->socks array to add
new sockets to the configuration.  However if we happen to get a IO
request in at this point even though we aren't setup we could hit a UAF,
as we deref config->socks without any locking, assuming that the
configuration was setup already and that ->socks is safe to access it as
we have a reference on the configuration.

But there's nothing really preventing IO from occurring at this point of
the device setup, we don't want to incur the overhead of a lock to
access ->socks when it will never change while the device is running.
To fix this UAF scenario simply freeze the queue if we are adding
sockets.  This will protect us from this particular case without adding
any additional overhead for the normal running case.

Cc: stable@vger.kernel.org
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/nbd.c