xenbus/backend: Protect xenbus callback with lock

[ Upstream commit 060eabe8fbe726aca341b518366da4d79e338100 ]

A driver's 'reclaim_memory' callback can race with 'probe' or 'remove'
because it will be called whenever memory pressure is detected.  To
avoid such race, this commit embeds a spinlock in each 'xenbus_device'
and make 'xenbus' to hold the lock while the corresponded callbacks are
running.

Reviewed-by: Juergen Gross <[email protected]>
Signed-off-by: SeongJae Park <[email protected]>
Signed-off-by: Boris Ostrovsky <[email protected]>
Stable-dep-of: afc545da381b ("xen: Fix the issue of resource not being properly released in xenbus_dev_probe()")
Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
SeongJae Park 2020-01-27 09:18:09 +01:00 • committed by Greg Kroah-Hartman
commit 7c138d1284
3 changed files with 16 additions and 3 deletions

View file

@ -85,6 +85,7 @@ struct xenbus_device {
enum xenbus_state state;
struct completion down;
struct work_struct work;
spinlock_t reclaim_lock;
};
static inline struct xenbus_device *to_xenbus_device(struct device *dev)