All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH maint] batman-adv: Avoid uninitialized chaddr when handling DHCP
@ 2020-07-22 18:49 Sven Eckelmann
  2020-07-22 19:26 ` Antonio Quartulli
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Eckelmann @ 2020-07-22 18:49 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann, syzbot+ab16e463b903f5a37036

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: 2d5b555644b2 ("batman-adv: send every DHCP packet as bat-unicast")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 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 a18dcc68..ef3f85b5 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -703,8 +703,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.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH maint] batman-adv: Avoid uninitialized chaddr when handling DHCP
  2020-07-22 18:49 [PATCH maint] batman-adv: Avoid uninitialized chaddr when handling DHCP Sven Eckelmann
@ 2020-07-22 19:26 ` Antonio Quartulli
  0 siblings, 0 replies; 2+ messages in thread
From: Antonio Quartulli @ 2020-07-22 19:26 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking,
	Sven Eckelmann
  Cc: syzbot+ab16e463b903f5a37036

On 22/07/2020 20:49, Sven Eckelmann wrote:
> 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: 2d5b555644b2 ("batman-adv: send every DHCP packet as bat-unicast")
> Signed-off-by: Sven Eckelmann <sven@narfation.org>

Acked-by: Antonio Quartulli <a@unstable.cc>

-- 
Antonio Quartulli

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-22 19:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 18:49 [PATCH maint] batman-adv: Avoid uninitialized chaddr when handling DHCP Sven Eckelmann
2020-07-22 19:26 ` Antonio Quartulli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.