batman-adv: Refresh patches
[feed/routing.git] / batman-adv / patches / 0047-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: 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 diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
28 index 17c844196eb26c9faf9fd543b88cd86cc1c2c029..ae22db3d6637dde2fcc238826a624ef2d6dbd8f5 100644
29 --- a/net/batman-adv/sysfs.c
30 +++ b/net/batman-adv/sysfs.c
31 @@ -1078,8 +1078,9 @@ static ssize_t batadv_store_throughput_override(struct kobject *kobj,
32 if (old_tp_override == tp_override)
33 goto out;
34
35 - batadv_info(net_dev, "%s: Changing from: %u.%u MBit to: %u.%u MBit\n",
36 - "throughput_override",
37 + batadv_info(hard_iface->soft_iface,
38 + "%s: %s: Changing from: %u.%u MBit to: %u.%u MBit\n",
39 + "throughput_override", net_dev->name,
40 old_tp_override / 10, old_tp_override % 10,
41 tp_override / 10, tp_override % 10);
42