]> git.baikalelectronics.ru Git - kernel.git/commit
xen-blkback: fix persistent grants negotiation
authorSeongJae Park <sj@kernel.org>
Fri, 15 Jul 2022 22:51:06 +0000 (22:51 +0000)
committerJuergen Gross <jgross@suse.com>
Fri, 12 Aug 2022 10:13:46 +0000 (12:13 +0200)
commitbd4a11959f36a0f202dd5328f65a811674de3d7e
tree5b21db057d98fe9519d8becea175d12c89c0f956
parent134878b9714d982a8022f91ae3818eecefbacef0
xen-blkback: fix persistent grants negotiation

Persistent grants feature can be used only when both backend and the
frontend supports the feature.  The feature was always supported by
'blkback', but commit 3d14b04b1cc9 ("xen-blkback: add a parameter for
disabling of persistent grants") has introduced a parameter for
disabling it runtime.

To avoid the parameter be updated while being used by 'blkback', the
commit caches the parameter into 'vbd->feature_gnt_persistent' in
'xen_vbd_create()', and then check if the guest also supports the
feature and finally updates the field in 'connect_ring()'.

However, 'connect_ring()' could be called before 'xen_vbd_create()', so
later execution of 'xen_vbd_create()' can wrongly overwrite 'true' to
'vbd->feature_gnt_persistent'.  As a result, 'blkback' could try to use
'persistent grants' feature even if the guest doesn't support the
feature.

This commit fixes the issue by moving the parameter value caching to
'xen_blkif_alloc()', which allocates the 'blkif'.  Because the struct
embeds 'vbd' object, which will be used by 'connect_ring()' later, this
should be called before 'connect_ring()' and therefore this should be
the right and safe place to do the caching.

Fixes: 3d14b04b1cc9 ("xen-blkback: add a parameter for disabling of persistent grants")
Cc: <stable@vger.kernel.org> # 5.10.x
Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
Signed-off-by: SeongJae Park <sj@kernel.org>
Reviewed-by: Maximilian Heyne <mheyne@amazon.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20220715225108.193398-2-sj@kernel.org
Signed-off-by: Juergen Gross <jgross@suse.com>
drivers/block/xen-blkback/xenbus.c