xen/xenbus: avoid large structs and arrays on the stack
authorJuergen Gross <jgross@suse.com>
Wed, 1 Jul 2020 12:16:37 +0000 (14:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Jul 2020 07:34:01 +0000 (09:34 +0200)
commit41b016e0f6595b118b0c8b393257a8d3c093a9af
treecf39fc6ecb00fa0a4eb2164eaf95bf182ac63be4
parent15cc8626e3284547ee0acfd853dd4b5b089ce5ea
xen/xenbus: avoid large structs and arrays on the stack

[ Upstream commit 3848e4e0a32afb96dc3b84e1358c3b9d103c6a2c ]

xenbus_map_ring_valloc() and its sub-functions are putting quite large
structs and arrays on the stack. This is problematic at runtime, but
might also result in build failures (e.g. with clang due to the option
-Werror,-Wframe-larger-than=... used).

Fix that by moving most of the data from the stack into a dynamically
allocated struct. Performance is no issue here, as
xenbus_map_ring_valloc() is used only when adding a new PV device to
a backend driver.

While at it move some duplicated code from pv/hvm specific mapping
functions to the single caller.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: https://lore.kernel.org/r/20200701121638.19840-2-jgross@suse.com
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/xen/xenbus/xenbus_client.c