From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D384F1A0BFD; Sun, 7 Sep 2025 20:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757277204; cv=none; b=UB3NikvVL7WAQOJx3eberOTIA0Ta6CL0i+xTbGvTyR3NbBjvNRKH273FiWdlb+CcPRMWj7M7ysWOm2L5gW37rxF3AaDutcIaUzxrRgfbdjlxfXvLzGmgQAd+atJoJSGGfbnGE+Ern2P+ZFNmdX17zuXbupWqU9CWlGih1Az6Ks0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757277204; c=relaxed/simple; bh=DRdKA+mAM4cT60PctQOV96VY7BLF9NlPvslN5KTYsQY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jMBK+tFsn/GeRKMz/g3CDeKCrcGDP9WGNzo09NWDqbTuqJGiIJpnCmhWTXlEh9qLgKvh/73yTr21KXF2XHDn7DxwSSduWSk3oJZuyWUl+LAa57vPErwoO/X1P+EW0q24gcikfL3olfTcW8bDtwNSk43bkqiKmoF/YT1ryehV1N4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lGw3trjZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lGw3trjZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0202EC4CEF0; Sun, 7 Sep 2025 20:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757277204; bh=DRdKA+mAM4cT60PctQOV96VY7BLF9NlPvslN5KTYsQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lGw3trjZYVnrwkX8U0eH+OMIO1OTnjxzaW2Lfzxyw+6xAVmYBnVHixX8Zi4JqnyrT AH0Y2VAnrHUi5gvK3rCOkn2GHOVs17CRNDyR03f/hDRouhBqJGkayCXWvaupCj+FOq Zc9NH+uDz1r/fpbyJLQxi33PD9ra3vPmy8gdZTms= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stanislav Fort , Stanislav Fort , Sven Eckelmann , Simon Wunderlich Subject: [PATCH 6.12 117/175] batman-adv: fix OOB read/write in network-coding decode Date: Sun, 7 Sep 2025 21:58:32 +0200 Message-ID: <20250907195617.626065964@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250907195614.892725141@linuxfoundation.org> References: <20250907195614.892725141@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stanislav Fort commit d77b6ff0ce35a6d0b0b7b9581bc3f76d041d4087 upstream. batadv_nc_skb_decode_packet() trusts coded_len and checks only against skb->len. XOR starts at sizeof(struct batadv_unicast_packet), reducing payload headroom, and the source skb length is not verified, allowing an out-of-bounds read and a small out-of-bounds write. Validate that coded_len fits within the payload area of both destination and source sk_buffs before XORing. Fixes: 2df5278b0267 ("batman-adv: network coding - receive coded packets and decode them") Cc: stable@vger.kernel.org Reported-by: Stanislav Fort Signed-off-by: Stanislav Fort Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/network-coding.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -1687,7 +1687,12 @@ batadv_nc_skb_decode_packet(struct batad coding_len = ntohs(coded_packet_tmp.coded_len); - if (coding_len > skb->len) + /* ensure dst buffer is large enough (payload only) */ + if (coding_len + h_size > skb->len) + return NULL; + + /* ensure src buffer is large enough (payload only) */ + if (coding_len + h_size > nc_packet->skb->len) return NULL; /* Here the magic is reversed: