Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3733290imm; Mon, 8 Oct 2018 08:40:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV61qknA6osVvs7AQivtm91Y99qzzbuSnZY2KgpIpZMayiuqJfu78QQAdsdqqxRZWuHZPnT2N X-Received: by 2002:a63:2ad4:: with SMTP id q203-v6mr21096490pgq.356.1539013235864; Mon, 08 Oct 2018 08:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539013235; cv=none; d=google.com; s=arc-20160816; b=aWv1xhKgybZ3m6nnZeMsR+WI1G9okv/NtQvxQ4nyV9hKn8MEskB0Z7t/ejofrQORQg BzYuPemPnFeSgMxw2/YfTMbY4B9QpGgyf1LpH+RSu9y+Oko88p71FIe/KStJXdJIchsD BWg+ttHZSEyUnraBh32bm5+xjxw+N3jIy0ludWa1Q450bJr2Cuc6swXebGGnStNYqXzC o0cS8jckMzL7BnJg4CfRUSppfFPYbOtDKfE1MeloDmYbX2bk4KFCWVocbowCHwa8kgHm yLsiNoFL7rl+Rkip9RY/vpBR+5CnXaIsAzLOSRfPsfsnoR6UbmXMS5sedbzLPhIQ7UYs koAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Oges1V89VOy9YgIYj1Ung3iqzq8ZBMNPjMMb98bSmFM=; b=EHOFRcEwOsf71WPxO6DSyC1BXlsn9iK5cxX9jHi1Ea29yyLS7BNYKFgYfI4gVyJ8m5 b5vKADufJVtp7+T/QI2102OPJ+hMcTFC6o25IPGZ8rq6CJPBKHxUbslzyvsn7Nr/kUiJ 8lrqsAiuiulIsCV3VbtN0b5hpPXcZ8+onlly6mYlrJE1URem8ZkRfZoUwFMho2VyKy+O 7YDgkpuqdXQIFeCnZx+6AqQPbll0Cb8pZZ80nLsXm3raUW30iP13rDRq3E+A9MmctksL jnhIX5CkrcW5lfwGuKkDpIQhbnjOphR0YrtqcIQQCNxP05CU7xES6d8F0oouL+x+niYk A5mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zMSrxTwU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5-v6si17194192plz.175.2018.10.08.08.40.21; Mon, 08 Oct 2018 08:40:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zMSrxTwU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727642AbeJHWvW (ORCPT + 99 others); Mon, 8 Oct 2018 18:51:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:55846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726665AbeJHWht (ORCPT ); Mon, 8 Oct 2018 18:37:49 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EEB0020890; Mon, 8 Oct 2018 15:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012334; bh=Ab/H869GExC6LwFLXGHC8lhQJucdJaCNVjCuBqJ0pOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zMSrxTwUioTyhQfJnn1zPIRiU3ajhbql9YArZPDHwCZ/A7MMLZo4UCgURJOLd5udx zIRd/mr4o00e3wPlxEE2hlQAt+ofjCRFXBVbLknfTO17wM9B3tfxhlBkrFu7VkfncY KoODIteDqsJnI03/+jhIDJP3NkwypEDqShk5r9ac= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sven Eckelmann , Simon Wunderlich , Sasha Levin Subject: [PATCH AUTOSEL 4.18 07/58] batman-adv: Fix segfault when writing to throughput_override Date: Mon, 8 Oct 2018 11:24:32 -0400 Message-Id: <20181008152523.70705-7-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sven Eckelmann [ Upstream commit b9fd14c20871e6189f635e49b32d7789e430b3c8 ] The per hardif sysfs file "batman_adv/throughput_override" prints the resulting change as info text when the users writes to this file. It uses the helper function batadv_info to add it at the same time to the kernel ring buffer and to the batman-adv debug log (when CONFIG_BATMAN_ADV_DEBUG is enabled). The function batadv_info requires as first parameter the batman-adv softif net_device. This parameter is then used to find the private buffer which contains the debug log for this batman-adv interface. But batadv_store_throughput_override used as first argument the slave net_device. This slave device doesn't have the batadv_priv private data which is access by batadv_info. Writing to this file with CONFIG_BATMAN_ADV_DEBUG enabled can either lead to a segfault or to memory corruption. Fixes: 0b5ecc6811bd ("batman-adv: add throughput override attribute to hard_ifaces") Signed-off-by: Sven Eckelmann Acked-by: Marek Lindner Signed-off-by: Simon Wunderlich Signed-off-by: Sasha Levin --- net/batman-adv/sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index f2eef43bd2ec..3a76e8970c02 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c @@ -1090,8 +1090,9 @@ static ssize_t batadv_store_throughput_override(struct kobject *kobj, if (old_tp_override == tp_override) goto out; - batadv_info(net_dev, "%s: Changing from: %u.%u MBit to: %u.%u MBit\n", - "throughput_override", + batadv_info(hard_iface->soft_iface, + "%s: %s: Changing from: %u.%u MBit to: %u.%u MBit\n", + "throughput_override", net_dev->name, old_tp_override / 10, old_tp_override % 10, tp_override / 10, tp_override % 10); -- 2.17.1