Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2081701imu; Wed, 28 Nov 2018 22:03:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/WML9QLsP9H4dHW7ApJGLN9uh0lBvrDQ0CIYFl9Te/6j3LZpVo8iFidoS0ONHMWZtmluH3N X-Received: by 2002:a63:9a09:: with SMTP id o9mr175678pge.94.1543471409180; Wed, 28 Nov 2018 22:03:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543471409; cv=none; d=google.com; s=arc-20160816; b=b6dVVjujmpzUrCvWYt3SBx+yS9UJYmlCwAyKF4s0XgT4xfNTfURLnBm0+pSRBE7awQ U4yzeakDQrPOY9I9NQJGtFGM9D9ZraxlslOIZPo54+CxtZrdu2iAYGBoBZ5Oqw4aPDD8 lCaWq9mub7TJzfhP3HZyMRO54LoWR9l2CMLPLHtbZo/bb+GI+CyjMqm202jAHosKoSCn 9bRB+chs1iAl/+OWlXP6X00nD7aw8PKLurAWZj0O0PVjKXNLwYg57kdz8ogRzDtLqL3K swJ2dwb5UecC2WXShvlaFnPkLbOChvyahY88B5f+8Ol2nsSTnr/MstT+aPsIDN664xBR m2IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KYiW6ofADyeA9tSx8iKbPEPXz8pRkZVv1pKo+dVgDYA=; b=P6xIKzJeWVWaY+rcyNZUnN0femQYKkMse3jcW9AkPgZyb9M1Bxb5yB03mElDMIGhRP erG2W7dH9EpOt+TBU7iUyNa7wJ1pX783d47w/2LyYkDVvi8W7rp88ruSPNj3WAPGUJWi /7d6Qk2G1dDQECZCmdHY+kqQJ+bYJJW8DdklIsYaOri2F/dFsiikMFNgWC/GSeHLMHpC w3Wqw8LG3EgntxaGM2QZK7Ao/F0KXoziCn+z/Dqk8HsA07X+VxDdMBHc9l336zfYzt2I 8F7hqN4Ph+nmJGUQheC0VEQ9gz8dtzCH7/5NbgwXm33choWqszLtoQafaYa4ju//g5vU ihqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i94ZVvI4; 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 n13si916213pgp.307.2018.11.28.22.03.14; Wed, 28 Nov 2018 22:03:29 -0800 (PST) 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=i94ZVvI4; 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 S1729483AbeK2RGD (ORCPT + 99 others); Thu, 29 Nov 2018 12:06:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:41810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727767AbeK2RGC (ORCPT ); Thu, 29 Nov 2018 12:06:02 -0500 Received: from sasha-vm.mshome.net (unknown [37.142.5.207]) (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 ECC262133F; Thu, 29 Nov 2018 06:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543471311; bh=Mx7+KsXK00elBz1ONarUvnYlw/dP+iqIBqHWxbaHHaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i94ZVvI4IQgu2G6+pyApk9cRiwSt1KdR9n/OPJQjYqvvngjz+XtGga1+SJA1vGEct Z8aImOjoxXWTY5ZmzoDep5wQ9vwiudcg+VcgNQn/H6szQMIXkKwfOQzjrZ7yAO4zXq O1rj5HR3KVOD43NJEsY49MGFA7MXuzkfOCCAzbVY= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sven Eckelmann , Simon Wunderlich , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 09/35] batman-adv: Expand merged fragment buffer for full packet Date: Thu, 29 Nov 2018 01:00:43 -0500 Message-Id: <20181129060110.159878-9-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129060110.159878-1-sashal@kernel.org> References: <20181129060110.159878-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sven Eckelmann [ Upstream commit d7d8bbb40a5b1f682ee6589e212934f4c6b8ad60 ] The complete size ("total_size") of the fragmented packet is stored in the fragment header and in the size of the fragment chain. When the fragments are ready for merge, the skbuff's tail of the first fragment is expanded to have enough room after the data pointer for at least total_size. This means that it gets expanded by total_size - first_skb->len. But this is ignoring the fact that after expanding the buffer, the fragment header is pulled by from this buffer. Assuming that the tailroom of the buffer was already 0, the buffer after the data pointer of the skbuff is now only total_size - len(fragment_header) large. When the merge function is then processing the remaining fragments, the code to copy the data over to the merged skbuff will cause an skb_over_panic when it tries to actually put enough data to fill the total_size bytes of the packet. The size of the skb_pull must therefore also be taken into account when the buffer's tailroom is expanded. Fixes: 610bfc6bc99b ("batman-adv: Receive fragmented packets and merge") Reported-by: Martin Weinelt Co-authored-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Sasha Levin --- net/batman-adv/fragmentation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c index b6abd19ab23e..c6d37d22bd12 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -274,7 +274,7 @@ batadv_frag_merge_packets(struct hlist_head *chain) kfree(entry); packet = (struct batadv_frag_packet *)skb_out->data; - size = ntohs(packet->total_size); + size = ntohs(packet->total_size) + hdr_size; /* Make room for the rest of the fragments. */ if (pskb_expand_head(skb_out, 0, size - skb_out->len, GFP_ATOMIC) < 0) { -- 2.17.1