Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4116458pxk; Tue, 8 Sep 2020 11:06:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5q6huNK2MykLFk6i72gfEovqMUVsCsHE/JYUrz3SVLSCA4H3qMuPmrCRnyWgJDyzFIq6J X-Received: by 2002:a05:6402:17f6:: with SMTP id t22mr177310edy.374.1599588399904; Tue, 08 Sep 2020 11:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599588399; cv=none; d=google.com; s=arc-20160816; b=a6NxiGhAFuWKMVRx9ysHDC9n566XiAtRTpeytiVCBxnW7N7DcgqAPvrqDnqyi5W29j yPWb/sN/PlWq+a48N0NJm9QoQNlWX5S9gH1QPMhvOgNjOkqvYdkBpv8/t0FbjsOvz9z6 yMRYi2dd1/SX1g3XkKtijde33JKQbQLhssk6LW/E8ftp9Bdr9Mj1XZjuLF9HCbZnZTKx QYMC8JhP4MKS/m/8CO4zDW97WM7jzr8MSAjsYIa+p4DV0RPysD4nrRoTYTHBpLm4a8HZ aJb/fE8DMwGgX3eVQqTEQJ3ao2NJAGoMXowCnW96wkXZmC5LH2PGdw2q/1fVgNtnLpNJ DFyQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CQIzlUAqO49/mhB6QpkaYeTWE9WZQpxnTdjCbhD8i+E=; b=xl4JsnVPnYcozOI5UQVrytiniFDZyj4Ya3p+T9SWPPPPtRgUoOle1GxUmUWZenGBM2 um3/bWSLjc0Mh4rzIS2bC0ETXW9lsWHtUAV3SdT/yEYBR00eiC14VYP3AgL63gmhFgYP KTOGCH/cAYNEiZoM/8oXQVjQQG00V151g9AhQtDgYgp+HKnx5ptjUrg7Eip4JWN1Ul52 B7djJex0FErn45vbaaxOwgFXF16pE7qOI82DcPF9/33dK7KP/npUzo7y4/avuNr8DsEm SbUY7Tv5E/289+4BTTgSyM1wIxEu9oSkSBevTriyazty5b9tu8J+StxJ4En2vbMQxt0I f/gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ox286CfT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h19si11826013ejl.253.2020.09.08.11.06.16; Tue, 08 Sep 2020 11:06:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ox286CfT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732199AbgIHSFJ (ORCPT + 99 others); Tue, 8 Sep 2020 14:05:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:56084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731519AbgIHQMK (ORCPT ); Tue, 8 Sep 2020 12:12:10 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1EE4E2478F; Tue, 8 Sep 2020 15:51:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599580279; bh=oszbqs7PEBghjGCl+rJ3kmEUWpwsIgRPGgvaQAx0z2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ox286CfTG3JhqcfLgHnKI423JgvxtEtyu6fYRagF4ILGOWo/qrwR08LIn+a5Uh3aP AW3sMHk9w2ol9IO9E/f8potJH4rZQZmLvV7WVqUhWAWs13oNRIyObwRPZAEQKDlMxH kQvP1eV2hS1AgnDTmBk3ABDLLSi589SO9w+ELXSI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+ab16e463b903f5a37036@syzkaller.appspotmail.com, Sven Eckelmann , Antonio Quartulli , Simon Wunderlich , Sasha Levin Subject: [PATCH 4.14 12/65] batman-adv: Avoid uninitialized chaddr when handling DHCP Date: Tue, 8 Sep 2020 17:25:57 +0200 Message-Id: <20200908152217.659257918@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152217.022816723@linuxfoundation.org> References: <20200908152217.022816723@linuxfoundation.org> User-Agent: quilt/0.66 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 303216e76dcab6049c9d42390b1032f0649a8206 ] The gateway client code can try to optimize the delivery of DHCP packets to avoid broadcasting them through the whole mesh. But also transmissions to the client can be optimized by looking up the destination via the chaddr of the DHCP packet. But the chaddr is currently only done when chaddr is fully inside the non-paged area of the skbuff. Otherwise it will not be initialized and the unoptimized path should have been taken. But the implementation didn't handle this correctly. It didn't retrieve the correct chaddr but still tried to perform the TT lookup with this uninitialized memory. Reported-by: syzbot+ab16e463b903f5a37036@syzkaller.appspotmail.com Fixes: 6c413b1c22a2 ("batman-adv: send every DHCP packet as bat-unicast") Signed-off-by: Sven Eckelmann Acked-by: Antonio Quartulli Signed-off-by: Simon Wunderlich Signed-off-by: Sasha Levin --- net/batman-adv/gateway_client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index c6a7341f05270..056af2eec4a2a 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -674,8 +674,10 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, chaddr_offset = *header_len + BATADV_DHCP_CHADDR_OFFSET; /* store the client address if the message is going to a client */ - if (ret == BATADV_DHCP_TO_CLIENT && - pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) { + if (ret == BATADV_DHCP_TO_CLIENT) { + if (!pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) + return BATADV_DHCP_NO; + /* check if the DHCP packet carries an Ethernet DHCP */ p = skb->data + *header_len + BATADV_DHCP_HTYPE_OFFSET; if (*p != BATADV_DHCP_HTYPE_ETHERNET) -- 2.25.1