Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4141183pxk; Tue, 8 Sep 2020 11:41:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWvLTzISQxABN34sh5uMlVJTOsJdg24PnLi28rwHRUl+gRpMVoDF6U2Cx2yeZ3hGYC3rP1 X-Received: by 2002:a17:906:3955:: with SMTP id g21mr27985434eje.69.1599590518116; Tue, 08 Sep 2020 11:41:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599590518; cv=none; d=google.com; s=arc-20160816; b=Q6sefdatBt++CrKHnZ/2+Ev07d4Xw74zGb9SImrj7wgcJDWo6NXFwtaFCS7qOaHPrv 3f49ht5ykv1PHUvIaTxRNPMjTlx1gtv14tPLpUq+FszoMnljFkLSx3sA2kHZAqS5qBmP cp6n9CTRSIbjYaTMJWK9D9i8nvII7LhZ9j6JBQvVWazFjQqXsFOILFJm4utsSy1D1Jk0 Hagmrnad1Bpc8XDegQa5dUi8OVwiQ2JojI5G/siQc3HIe9WZlU7NFcTGtV1G7BlA98MK sj01YmwW4CI0lYHxQaaU/8hwlJ7/Hi8kg9x74Shulpf8VAwuyKY14UhwNKqsi1vd4FSY fbYQ== 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=VfIG9BW/dk+jdrGf9z4tUi8lEBpR5h+10upfRZyLAWU=; b=p3zyzcRh0joJGimiIjoQ62HZdD7wqGqdu5qR/UmUn91ZahgnKG/Y+XuQ2jGjhb9VQh Was7L+dItZ4VXp0HnbgwIpSf73DRCdXI9vfC0P21OZYMvyZB7d+rlc1zGRIZa8j/XL0R 2mJYzAP8kISdQJSHaK+5NvlULkikkJlhKDws2rsjdy5E0Z+MRebMnyQW+c0c9adnpZzf mMUcKQKtTjoNrbFHQ69Eok2n9civkGlq/wUBCU2xUmTBIgw1/0O/yK6e+JQaL1nRIYco mm8MuQgqfOkNWYe0upkoolyZg7gOsLPGUSej0CzuQBYqmIFHrENh2ZI5z0BvGh/eR9sE eTkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EShjXUOL; 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 p2si2219305ejf.310.2020.09.08.11.41.35; Tue, 08 Sep 2020 11:41:58 -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=EShjXUOL; 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 S1731440AbgIHSia (ORCPT + 99 others); Tue, 8 Sep 2020 14:38:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:55372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731341AbgIHQJA (ORCPT ); Tue, 8 Sep 2020 12:09:00 -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 BE2CC2413B; Tue, 8 Sep 2020 15:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599580141; bh=l5pXDIH58BbziP64ptPqTw2F3wmrA802mD+6ENN3vkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EShjXUOLvLyrI6jqW2CEL+Pi+hh1+5MTPK7EZVYP9Dj2xNA30NtwTQvdMxJDZzZ/n 8K549Cv3kbxpBwQdcR88cS8QEzdTfZtdSwfg5Avy6pRe96PW6T6tOA9tblDQolp6bD sq++b+o3ssRuBQeaa/yuo2fs/MR/dH/k6xGfymZ4= 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.19 16/88] batman-adv: Avoid uninitialized chaddr when handling DHCP Date: Tue, 8 Sep 2020 17:25:17 +0200 Message-Id: <20200908152221.888974886@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152221.082184905@linuxfoundation.org> References: <20200908152221.082184905@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 140c61a3f1ecf..0c59fefc13719 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -714,8 +714,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