batman-adv: Merge bugfixes from 2018.3
[feed/routing.git] / batman-adv / patches / 0013-batman-adv-Fix-segfault-when-writing-to-throughput_o.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Fri, 31 Aug 2018 16:46:47 +0200
3 Subject: [PATCH] batman-adv: Fix segfault when writing to throughput_override
4
5 The per hardif sysfs file "batman_adv/throughput_override" prints the
6 resulting change as info text when the users writes to this file. It uses
7 the helper function batadv_info to add it at the same time to the kernel
8 ring buffer and to the batman-adv debug log (when CONFIG_BATMAN_ADV_DEBUG
9 is enabled).
10
11 The function batadv_info requires as first parameter the batman-adv softif
12 net_device. This parameter is then used to find the private buffer which
13 contains the debug log for this batman-adv interface. But
14 batadv_store_throughput_override used as first argument the slave
15 net_device. This slave device doesn't have the batadv_priv private data
16 which is access by batadv_info.
17
18 Writing to this file with CONFIG_BATMAN_ADV_DEBUG enabled can either lead
19 to a segfault or to memory corruption.
20
21 Fixes: c513176e4b7a ("batman-adv: add throughput override attribute to hard_ifaces")
22 Signed-off-by: Sven Eckelmann <sven@narfation.org>
23 Acked-by: Marek Lindner <mareklindner@neomailbox.ch>
24
25 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/ddf99b78e255530cbadc0f67656a549e19520280
26 ---
27 net/batman-adv/sysfs.c | 5 +++--
28 1 file changed, 3 insertions(+), 2 deletions(-)
29
30 diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
31 index f2eef43bd2ec5b798ba552ff14eedcfa734b39d6..3a76e8970c025ca6917d6cd15d1382f685cd3532 100644
32 --- a/net/batman-adv/sysfs.c
33 +++ b/net/batman-adv/sysfs.c
34 @@ -1090,8 +1090,9 @@ static ssize_t batadv_store_throughput_override(struct kobject *kobj,
35 if (old_tp_override == tp_override)
36 goto out;
37
38 - batadv_info(net_dev, "%s: Changing from: %u.%u MBit to: %u.%u MBit\n",
39 - "throughput_override",
40 + batadv_info(hard_iface->soft_iface,
41 + "%s: %s: Changing from: %u.%u MBit to: %u.%u MBit\n",
42 + "throughput_override", net_dev->name,
43 old_tp_override / 10, old_tp_override % 10,
44 tp_override / 10, tp_override % 10);
45