From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.simonwunderlich.de (mail.simonwunderlich.de [23.88.38.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E317E366066; Tue, 30 Jun 2026 13:50:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=23.88.38.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782827415; cv=none; b=uUINTX5x4fnHrnrrQRWdsMnVN2G2TfRjHP81+ZF+31kHQLPrqZnbZkimSTnnea+zf3vodMiN7d50HQc8UXAsy4Of8OzgQQJChtsPpRvc3yrVuaYwwU0rNZzQN+DiXyCiCNQrsrTrK+srRC7Z/9jX5oLQJC76urjOiiiDXq9JwdA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782827415; c=relaxed/simple; bh=OARHgQ2UZkaBI0aNWjDfeM2ltbp2KYNcjq4HRzlHjSo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HTlU4z5r6WnoC5it6WgohsMfLV7UFsL1Qd4O0kJ2hY5x2wLbWiA7D6NVxJimcw1iBX/fNvcWB23KF5BXkSApc/y+QTjAMnhzLPkTr0b4ANqDscWoFfbOC28q4aSMsq0qtsGcx/eCPPApIqrqjpms56VYSCofP+wA4JotcDZyTTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=simonwunderlich.de; spf=pass smtp.mailfrom=simonwunderlich.de; dkim=pass (2048-bit key) header.d=simonwunderlich.de header.i=@simonwunderlich.de header.b=1CRTiOeA; arc=none smtp.client-ip=23.88.38.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=simonwunderlich.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=simonwunderlich.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=simonwunderlich.de header.i=@simonwunderlich.de header.b="1CRTiOeA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=simonwunderlich.de; s=09092022; t=1782827074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SiIK0ISh6k4aQjZejSleIeHh0c9JnPFk+A63O8+Yixs=; b=1CRTiOeAAZM8h6sEfcYh0sAkV+2Dt1H8ekbdwWd66z3t6SF/DCXLDasSEAYsLc4GBV3rV6 olFVTPgZvt/WDmrkgFh2qt0t3ixGncqyOBQCToabMuv35cRys3n0fLNfheGmpSDXQWU1jI 72tTym77n3PSOzHFFQ+lm9FeMQH6kY/BaD7chEglT+BqbtcphNOfKRMDlhf2iTaXlAXmaB NWqTu19ucBX1BlVKtg1C9mKJUfMkB4muXcLlKii1Kb86xjovtRjGfSQvL0ekMskPtjBS5T taILNb1ACCrGffX21stG7z0ZeMsGDH5pvb698H4unY+TIRV1JVXs3MEmuOO8kQ== From: Simon Wunderlich To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , b.a.t.m.a.n@lists.open-mesh.org, Sven Eckelmann , stable@vger.kernel.org, Simon Wunderlich Subject: [PATCH net 4/6] batman-adv: dat: acquire ARP hw source only after skb realloc Date: Tue, 30 Jun 2026 15:44:28 +0200 Message-ID: <20260630134430.85786-5-sw@simonwunderlich.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260630134430.85786-1-sw@simonwunderlich.de> References: <20260630134430.85786-1-sw@simonwunderlich.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Sven Eckelmann The pskb_may_pull() called by batadv_get_vid() could reallocate the buffer behind the skb. Variables which were pointing to the old buffer need to be reassigned to avoid an use-after-free. Cc: stable@vger.kernel.org Fixes: b61ec31c8575 ("batman-adv: Snoop DHCPACKs for DAT") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/distributed-arp-table.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index ae39ceaa2e29a..ead02c9e08484 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -1747,6 +1747,7 @@ void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv, struct ethhdr *ethhdr; __be32 ip_src, yiaddr; unsigned short vid; + int hdr_size_tmp; __be16 proto; u8 *hw_src; @@ -1763,8 +1764,10 @@ void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv, if (!batadv_dat_check_dhcp_ack(skb, proto, &ip_src, chaddr, &yiaddr)) return; + hdr_size_tmp = hdr_size; + vid = batadv_dat_get_vid(skb, &hdr_size_tmp); + ethhdr = (struct ethhdr *)(skb->data + hdr_size); hw_src = ethhdr->h_source; - vid = batadv_dat_get_vid(skb, &hdr_size); batadv_dat_entry_add(bat_priv, yiaddr, chaddr, vid); batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid); -- 2.47.3