From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout-y-209.mailbox.org (mout-y-209.mailbox.org [91.198.250.237]) (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 21D7523AE62; Thu, 9 Apr 2026 02:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.198.250.237 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775703003; cv=none; b=LEcUUQTXqw/isheZKjxq7nGWUXxmMfIk9AjKEFP20zV2PwRuvRA6eF05ZWtKEYcnIPs7TgIz3tlw229K/pnb50glL/bGa5nlZL3yBdCWtRUs2Vkb+Y8ozU79EBgQbv7kg7DLHmUI/Q9MeKBqzPO3sPGGsB3OggGeEhkKnbDGdvI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775703003; c=relaxed/simple; bh=0Pbj/t9PBA+V4Pfq4iqpUh+BvdT7LJ1OhIxqSu0zNZk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ciU4O9HueC3Upy6sL+y3+Lvs3kre+Y6wqPyNHTTRqZg1sQdmDJ8KMHKbqDUuD8hQfl5OI2AXG+h+WRzUf9ZwEb5tsr5xeqAEswXt7Wbbt5dSz1VnD/u1ej3xDw0qsXT1SUPEckc8/kUWMcnBWjNd7+24yB6XKyMkOwvX/I19KUo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org; spf=pass smtp.mailfrom=mailbox.org; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b=wl8qgk7H; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b=L31CVT8E; arc=none smtp.client-ip=91.198.250.237 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mailbox.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="wl8qgk7H"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="L31CVT8E" Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-y-209.mailbox.org (Postfix) with ESMTPS id 4frktZ4bmqzB14V; Thu, 9 Apr 2026 04:49:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1775702998; 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=GsidmfB0EwnTNO061hNze2h62VV8OIyujPFbtg3of64=; b=wl8qgk7HJK8ClFdJmmlV5Ml3K9YwnztQS9upxm2OxqJjAmztHeNAyR0OJ5MC8dqWKLuohR JwERnE9heEMtBxwZBGfVlLhyZOGWUPVFaEc3meXkESZzCKHqJo1G0Aggej81KqPzYuHpuA /eprfRiZ3mH/LbLTc62ViQF1OCpdAP/NZv9/eySJz479J+Cal/QocLjfyjSQsdVx5ahH8l 4KXcGCZ/6Ps4K0AoMDLv+sAs0VartZWoO7sbGkFyqNhUYm15MToqyNIAC85Vfq64Wd7vv8 Wo48Q4qYBSKgOWaj8/KJJedgZTC44V+Wlh+HfW/t33Dy2NGcVSkrdnlO5B9gpg== Authentication-Results: outgoing_mbo_mout; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=L31CVT8E; spf=pass (outgoing_mbo_mout: domain of mashiro.chen@mailbox.org designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=mashiro.chen@mailbox.org From: Mashiro Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1775702997; 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=GsidmfB0EwnTNO061hNze2h62VV8OIyujPFbtg3of64=; b=L31CVT8EQppmgQQoIEObaUH1PTbNAEPieZR+C6RVCXhEGqFyWPswcnsseuKC+5wgBLEIVK 3jpLTG3SnCI000X+m6IKMWxUoryCRgfvlHl+9mp4Hyn+DieNLNtHMOCs0uf6CyUyynasNZ gf+9Bb5Q+X2/iyrFfuyPAkvHkz5l7jLwzgeoEiROqqKaF56JQsnTXYvGyHlL7BmfvfJS9S 9XI5U4WQIbX6u1EVDATbz/Jtdhlg6IjLxLNZ3/5KKyuW8psIPi3Ivzp68ffeyKgmvb0mic JrUyBPiBC+xrfDiG3xS+cOqdBVgvndsLcGR4/2iK9Qu9hg3383wYEH9J2w6c0g== To: netdev@vger.kernel.org Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jreuter@yaina.de, linux-hams@vger.kernel.org, linux-kernel@vger.kernel.org, Mashiro Chen , stable@vger.kernel.org Subject: [PATCH v2 net 1/2] net: hamradio: bpqether: validate frame length in bpq_rcv() Date: Thu, 9 Apr 2026 10:49:26 +0800 Message-ID: <20260409024927.24397-2-mashiro.chen@mailbox.org> In-Reply-To: <20260409024927.24397-1-mashiro.chen@mailbox.org> References: <20260409024927.24397-1-mashiro.chen@mailbox.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MBO-RS-META: pgimnr9g3bswf9q61zcp5it94phwbyo4 X-MBO-RS-ID: f1c15c24337190e2404 X-Rspamd-Queue-Id: 4frktZ4bmqzB14V The BPQ length field is decoded as: len = skb->data[0] + skb->data[1] * 256 - 5; If the sender sets bytes [0..1] to values whose combined value is less than 5, len becomes negative. Passing a negative int to skb_trim() silently converts to a huge unsigned value, causing the function to be a no-op. The frame is then passed up to AX.25 with its original (untrimmed) payload, delivering garbage beyond the declared frame boundary. Additionally, a negative len corrupts the 64-bit rx_bytes counter through implicit sign-extension. Add a bounds check before pulling the length bytes: reject frames where len is negative or exceeds the remaining skb data. Cc: stable@vger.kernel.org Cc: linux-hams@vger.kernel.org Acked-by: Joerg Reuter Signed-off-by: Mashiro Chen --- drivers/net/hamradio/bpqether.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c index 045c5177262eaf..214fd1f819a1bb 100644 --- a/drivers/net/hamradio/bpqether.c +++ b/drivers/net/hamradio/bpqether.c @@ -187,6 +187,9 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty len = skb->data[0] + skb->data[1] * 256 - 5; + if (len < 0 || len > skb->len - 2) + goto drop_unlock; + skb_pull(skb, 2); /* Remove the length bytes */ skb_trim(skb, len); /* Set the length of the data */ -- 2.53.0